commit 92d5775a4658249fb3e4e421c543431a49d51ca2
parent be845ac25c0ea33fee28ec3bf649b41dd7215b4a
Author: fundamental <[email protected]>
Date: Tue, 10 Feb 2015 21:30:19 -0500
More Presets Restoration
Diffstat:
11 files changed, 73 insertions(+), 19 deletions(-)
diff --git a/src/Misc/Master.cpp b/src/Misc/Master.cpp
@@ -100,12 +100,13 @@ static Ports localports = {
d.reply("/free", "sb", "Part", sizeof(void*), &m->part[i]);
m->part[i] = p;
p->initialize_rt();
- printf("part %d is now pointer %p\n", i, p);}},
+ //printf("part %d is now pointer %p\n", i, p);
+ }},
{"Pvolume::i", rDoc("Master Volume"), 0,
[](const char *m, rtosc::RtData &d) {
if(rtosc_narguments(m)==0) {
d.reply(d.loc, "i", ((Master*)d.obj)->Pvolume);
- } else if(rtosc_narguments(m)==1 && rtosc_type(m,0)=='c') {
+ } else if(rtosc_narguments(m)==1 && rtosc_type(m,0)=='i') {
((Master*)d.obj)->setPvolume(limit<char>(rtosc_argument(m,0).i,0,127));
d.broadcast(d.loc, "i", ((Master*)d.obj)->Pvolume);}}},
{"volume::i", rDoc("Master Volume"), 0,
@@ -532,6 +533,7 @@ void dump_msg(const char* ptr, std::ostream& os = std::cerr)
}
#endif
+int msg_id=0;
/*
* Master audio out (the final sound)
@@ -567,7 +569,7 @@ void Master::AudioOut(float *outl, float *outr)
//XXX yes, this is not realtime safe, but it is useful...
if(strcmp(msg, "/get-vu") && false) {
fprintf(stdout, "%c[%d;%d;%dm", 0x1B, 0, 5 + 30, 0 + 40);
- fprintf(stdout, "backend: '%s'<%s>\n", msg,
+ fprintf(stdout, "backend[%d]: '%s'<%s>\n", msg_id++, msg,
rtosc_argument_string(msg));
fprintf(stdout, "%c[%d;%d;%dm", 0x1B, 0, 7 + 30, 0 + 40);
}
@@ -577,7 +579,7 @@ void Master::AudioOut(float *outl, float *outr)
events++;
if(!d.matches) {// && !ports.apropos(msg)) {
fprintf(stderr, "%c[%d;%d;%dm", 0x1B, 1, 7 + 30, 0 + 40);
- fprintf(stderr, "Unknown address '%s'\n", uToB->peak());
+ fprintf(stderr, "Unknown address<BACKEND> '%s:%s'\n", uToB->peak(), rtosc_argument_string(uToB->peak()));
#if 0
if(strstr(msg, "PFMVelocity"))
dump_msg(msg);
diff --git a/src/Misc/MiddleWare.cpp b/src/Misc/MiddleWare.cpp
@@ -790,6 +790,7 @@ void MiddleWareImpl::doReadOnlyOp(std::function<void()> read_only_fn)
void MiddleWareImpl::bToUhandle(const char *rtmsg)
{
assert(strcmp(rtmsg, "/part0/kit0/Ppadenableda"));
+ assert(strcmp(rtmsg, "/ze_state"));
//Dump Incomming Events For Debugging
if(strcmp(rtmsg, "/vu-meter") && false) {
fprintf(stdout, "%c[%d;%d;%dm", 0x1B, 0, 1 + 30, 0 + 40);
@@ -942,7 +943,7 @@ void MiddleWareImpl::handleMsg(const char *msg)
assert(!strstr(msg,"free"));
assert(msg && *msg && rindex(msg, '/')[1]);
//fprintf(stdout, "%c[%d;%d;%dm", 0x1B, 0, 6 + 30, 0 + 40);
- //fprintf(stdout, "middleware: '%s'\n", msg);
+ //fprintf(stdout, "middleware: '%s':%s\n", msg, rtosc_argument_string(msg));
//fprintf(stdout, "%c[%d;%d;%dm", 0x1B, 0, 7 + 30, 0 + 40);
const char *last_path = rindex(msg, '/');
if(!last_path)
@@ -1048,6 +1049,10 @@ class UI_Interface:public Fl_Osc_Interface
{
va_list va;
va_start(va, args);
+ //fprintf(stderr, "%c[%d;%d;%dm", 0x1B, 0, 4 + 30, 0 + 40);
+ ////fprintf(stderr, ".");
+ //fprintf(stderr, "write(%s:%s)\n", s.c_str(), args);
+ //fprintf(stderr, "%c[%d;%d;%dm", 0x1B, 0, 7 + 30, 0 + 40);
impl->write(s.c_str(), args, va);
va_end(va);
}
@@ -1055,8 +1060,8 @@ class UI_Interface:public Fl_Osc_Interface
void writeRaw(const char *msg) override
{
fprintf(stderr, "%c[%d;%d;%dm", 0x1B, 0, 4 + 30, 0 + 40);
- fprintf(stderr, ".");
- //fprintf(stderr, "write(%s)\n", msg);
+ //fprintf(stderr, ".");
+ fprintf(stderr, "rawWrite(%s:%s)\n", msg, rtosc_argument_string(msg));
fprintf(stderr, "%c[%d;%d;%dm", 0x1B, 0, 7 + 30, 0 + 40);
impl->handleMsg(msg);
}
@@ -1095,8 +1100,8 @@ class UI_Interface:public Fl_Osc_Interface
void renameLink(string old, string newer, Fl_Osc_Widget *w) override
{
- //fprintf(stdout, "renameLink('%s','%s',%p)\n",
- // old.c_str(), newer.c_str(), w);
+ fprintf(stdout, "renameLink('%s','%s',%p)\n",
+ old.c_str(), newer.c_str(), w);
removeLink(old, w);
createLink(newer, w);
}
diff --git a/src/Misc/PresetExtractor.cpp b/src/Misc/PresetExtractor.cpp
@@ -111,12 +111,20 @@ void doClassPaste(std::string type, MiddleWare &mw, string url, string data)
{
if(type == "EnvelopeParams")
doPaste<EnvelopeParams>(mw, url, data);
+ if(type == "LFOParams")
+ doPaste<LFOParams>(mw, url, data);
+ if(type == "FilterParams")
+ doPaste<FilterParams>(mw, url, data);
}
std::string doClassCopy(std::string type, MiddleWare &mw, string url)
{
if(type == "EnvelopeParams")
return doCopy<EnvelopeParams>(mw, url);
+ if(type == "LFOParams")
+ return doCopy<LFOParams>(mw, url);
+ if(type == "FilterParams")
+ return doCopy<FilterParams>(mw, url);
return "UNDEF";
}
diff --git a/src/Misc/Util.h b/src/Misc/Util.h
@@ -206,7 +206,7 @@ const char *message_snip(const char *m);
[](const char *, rtosc::RtData &d){ \
d.reply(d.loc, "b", sizeof(d.obj), &d.obj);}}\
-#define rPaste(type) \
+#define rPaste() \
{"paste:b", rProp(internal) rDoc("paste port"), 0, \
[](const char *m, rtosc::RtData &d){ \
printf("rPaste...\n"); \
diff --git a/src/Params/FilterParams.cpp b/src/Params/FilterParams.cpp
@@ -61,6 +61,8 @@ static rtosc::Ports subports = {
#undef rChangeCb
#define rChangeCb obj->changed = true;
rtosc::Ports FilterParams::ports = {
+ rSelf(FilterParams),
+ rPaste(),
rParamZyn(Pcategory, "Class of filter"),
rParamZyn(Ptype, "Filter Type"),
rParamZyn(Pfreq, "Center Freq"),
@@ -80,7 +82,7 @@ rtosc::Ports FilterParams::ports = {
rToggle(Psequencereversed, "If the modulator input is inverted"),
//{"Psequence#" FF_MAX_SEQUENCE "/nvowel", "", NULL, [](){}},
-
+
//UI reader
{"Pvowels:", rDoc("Get Formant Vowels"), NULL,
[](const char *, RtData &d) {
@@ -98,7 +100,7 @@ rtosc::Ports FilterParams::ports = {
FilterParams *obj = (FilterParams *) d.obj;
d.obj = (void*)&obj->Pvowels[idx];
subports.dispatch(msg, d);
-
+
if(rtosc_narguments(msg))
rChangeCb;
}},
@@ -121,6 +123,10 @@ rtosc::Ports FilterParams::ports = {
+FilterParams::FilterParams()
+ :FilterParams(0,64,64)
+{
+}
FilterParams::FilterParams(unsigned char Ptype_,
unsigned char Pfreq_,
unsigned char Pq_)
@@ -489,3 +495,11 @@ void FilterParams::getfromXML(XMLwrapper *xml)
xml->exitbranch();
}
}
+
+void FilterParams::paste(FilterParams &x)
+{
+ //Avoid undefined behavior
+ if(&x == this)
+ return;
+ memcpy((char*)this, (const char*)&x, sizeof(*this));
+}
diff --git a/src/Params/FilterParams.h b/src/Params/FilterParams.h
@@ -30,6 +30,7 @@
class FilterParams:public PresetsArray
{
public:
+ FilterParams();
FilterParams(unsigned char Ptype_,
unsigned char Pfreq,
unsigned char Pq_);
@@ -40,6 +41,7 @@ class FilterParams:public PresetsArray
void defaults();
void getfromXML(XMLwrapper *xml);
void getfromXMLsection(XMLwrapper *xml, int n);
+ void paste(FilterParams &);
void getfromFilterParams(FilterParams *pars);
diff --git a/src/Params/LFOParams.cpp b/src/Params/LFOParams.cpp
@@ -33,6 +33,8 @@ using namespace rtosc;
#define rObject LFOParams
static rtosc::Ports _ports = {
+ rSelf(LFOParams),
+ rPaste(),
rParamF(Pfreq, "frequency of LFO"),
rParamZyn(Pintensity, "Intensity of LFO"),
rParamZyn(Pstartphase, rSpecial(random), "Starting Phase"),
@@ -48,6 +50,21 @@ rtosc::Ports &LFOParams::ports = _ports;
int LFOParams::time;
+LFOParams::LFOParams()
+{
+ Dfreq = 64;
+ Dintensity = 0;
+ Dstartphase = 0;
+ DLFOtype = 0;
+ Drandomness = 0;
+ Ddelay = 0;
+ Dcontinous = 0;
+ fel = 0;
+ time = 0;
+
+ defaults();
+}
+
LFOParams::LFOParams(char Pfreq_,
char Pintensity_,
char Pstartphase_,
@@ -123,3 +140,11 @@ void LFOParams::getfromXML(XMLwrapper *xml)
Pstretch = xml->getpar127("stretch", Pstretch);
Pcontinous = xml->getparbool("continous", Pcontinous);
}
+
+void LFOParams::paste(LFOParams &x)
+{
+ //Avoid undefined behavior
+ if(&x == this)
+ return;
+ memcpy((char*)this, (const char*)&x, sizeof(*this));
+}
diff --git a/src/Params/LFOParams.h b/src/Params/LFOParams.h
@@ -29,6 +29,7 @@
class LFOParams:public Presets
{
public:
+ LFOParams();
LFOParams(char Pfreq_,
char Pintensity_,
char Pstartphase_,
@@ -43,6 +44,7 @@ class LFOParams:public Presets
void defaults();
/**Loads the LFO from the xml*/
void getfromXML(XMLwrapper *xml);
+ void paste(LFOParams &);
/* MIDI Parameters*/
float Pfreq; /**<frequency*/
diff --git a/src/Synth/OscilGen.cpp b/src/Synth/OscilGen.cpp
@@ -1168,7 +1168,7 @@ void OscilGen::add2XML(XMLwrapper *xml)
for(int i = 1; i < synth->oscilsize / 2; ++i) {
float xc = basefuncFFTfreqs[i].real();
float xs = basefuncFFTfreqs[i].imag();
- if((fabs(xs) > 0.00001f) && (fabs(xc) > 0.00001f)) {
+ if((fabs(xs) > 1e-6f) && (fabs(xc) > 1e-6f)) {
xml->beginbranch("BF_HARMONIC", i);
xml->addparreal("cos", xc);
xml->addparreal("sin", xs);
diff --git a/src/Tests/guitar-adnote.xmz b/src/Tests/guitar-adnote.xmz
@@ -3284,10 +3284,6 @@ version-revision="4" ZynAddSubFX-author="Nasca Octavian Paul">
<par_real name="cos" value="-0.00259324" />
<par_real name="sin" value="0.00159791" />
</BF_HARMONIC>
-<BF_HARMONIC id="509">
-<par_real name="cos" value="-9.35799e-07" />
-<par_real name="sin" value="-4.35678e-05" />
-</BF_HARMONIC>
<BF_HARMONIC id="510">
<par_real name="cos" value="-0.00690247" />
<par_real name="sin" value="0.000466586" />
diff --git a/src/UI/LFOUI.fl b/src/UI/LFOUI.fl
@@ -149,12 +149,12 @@ hide();} {}
}
Fl_Button {} {
label C
- callback {//presetsui->copy(pars);}
+ callback {presetsui->copy(lfoparamswindow->loc());}
xywh {145 10 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55 deactivate
}
Fl_Button {} {
label P
- callback {//presetsui->paste(pars,this);}
+ callback {presetsui->paste(lfoparamswindow->loc(),this);}
xywh {162 10 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55 deactivate
}
}