From db5fb1cd05e9a16f1cf66031589cff09774b4063 Mon Sep 17 00:00:00 2001 From: falkTX Date: Mon, 9 Nov 2015 10:50:52 +0100 Subject: [PATCH] Update zyn again, fix carla code to match Closes #318 Closes #323 --- source/native-plugins/zynaddsubfx-ui.cpp | 20 +++--- .../zynaddsubfx/DSP/FormantFilter.cpp | 13 ++-- .../zynaddsubfx/Effects/Chorus.cpp | 5 +- .../zynaddsubfx/Effects/EffectLFO.cpp | 3 +- .../zynaddsubfx/Effects/Phaser.cpp | 6 +- .../zynaddsubfx/Misc/Master.cpp | 14 ++-- .../zynaddsubfx/Misc/Microtonal.cpp | 2 +- .../zynaddsubfx/Misc/MiddleWare.cpp | 26 ++++++- .../zynaddsubfx/Params/EnvelopeParams.cpp | 29 +++++--- .../zynaddsubfx/Params/EnvelopeParams.h | 4 +- .../zynaddsubfx/Params/FilterParams.cpp | 38 +++++++++-- .../zynaddsubfx/Params/LFOParams.cpp | 15 ++-- .../zynaddsubfx/Params/PADnoteParameters.cpp | 5 +- .../native-plugins/zynaddsubfx/Synth/LFO.cpp | 31 ++++++++- source/native-plugins/zynaddsubfx/Synth/LFO.h | 4 ++ .../zynaddsubfx/Synth/OscilGen.cpp | 60 +++++++++++----- .../zynaddsubfx/Synth/Resonance.cpp | 13 +++- .../native-plugins/zynaddsubfx/UI/ADnoteUI.fl | 32 +++++++-- .../native-plugins/zynaddsubfx/UI/BankUI.fl | 2 +- .../zynaddsubfx/UI/BankView.cpp | 5 +- .../zynaddsubfx/UI/Fl_Osc_Dial.cpp | 9 ++- .../zynaddsubfx/UI/Fl_Osc_DialF.H | 3 + .../zynaddsubfx/UI/Fl_Osc_DialF.cpp | 20 +++++- .../zynaddsubfx/UI/Fl_Osc_Pane.H | 2 + .../zynaddsubfx/UI/Fl_Osc_Pane.cpp | 8 +++ .../zynaddsubfx/UI/Fl_Osc_Slider.H | 5 ++ .../zynaddsubfx/UI/Fl_Osc_Slider.cpp | 68 +++++++++++-------- .../native-plugins/zynaddsubfx/UI/MasterUI.fl | 9 ++- .../zynaddsubfx/UI/Osc_IntModel.h | 8 +++ .../zynaddsubfx/UI/OscilGenUI.fl | 24 +++---- .../zynaddsubfx/UI/PADnoteUI.fl | 57 +++++++++++++--- .../native-plugins/zynaddsubfx/UI/PartUI.fl | 20 +++++- .../zynaddsubfx/UI/SUBnoteUI.fl | 10 +-- .../zynaddsubfx/UI/WidgetPDial.cpp | 2 +- .../native-plugins/zynaddsubfx/UI/guimain.cpp | 29 +++++++- source/utils/CarlaPluginUI.cpp | 5 +- 36 files changed, 451 insertions(+), 155 deletions(-) diff --git a/source/native-plugins/zynaddsubfx-ui.cpp b/source/native-plugins/zynaddsubfx-ui.cpp index c6daced98..d918c899c 100644 --- a/source/native-plugins/zynaddsubfx-ui.cpp +++ b/source/native-plugins/zynaddsubfx-ui.cpp @@ -183,8 +183,7 @@ protected: CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(uiTitle), true); try { - MasterUI* const ui((MasterUI*)gui); - ui->masterwindow->label(uiTitle); + GUI::raiseUi(gui, "/ui/title", "s", uiTitle); } CARLA_SAFE_EXCEPTION("msgReceived uiTitle"); return true; } @@ -224,29 +223,28 @@ int main(int argc, const char* argv[]) lo_server_add_method(server, NULL, NULL, handler_function, 0); } + std::thread lo_watch(watch_lo); gui = GUI::createUi(new UI_Interface(), &Pexitprogram); if (argc == 1) GUI::raiseUi(gui, "/show", "i", 1); - if (uiTitle != nullptr) - { - MasterUI* const ui((MasterUI*)gui); - ui->masterwindow->label(uiTitle); - } + if (uiTitle != nullptr && uiTitle[0] != '\0') + GUI::raiseUi(gui, "/ui/title", "s", uiTitle); for (; Pexitprogram == 0;) { - if (server != nullptr) { - for (; lo_server_recv_noblock(server, 0);) {} - } - pipe.idlePipe(); GUI::tickUi(gui); + + for (; lo_buffer.hasNext();) + raiseUi(gui, lo_buffer.read()); } GUI::destroyUi(gui); gui = nullptr; + + lo_watch.join(); return 0; } diff --git a/source/native-plugins/zynaddsubfx/DSP/FormantFilter.cpp b/source/native-plugins/zynaddsubfx/DSP/FormantFilter.cpp index 6e1dd5044..4773106e8 100644 --- a/source/native-plugins/zynaddsubfx/DSP/FormantFilter.cpp +++ b/source/native-plugins/zynaddsubfx/DSP/FormantFilter.cpp @@ -115,21 +115,16 @@ void FormantFilter::setpos(float frequency) else oldinput = input; - float pos = fmodf(input * sequencestretch, 1.0f); - if(pos < 0.0f) - pos += 1.0f; + float pos = input * sequencestretch; + pos -= floorf(pos); F2I(pos * sequencesize, p2); p1 = p2 - 1; if(p1 < 0) p1 += sequencesize; - pos = fmodf(pos * sequencesize, 1.0f); - if(pos < 0.0f) - pos = 0.0f; - else - if(pos > 1.0f) - pos = 1.0f; + pos = pos * sequencesize; + pos -= floorf(pos); pos = (atanf((pos * 2.0f - 1.0f) diff --git a/source/native-plugins/zynaddsubfx/Effects/Chorus.cpp b/source/native-plugins/zynaddsubfx/Effects/Chorus.cpp index 4f44297af..df713b607 100644 --- a/source/native-plugins/zynaddsubfx/Effects/Chorus.cpp +++ b/source/native-plugins/zynaddsubfx/Effects/Chorus.cpp @@ -69,7 +69,6 @@ float Chorus::getdelay(float xlfo) //Apply the effect void Chorus::out(const Stereo &input) { - const float one = 1.0f; dl1 = dl2; dr1 = dr2; lfo.effectlfoout(&lfol, &lfor); @@ -98,7 +97,7 @@ void Chorus::out(const Stereo &input) dlhi %= maxdelay; float dlhi2 = (dlhi - 1 + maxdelay) % maxdelay; - float dllo = 1.0f - fmod(tmp, one); + float dllo = 1.0f + floorf(tmp) - tmp; efxoutl[i] = cinterpolate(delaySample.l, maxdelay, dlhi2) * dllo + cinterpolate(delaySample.l, maxdelay, dlhi) * (1.0f - dllo); @@ -116,7 +115,7 @@ void Chorus::out(const Stereo &input) dlhi %= maxdelay; dlhi2 = (dlhi - 1 + maxdelay) % maxdelay; - dllo = 1.0f - fmodf(tmp, one); + dllo = 1.0f + floorf(tmp) - tmp; efxoutr[i] = cinterpolate(delaySample.r, maxdelay, dlhi2) * dllo + cinterpolate(delaySample.r, maxdelay, dlhi) * (1.0f - dllo); diff --git a/source/native-plugins/zynaddsubfx/Effects/EffectLFO.cpp b/source/native-plugins/zynaddsubfx/Effects/EffectLFO.cpp index 3d2361040..a363fcdb4 100644 --- a/source/native-plugins/zynaddsubfx/Effects/EffectLFO.cpp +++ b/source/native-plugins/zynaddsubfx/Effects/EffectLFO.cpp @@ -60,7 +60,8 @@ void EffectLFO::updateparams(void) if(PLFOtype > 1) PLFOtype = 1; //this has to be updated if more lfo's are added lfotype = PLFOtype; - xr = fmodf(xl + (Pstereo - 64.0f) / 127.0f + 1.0f, 1.0f); + xr = xl + (Pstereo - 64.0f) / 127.0f + 1.0f; + xr -= floorf(xr); } diff --git a/source/native-plugins/zynaddsubfx/Effects/Phaser.cpp b/source/native-plugins/zynaddsubfx/Effects/Phaser.cpp index a764c8fd6..909429874 100644 --- a/source/native-plugins/zynaddsubfx/Effects/Phaser.cpp +++ b/source/native-plugins/zynaddsubfx/Effects/Phaser.cpp @@ -135,8 +135,10 @@ void Phaser::AnalogPhase(const Stereo &input) Stereo xn(input.l[i] * pangainL, input.r[i] * pangainR); if(barber) { - g.l = fmodf((g.l + 0.25f), ONE_); - g.r = fmodf((g.r + 0.25f), ONE_); + g.l += 0.25; + g.l -= floorf(g.l); + g.r += 0.25; + g.r -= floorf(g.r); } xn.l = applyPhase(xn.l, g.l, fb.l, hpf.l, yn1.l, xn1.l); diff --git a/source/native-plugins/zynaddsubfx/Misc/Master.cpp b/source/native-plugins/zynaddsubfx/Misc/Master.cpp index 4af648620..bc662fc94 100644 --- a/source/native-plugins/zynaddsubfx/Misc/Master.cpp +++ b/source/native-plugins/zynaddsubfx/Misc/Master.cpp @@ -73,10 +73,11 @@ static const Ports sysefxPort = int ind2 = atoi(m); Master &mast = *(Master*)d.obj; - if(rtosc_narguments(m)) + if(rtosc_narguments(m)) { mast.setPsysefxvol(ind2, ind1, rtosc_argument(m,0).i); - else - d.reply(d.loc, "i", mast.Psysefxvol[ind2][ind1]); + d.broadcast(d.loc, "i", mast.Psysefxvol[ind1][ind2]); + } else + d.reply(d.loc, "i", mast.Psysefxvol[ind1][ind2]); }} }; @@ -112,8 +113,13 @@ static const Ports master_ports = { rRecursp(insefx, 8, "Insertion Effect"),//NUM_INS_EFX rRecur(microtonal, "Micrtonal Mapping Functionality"), rRecur(ctl, "Controller"), - rParamZyn(Pkeyshift, "Global Key Shift"), rArrayI(Pinsparts, NUM_INS_EFX, "Part to insert part onto"), + {"Pkeyshift::i", rProp(parameter) rLinear(0,127) rDoc("Global Key Shift"), 0, [](const char *m, RtData&d) { + if(rtosc_narguments(m)==0) { + d.reply(d.loc, "i", ((Master*)d.obj)->Pkeyshift); + } else if(rtosc_narguments(m)==1 && rtosc_type(m,0)=='i') { + ((Master*)d.obj)->setPkeyshift(limit(rtosc_argument(m,0).i,0,127)); + d.broadcast(d.loc, "i", ((Master*)d.obj)->Pkeyshift);}}}, {"echo", rDoc("Hidden port to echo messages"), 0, [](const char *m, RtData&d) { d.reply(m-1);}}, {"get-vu:", rDoc("Grab VU Data"), 0, [](const char *, RtData &d) { diff --git a/source/native-plugins/zynaddsubfx/Misc/Microtonal.cpp b/source/native-plugins/zynaddsubfx/Misc/Microtonal.cpp index 1f8eebc9e..ea698cf5b 100644 --- a/source/native-plugins/zynaddsubfx/Misc/Microtonal.cpp +++ b/source/native-plugins/zynaddsubfx/Misc/Microtonal.cpp @@ -655,7 +655,7 @@ void Microtonal::getfromXML(XMLwrapper *xml) //populate fields for display float x = logf(octave[i].tuning) / LOG_2 * 1200.0f; octave[i].x1 = (int) floor(x); - octave[i].x2 = (int) (floor(fmodf(x, 1.0f) * 1e6)); + octave[i].x2 = (int) (floor((x-octave[i].x1) * 1.0e6)); } diff --git a/source/native-plugins/zynaddsubfx/Misc/MiddleWare.cpp b/source/native-plugins/zynaddsubfx/Misc/MiddleWare.cpp index df418dd43..b3265dacc 100644 --- a/source/native-plugins/zynaddsubfx/Misc/MiddleWare.cpp +++ b/source/native-plugins/zynaddsubfx/Misc/MiddleWare.cpp @@ -324,13 +324,22 @@ struct NonRtObjStore void handlePad(const char *msg, rtosc::RtData &d) { string obj_rl(d.message, msg); void *pad = get(obj_rl); - if(!strcmp(msg, "prepare")) + if(!strcmp(msg, "prepare")) { preparePadSynth(obj_rl, (PADnoteParameters*)pad, d); - else { + d.matches++; + d.reply((obj_rl+"needPrepare").c_str(), "F"); + } else { assert(pad); strcpy(d.loc, obj_rl.c_str()); d.obj = pad; PADnoteParameters::non_realtime_ports.dispatch(msg, d); + if(rtosc_narguments(msg)) { + if(!strcmp(msg, "oscilgen/prepare")) + ; //ignore + else { + d.reply((obj_rl+"needPrepare").c_str(), "T"); + } + } } } }; @@ -782,6 +791,7 @@ rtosc::Ports bankPorts = { int i = 0; for(auto &elm : impl.banks) d.reply("/bank/bank_select", "iss", i++, elm.name.c_str(), elm.dir.c_str()); + d.reply("/bank/bank_select", "i", impl.bankpos); rEnd}, {"slot#1024:", 0, 0, @@ -977,6 +987,16 @@ static rtosc::Ports middwareSnoopPorts = { impl.pending_load[part_id]++; impl.loadPart(part_id, file, impl.master); rEnd}, + {"load-part:iss", 0, 0, + rBegin; + const int part_id = rtosc_argument(msg,0).i; + const char *file = rtosc_argument(msg,1).s; + const char *name = rtosc_argument(msg,2).s; + impl.pending_load[part_id]++; + impl.loadPart(part_id, file, impl.master); + impl.uToB->write(("/part"+to_s(part_id)+"/Pname").c_str(), "s", + name); + rEnd}, {"setprogram:i:c", 0, 0, rBegin; Bank &bank = impl.master->bank; @@ -984,6 +1004,7 @@ static rtosc::Ports middwareSnoopPorts = { if(slot < BANK_SIZE) { impl.pending_load[0]++; impl.loadPart(0, impl.master->bank.ins[slot].filename.c_str(), impl.master); + impl.uToB->write("/part0/Pname", "s", impl.master->bank.ins[slot].name.c_str()); } rEnd}, {"part#16/clear:", 0, 0, @@ -1039,6 +1060,7 @@ static rtosc::Ports middlewareReplyPorts = { const int part = rtosc_argument(msg, 0).i; const int program = rtosc_argument(msg, 1).i; impl.loadPart(part, impl.master->bank.ins[program].filename.c_str(), impl.master); + impl.uToB->write(("/part"+to_s(part)+"/Pname").c_str(), "s", impl.master->bank.ins[program].name.c_str()); rEnd}, {"undo_pause:", 0, 0, rBegin; impl.recording_undo = false; rEnd}, {"undo_resume:", 0, 0, rBegin; impl.recording_undo = true; rEnd}, diff --git a/source/native-plugins/zynaddsubfx/Params/EnvelopeParams.cpp b/source/native-plugins/zynaddsubfx/Params/EnvelopeParams.cpp index bf5f1d72f..6df860429 100644 --- a/source/native-plugins/zynaddsubfx/Params/EnvelopeParams.cpp +++ b/source/native-plugins/zynaddsubfx/Params/EnvelopeParams.cpp @@ -127,19 +127,30 @@ EnvelopeParams::EnvelopeParams(unsigned char Penvstretch_, EnvelopeParams::~EnvelopeParams() {} +#define COPY(y) this->y = ep.y void EnvelopeParams::paste(const EnvelopeParams &ep) { - //Avoid undefined behavior - if(&ep == this) - return; - - char *base = (char*)&this->Pfreemode; - char *end = (char*)&this->DR_val; - assert(end-base > 0); - - memcpy((char*)&this->Pfreemode, (const char*)&ep.Pfreemode, 1+end-base); + COPY(Pfreemode); + COPY(Penvpoints); + COPY(Penvsustain); + for(int i=0; iPenvdt[i] = ep.Penvdt[i]; + this->Penvval[i] = ep.Penvval[i]; + } + COPY(Penvstretch); + COPY(Pforcedrelease); + COPY(Plinearenvelope); + + COPY(PA_dt); + COPY(PD_dt); + COPY(PR_dt); + COPY(PA_val); + COPY(PD_val); + COPY(PS_val); + COPY(PR_val); } +#undef COPY float EnvelopeParams::getdt(char i) const { diff --git a/source/native-plugins/zynaddsubfx/Params/EnvelopeParams.h b/source/native-plugins/zynaddsubfx/Params/EnvelopeParams.h index da0ad0450..d6e65637c 100644 --- a/source/native-plugins/zynaddsubfx/Params/EnvelopeParams.h +++ b/source/native-plugins/zynaddsubfx/Params/EnvelopeParams.h @@ -54,9 +54,9 @@ class EnvelopeParams:public Presets static float dt(char val); /* MIDI Parameters */ - unsigned char Pfreemode; //1 daca este in modul free sau 0 daca este in mod ADSR,ASR,... + unsigned char Pfreemode; //1 for free mode, 0 otherwise unsigned char Penvpoints; - unsigned char Penvsustain; //127 pentru dezactivat + unsigned char Penvsustain; //127 for disabled unsigned char Penvdt[MAX_ENVELOPE_POINTS]; unsigned char Penvval[MAX_ENVELOPE_POINTS]; unsigned char Penvstretch; //64=normal stretch (piano-like), 0=no stretch diff --git a/source/native-plugins/zynaddsubfx/Params/FilterParams.cpp b/source/native-plugins/zynaddsubfx/Params/FilterParams.cpp index c0224a2b3..0af9dda05 100644 --- a/source/native-plugins/zynaddsubfx/Params/FilterParams.cpp +++ b/source/native-plugins/zynaddsubfx/Params/FilterParams.cpp @@ -420,13 +420,43 @@ void FilterParams::getfromXML(XMLwrapper *xml) } } +#define COPY(y) this->y = x.y void FilterParams::paste(FilterParams &x) { - //Avoid undefined behavior - if(&x == this) - return; - memcpy((char*)this, (const char*)&x, sizeof(*this)); + COPY(Pcategory); + COPY(Ptype); + COPY(Pfreq); + COPY(Pq); + COPY(Pstages); + COPY(Pfreqtrack); + COPY(Pgain); + + COPY(Pnumformants); + COPY(Pformantslowness); + COPY(Pvowelclearness); + COPY(Pcenterfreq); + COPY(Poctavesfreq); + + for(int i=0; iPvowels[i].formants[j]; + auto &b = x.Pvowels[i].formants[j]; + a.freq = b.freq; + a.amp = b.amp; + a.q = b.q; + } + } + + + COPY(Psequencesize); + COPY(Psequencestretch); + COPY(Psequencereversed); + for(int i=0; iPsequence[i] = x.Psequence[i]; + + COPY(changed); } +#undef COPY void FilterParams::pasteArray(FilterParams &x, int nvowel) { diff --git a/source/native-plugins/zynaddsubfx/Params/LFOParams.cpp b/source/native-plugins/zynaddsubfx/Params/LFOParams.cpp index 43dc08380..b35cfb9e3 100644 --- a/source/native-plugins/zynaddsubfx/Params/LFOParams.cpp +++ b/source/native-plugins/zynaddsubfx/Params/LFOParams.cpp @@ -142,10 +142,17 @@ void LFOParams::getfromXML(XMLwrapper *xml) Pcontinous = xml->getparbool("continous", Pcontinous); } +#define COPY(y) this->y=x.y void LFOParams::paste(LFOParams &x) { - //Avoid undefined behavior - if(&x == this) - return; - memcpy((char*)this, (const char*)&x, sizeof(*this)); + COPY(Pfreq); + COPY(Pintensity); + COPY(Pstartphase); + COPY(PLFOtype); + COPY(Prandomness); + COPY(Pfreqrand); + COPY(Pdelay); + COPY(Pcontinous); + COPY(Pstretch); } +#undef COPY diff --git a/source/native-plugins/zynaddsubfx/Params/PADnoteParameters.cpp b/source/native-plugins/zynaddsubfx/Params/PADnoteParameters.cpp index 79537fc03..575a8b63d 100644 --- a/source/native-plugins/zynaddsubfx/Params/PADnoteParameters.cpp +++ b/source/native-plugins/zynaddsubfx/Params/PADnoteParameters.cpp @@ -684,8 +684,9 @@ void PADnoteParameters::generatespectrum_bandwidthMode(float *spectrum, const float ibasefreq = realfreq / (synth.samplerate_f * 0.5f) * size; for(int i = 0; i < profilesize; ++i) { const float idfreq = (i / (float)profilesize - 0.5f) * ibw; - const int spfreq = (int) (idfreq + ibasefreq); - const float fspfreq = fmodf((float)idfreq + ibasefreq, 1.0f); + const float freqsum = idfreq + ibasefreq; + const int spfreq = (int)freqsum; + const float fspfreq = freqsum - spfreq; if(spfreq <= 0) continue; if(spfreq >= size - 1) diff --git a/source/native-plugins/zynaddsubfx/Synth/LFO.cpp b/source/native-plugins/zynaddsubfx/Synth/LFO.cpp index 37449959c..d8b272d45 100644 --- a/source/native-plugins/zynaddsubfx/Synth/LFO.cpp +++ b/source/native-plugins/zynaddsubfx/Synth/LFO.cpp @@ -31,7 +31,9 @@ LFO::LFO(const LFOParams &lfopars, float basefreq, const AbsTime &t) :delayTime(t, lfopars.Pdelay / 127.0f * 4.0f), //0..4 sec waveShape(lfopars.PLFOtype), - deterministic(!lfopars.Pfreqrand) + deterministic(!lfopars.Pfreqrand), + dt_(t.dt()), + lfopars_(lfopars), basefreq_(basefreq) { int stretch = lfopars.Pstretch; if(stretch == 0) @@ -114,6 +116,33 @@ float LFO::baseOut(const char waveShape, const float phase) const float LFO::lfoout() { + //update internals XXX TODO cleanup + { + waveShape = lfopars_.PLFOtype; + int stretch = lfopars_.Pstretch; + if(stretch == 0) + stretch = 1; + const float lfostretch = powf(basefreq_ / 440.0f, (stretch - 64.0f) / 63.0f); + + float lfofreq = + (powf(2, lfopars_.Pfreq * 10.0f) - 1.0f) / 12.0f * lfostretch; + + phaseInc = fabs(lfofreq) * dt_; + + switch(lfopars_.fel) { + case 1: + lfointensity = lfopars_.Pintensity / 127.0f; + break; + case 2: + lfointensity = lfopars_.Pintensity / 127.0f * 4.0f; + break; //in octave + default: + lfointensity = powf(2, lfopars_.Pintensity / 127.0f * 11.0f) - 1.0f; //in centi + //x -= 0.25f; //chance the starting phase + break; + } + } + float out = baseOut(waveShape, phase); if(waveShape == LFO_SINE || waveShape == LFO_TRIANGLE) diff --git a/source/native-plugins/zynaddsubfx/Synth/LFO.h b/source/native-plugins/zynaddsubfx/Synth/LFO.h index ebe5707a8..5a00bd555 100644 --- a/source/native-plugins/zynaddsubfx/Synth/LFO.h +++ b/source/native-plugins/zynaddsubfx/Synth/LFO.h @@ -64,6 +64,10 @@ class LFO //If After initialization there are no calls to random number gen. bool deterministic; + const float dt_; + const LFOParams &lfopars_; + const float basefreq_; + void computeNextFreqRnd(void); }; diff --git a/source/native-plugins/zynaddsubfx/Synth/OscilGen.cpp b/source/native-plugins/zynaddsubfx/Synth/OscilGen.cpp index 293c0ad82..174320e7e 100644 --- a/source/native-plugins/zynaddsubfx/Synth/OscilGen.cpp +++ b/source/native-plugins/zynaddsubfx/Synth/OscilGen.cpp @@ -1177,31 +1177,55 @@ void OscilGen::getcurrentbasefunction(float *smps) getbasefunction(smps); //the sine case } -#define PRESERVE(x) decltype(this->x) x = this->x -#define RESTORE(x) this->x = x +#define COPY(y) this->y = o.y void OscilGen::paste(OscilGen &o) { //XXX Figure out a better implementation of this sensitive to RT issues... - //Preserve Pointer Elements - PRESERVE(oscilFFTfreqs); - PRESERVE(pendingfreqs); - PRESERVE(tmpsmps); - PRESERVE(outoscilFFTfreqs); - PRESERVE(fft); - PRESERVE(basefuncFFTfreqs); - PRESERVE(res); - memcpy((char*)this, (char*)&o, sizeof(*this)); - RESTORE(oscilFFTfreqs); - RESTORE(pendingfreqs); - RESTORE(tmpsmps); - RESTORE(outoscilFFTfreqs); - RESTORE(fft); - RESTORE(basefuncFFTfreqs); - RESTORE(res); + for(int i=0; iPcurrentbasefunc) changebasefunction(); this->prepare(); } +#undef COPY void OscilGen::add2XML(XMLwrapper *xml) { diff --git a/source/native-plugins/zynaddsubfx/Synth/Resonance.cpp b/source/native-plugins/zynaddsubfx/Synth/Resonance.cpp index 0601ece9a..d2f2a360f 100644 --- a/source/native-plugins/zynaddsubfx/Synth/Resonance.cpp +++ b/source/native-plugins/zynaddsubfx/Synth/Resonance.cpp @@ -251,10 +251,21 @@ void Resonance::sendcontroller(MidiControllers ctl, float par) ctlbw = par; } +#define COPY(y) this->y = r.y void Resonance::paste(Resonance &r) { - memcpy((char*)this, (char*)&r, sizeof(r)); + COPY(Penabled); + for(int i=0; iPrespoints[i] = r.Prespoints[i]; + COPY(PmaxdB); + COPY(Pcenterfreq); + COPY(Poctavesfreq); + COPY(Pprotectthefundamental); + + COPY(ctlcenter); + COPY(ctlbw); } +#undef COPY void Resonance::add2XML(XMLwrapper *xml) { diff --git a/source/native-plugins/zynaddsubfx/UI/ADnoteUI.fl b/source/native-plugins/zynaddsubfx/UI/ADnoteUI.fl index 650851b95..f9b8dfcf1 100644 --- a/source/native-plugins/zynaddsubfx/UI/ADnoteUI.fl +++ b/source/native-plugins/zynaddsubfx/UI/ADnoteUI.fl @@ -1181,9 +1181,9 @@ resui->resonancewindow->show();} class ADvoiceUI } {} Fl_Button {} { - label {Close Window} + label {Close} callback {ADnoteVoice->hide();} - xywh {305 601 195 25} box THIN_UP_BOX labelfont 1 + xywh {700 601 60 25} box THIN_UP_BOX } Fl_Counter currentvoicecounter { label {Current Voice} @@ -1195,12 +1195,27 @@ advoice->change_voice(nvoice);} Fl_Button {} { label C callback {presetsui->copy(ADnoteVoice->loc(),nvoice);} - xywh {705 609 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55 + xywh {630 609 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55 } Fl_Button {} { label P callback {presetsui->paste(ADnoteVoice->loc(),this,nvoice);} - xywh {735 609 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55 + xywh {660 609 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55 + } + Fl_Button {} { + label {Show ADsynth} + callback {ADnoteGlobalParameters->show();} + xywh {280 601 110 25} labelfont 0 labelsize 12 + } + Fl_Button {} { + label {Show Voice List} + callback { + for (int i=0;irefreshlist(); + } + ADnoteVoiceList->show(); + } + xywh {400 601 130 25} labelfont 0 labelsize 12 } } Fl_Window ADnoteVoiceList { @@ -1237,9 +1252,9 @@ advoice->change_voice(nvoice);} xywh {285 15 25 10} box NO_BOX labelfont 1 labelsize 11 } Fl_Button {} { - label {Hide Voice List} + label {Close} callback {ADnoteVoiceList->hide();} - xywh {271 237 125 20} + xywh {271 237 80 20} } Fl_Scroll {} {open xywh {0 15 670 220} type VERTICAL box THIN_UP_BOX @@ -1249,6 +1264,11 @@ advoice->change_voice(nvoice);} code0 {o->begin();for (int i=0;iinit(i,loc+"VoicePar"+to_s(i)+"/",osc);}o->end();} } {} } + Fl_Button {} { + label {Edit ADsynth} + callback {ui->partui->adnoteui->ADnoteGlobalParameters->show();} + xywh {5 237 106 20} labelsize 12 + } } } Function {ADnoteUI(std::string loc_, Fl_Osc_Interface *osc_)} {open diff --git a/source/native-plugins/zynaddsubfx/UI/BankUI.fl b/source/native-plugins/zynaddsubfx/UI/BankUI.fl index 6c5fc99b7..f98b61b81 100644 --- a/source/native-plugins/zynaddsubfx/UI/BankUI.fl +++ b/source/native-plugins/zynaddsubfx/UI/BankUI.fl @@ -138,7 +138,7 @@ bankview->refresh();} {} Function {rescan_for_banks()} {open } { code {banklist->clear(); - osc->write("/rescanforbanks"); + osc->write("/bank/rescan"); if (banklist->size() == 0) banklist->add(" ");} {} } diff --git a/source/native-plugins/zynaddsubfx/UI/BankView.cpp b/source/native-plugins/zynaddsubfx/UI/BankView.cpp index b6d45ccbe..5fd11432d 100644 --- a/source/native-plugins/zynaddsubfx/UI/BankView.cpp +++ b/source/native-plugins/zynaddsubfx/UI/BankView.cpp @@ -282,8 +282,9 @@ void BankView::react(int event, int nslot) //Reads from slot if ((event==1)&&(mode==1) && !isempty){ printf("Loading a part #%d with file '%s'\n", nslot, slot.filename()); - osc->write("/load-part", "is", *npart, slot.filename()); - osc->writeValue("/part"+to_s(*npart)+"/name", slot.name()); + osc->write("/load-part", "iss", *npart, slot.filename(), + slot.name()); + osc->writeValue("/part"+to_s(*npart)+"/Pname", slot.name()); if(cbwig_) cbwig_->do_callback(); } diff --git a/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Dial.cpp b/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Dial.cpp index e4040d397..929d9be9b 100644 --- a/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Dial.cpp +++ b/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Dial.cpp @@ -78,15 +78,14 @@ int Fl_Osc_Dial::handle(int ev) void Fl_Osc_Dial::OSC_value(int v) { - if(64 != (int)minimum()) - value(v+minimum()+fmodf(value(), 1)); - else - value(v+fmodf(value(), 1)); + value(v + value() - floorf(value()) + + (minimum() == 64 ? 0 : minimum())); } void Fl_Osc_Dial::OSC_value(char v) { - value(v+minimum()+fmodf(value(), 1)); + value(v + value() - floorf(value()) + + minimum()); } void Fl_Osc_Dial::update(void) diff --git a/source/native-plugins/zynaddsubfx/UI/Fl_Osc_DialF.H b/source/native-plugins/zynaddsubfx/UI/Fl_Osc_DialF.H index e68d61450..77c93066f 100644 --- a/source/native-plugins/zynaddsubfx/UI/Fl_Osc_DialF.H +++ b/source/native-plugins/zynaddsubfx/UI/Fl_Osc_DialF.H @@ -17,6 +17,9 @@ class Fl_Osc_DialF:public WidgetPDial, public Fl_Osc_Widget void update(void); void callback(Fl_Callback *cb, void *p = NULL); + //Midi learn handler + int handle(int); + void cb(void); private: std::pair cb_data; diff --git a/source/native-plugins/zynaddsubfx/UI/Fl_Osc_DialF.cpp b/source/native-plugins/zynaddsubfx/UI/Fl_Osc_DialF.cpp index 5b3390cff..502c5236f 100644 --- a/source/native-plugins/zynaddsubfx/UI/Fl_Osc_DialF.cpp +++ b/source/native-plugins/zynaddsubfx/UI/Fl_Osc_DialF.cpp @@ -51,11 +51,27 @@ void Fl_Osc_DialF::callback(Fl_Callback *cb, void *p) cb_data.second = p; } +int Fl_Osc_DialF::handle(int ev) +{ + bool middle_mouse = (ev == FL_PUSH && Fl::event_state(FL_BUTTON2) && !Fl::event_shift()); + bool ctl_click = (ev == FL_PUSH && Fl::event_state(FL_BUTTON1) && Fl::event_ctrl()); + bool shift_middle = (ev == FL_PUSH && Fl::event_state(FL_BUTTON2) && Fl::event_shift()); + if(middle_mouse || ctl_click) { + printf("Trying to learn...\n"); + osc->write("/learn", "s", (loc+ext).c_str()); + return 1; + } else if(shift_middle) { + osc->write("/unlearn", "s", (loc+ext).c_str()); + return 1; + } + return WidgetPDial::handle(ev); +} + void Fl_Osc_DialF::OSC_value(float v) { value(v); } - + void Fl_Osc_DialF::update(void) { oscWrite(ext); @@ -66,7 +82,7 @@ void Fl_Osc_DialF::cb(void) assert(osc); oscWrite(ext, "f", (float)value()); - + if(cb_data.first) cb_data.first(this, cb_data.second); // label_str = string_cast(val); diff --git a/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Pane.H b/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Pane.H index 9d9e9b803..7c6a10e4e 100644 --- a/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Pane.H +++ b/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Pane.H @@ -18,6 +18,7 @@ class Fl_Osc_Pane class Fl_Osc_Window:public Fl_Double_Window, public Fl_Osc_Pane { Osc_DataModel *title_ext; + std::string rewrite_rule; std::string title_orig; std::string title_new; public: @@ -28,6 +29,7 @@ class Fl_Osc_Window:public Fl_Double_Window, public Fl_Osc_Pane virtual std::string loc(void) const; virtual void rebase(std::string new_base); void update(); + void update_title(); }; diff --git a/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Pane.cpp b/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Pane.cpp index 012d3cef2..502c413f6 100644 --- a/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Pane.cpp +++ b/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Pane.cpp @@ -17,6 +17,7 @@ void Fl_Osc_Window::init(Fl_Osc_Interface *osc_, std::string loc_) title_ext = new Osc_DataModel(osc_); title_ext->doUpdate("/ui/title"); title_ext->callback = [this](string next) { + rewrite_rule = next; //printf("old: %s\n", title_orig.c_str()); const char *orig = title_orig.c_str(); // 12345678901 @@ -77,6 +78,12 @@ void Fl_Osc_Window::update(void) } } +void Fl_Osc_Window::update_title(void) +{ + title_orig = label(); + title_ext->callback(rewrite_rule); +} + static void nested_rebase(Fl_Group *g, std::string new_base) { unsigned nchildren = g->children(); @@ -106,6 +113,7 @@ void Fl_Osc_Window::rebase(std::string new_base) else if(dynamic_cast(widget)) nested_rebase(dynamic_cast(widget), new_base); } + base = new_base; } static Fl_Osc_Pane *find_osc_pane(Fl_Widget *root) diff --git a/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Slider.H b/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Slider.H index d5e7f972c..7bc66cb2a 100644 --- a/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Slider.H +++ b/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Slider.H @@ -30,4 +30,9 @@ class Fl_Osc_Slider:public Fl_Slider, public Fl_Osc_Widget protected: char osc_type; std::pair cb_data; + + private: + float old_value; + int start_pos; + float denominator; }; diff --git a/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Slider.cpp b/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Slider.cpp index ba9bf21f6..d3c3e9b06 100644 --- a/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Slider.cpp +++ b/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Slider.cpp @@ -35,7 +35,7 @@ Fl_Osc_Slider::~Fl_Osc_Slider(void) void Fl_Osc_Slider::OSC_value(int v) { const float min_ = min__(minimum(), maximum());//flipped sliders - Fl_Slider::value(v+min_+fmodf(value(),1.0)); + Fl_Slider::value(v+min_+value()-floorf(value())); } void Fl_Osc_Slider::OSC_value(float v) @@ -47,7 +47,7 @@ void Fl_Osc_Slider::OSC_value(float v) void Fl_Osc_Slider::OSC_value(char v) { const float min_ = min__(minimum(), maximum());//flipped sliders - Fl_Slider::value(v+min_+fmodf(value(),1.0)); + Fl_Slider::value(v+min_+value()-floorf(value())); } void Fl_Osc_Slider::cb(void) @@ -88,9 +88,27 @@ int Fl_Osc_Slider::handle(int ev, int X, int Y, int W, int H) return 1; } - int handled, rounded; - bool reset_requested = false; + int handled; + float rounded; + + if (ev != FL_MOUSEWHEEL) + handled = Fl_Slider::handle(ev, X, Y, W, H); + switch (ev) { + case FL_PUSH: + denominator = 2.0; + old_value = value(); + start_pos = horizontal() ? Fl::event_x() : Fl::event_y(); + { + float range = maximum() - minimum(); + float absrng = range > 0 ? range : -range; + + if (absrng / W / step() > 32 && Fl::event_button1()) + denominator = 0.25; + if (range < 0) + denominator *= -1; + } + break; case FL_MOUSEWHEEL: if (this == Fl::belowmouse() && Fl::e_dy != 0) { int step = 1, divisor = 16; @@ -108,42 +126,32 @@ int Fl_Osc_Slider::handle(int ev, int X, int Y, int W, int H) } int dy = minimum() <= maximum() ? -Fl::e_dy : Fl::e_dy; // Flip sense for vertical sliders. - dy = (this->type() & 1) ? dy : -dy; + dy = this->horizontal() ? dy : -dy; handle_drag(clamp(value() + step * dy)); } return 1; case FL_RELEASE: - rounded = value() + 0.5; - value(clamp((double)rounded)); if (Fl::event_clicks() == 1) { Fl::event_clicks(0); - reset_requested = true; + value(reset_value); + } else { + rounded = floorf(value() + 0.5); + value(clamp(rounded)); } - } - - if (!Fl::event_shift()) { - handled = Fl_Slider::handle(ev, X, Y, W, H); - if (reset_requested) { - value(reset_value); value_damage(); - if (this->when() != 0) + do_callback(); + break; + case FL_DRAG: + if (Fl::event_shift()) { + int delta = (horizontal() ? Fl::event_x() : Fl::event_y()) - + start_pos; + rounded = floor(clamp(old_value + delta/denominator) + 0.5); + value(rounded); + value_damage(); do_callback(); - } - return handled; - } - - // Slow down the drag. - // Handy if the slider has a large delta bigger than a mouse quantum. - // Somewhat tricky to use with OSC feedback. - // To change direction of movement, one must reclick the handle. - int old_value = value(); - handled = Fl_Slider::handle(ev, X, Y, W, H); - int delta = value() - old_value; - if (ev == FL_DRAG && (delta < -1 || delta > 1)) { - value(clamp((old_value + (delta > 0 ? 1 : -1)))); - value_damage(); - do_callback(); + } } + return handled; } diff --git a/source/native-plugins/zynaddsubfx/UI/MasterUI.fl b/source/native-plugins/zynaddsubfx/UI/MasterUI.fl index 082e07114..0f654a96e 100644 --- a/source/native-plugins/zynaddsubfx/UI/MasterUI.fl +++ b/source/native-plugins/zynaddsubfx/UI/MasterUI.fl @@ -1493,7 +1493,7 @@ virkeys->take_focus();} Fl_Button {} { label Advanced callback { - osc->write("/cfg.UserInterfaceMode", "i", 1); + osc->write("/config/cfg.UserInterfaceMode", "i", 1); masterwindow->show(); selectuiwindow->hide();} xywh {10 165 100 35} color 229 labelfont 1 labelsize 16 @@ -1506,7 +1506,7 @@ selectuiwindow->hide();} label Beginner callback {simplemasterwindow->show(); selectuiwindow->hide(); -osc->write("/cfg.UserInterfaceMode", "i", 2);} +osc->write("/config/cfg.UserInterfaceMode", "i", 2);} xywh {10 80 100 65} color 238 labelfont 1 labelsize 16 } Fl_Box {} { @@ -1534,7 +1534,10 @@ osc->write("/cfg.UserInterfaceMode", "i", 2);} else snprintf(&masterwindowlabel[0],100,"%s","ZynAddSubFX"); masterwindowlabel[99]='\\0'; masterwindow->label(&masterwindowlabel[0]); -simplemasterwindow->label(&masterwindowlabel[0]);} {} +simplemasterwindow->label(&masterwindowlabel[0]); +masterwindow->update_title(); +simplemasterwindow->update_title(); +} {} } Function {MasterUI(int *exitprogram_, class Fl_Osc_Interface *osc_):nioui(osc_)} {open } { diff --git a/source/native-plugins/zynaddsubfx/UI/Osc_IntModel.h b/source/native-plugins/zynaddsubfx/UI/Osc_IntModel.h index e01678166..707573adc 100644 --- a/source/native-plugins/zynaddsubfx/UI/Osc_IntModel.h +++ b/source/native-plugins/zynaddsubfx/UI/Osc_IntModel.h @@ -40,6 +40,14 @@ class Osc_IntModel:public Fl_Osc_Widget value = rtosc_argument(msg, 0).i; if(callback) callback(value); + } else if(args == "T") { + value = 1; + if(callback) + callback(value); + } else if(args == "F") { + value = 0; + if(callback) + callback(value); } } }; diff --git a/source/native-plugins/zynaddsubfx/UI/OscilGenUI.fl b/source/native-plugins/zynaddsubfx/UI/OscilGenUI.fl index bb7291f0a..9fca9b139 100644 --- a/source/native-plugins/zynaddsubfx/UI/OscilGenUI.fl +++ b/source/native-plugins/zynaddsubfx/UI/OscilGenUI.fl @@ -247,13 +247,8 @@ class OscilEditor {open : {public PresetsUI_} } { Fl_Button applybutton { label Apply - callback {//applybutton->color(FL_GRAY); -//applybutton->redraw(); -//if (cbapplywidget!=NULL) { -// cbapplywidget->do_callback(); -// cbapplywidget->color(FL_GRAY); -// cbapplywidget->redraw(); -//};} + callback { + dummy->osc->requestValue(loc+"../prepare");} xywh {305 285 60 20} box THIN_UP_BOX labelfont 1 code0 {if(adnotep) o->hide();} code1 {dummy->base = loc;} @@ -354,7 +349,7 @@ class OscilEditor {open : {public PresetsUI_} code1 {oscilo_base->parent(o);oscilo_base->init(true);} } {} Fl_Dial bfpar { - callback {redrawoscil(); bfparval->value(o->value());} + callback {redrawoscil(); if(bfparval){bfparval->value(o->value());}} tooltip {Base Function Parameter} xywh {525 285 20 20} minimum -64 maximum 63 step 1 code0 {o->init("Pbasefuncpar");} class Fl_Osc_Dial @@ -451,6 +446,8 @@ setbfmodstatus(o->value()); Fl_Value_Output bfparval { label {Par.} xywh {495 290 25 15} labelsize 12 minimum -63 maximum 63 step 1 + code0 {o->value(bfpar->value());} + } Fl_Group basefuncmodulation {open xywh {555 281 169 25} box UP_FRAME @@ -637,13 +634,14 @@ redrawoscil();} } } Fl_Dial wshpar { - callback {redrawoscil(); wsparval->value(o->value());} + callback {redrawoscil();if(wsparval){wsparval->value(o->value());}} tooltip {Waveshaping Parameter} xywh {265 318 20 20} minimum -64 maximum 63 step 1 code0 {o->init("Pwaveshaping");} class Fl_Osc_Dial } Fl_Value_Output wsparval { xywh {233 321 25 15} labelsize 12 minimum -63 maximum 63 step 1 + code0 {o->value(wshpar->value());} } } Fl_Light_Button autoclearbutton { @@ -1009,23 +1007,23 @@ oscils->update(); oscilo_base->update(); oscils_base->update();} {} } - Function {setbfmodstatus(int menuentry)} {open public + Function {setbfmodstatus(int menuentry)} {open } { code { switch (menuentry){ case 0: bfpar->deactivate(); - bfparval->deactivate(); + bfparval->deactivate(); basefuncmodulation->deactivate(); break; case 127: bfpar->deactivate(); - bfparval->deactivate(); + bfparval->deactivate(); basefuncmodulation->activate(); break; default: bfpar->activate(); - bfparval->activate(); + bfparval->activate(); basefuncmodulation->activate(); } } {} } diff --git a/source/native-plugins/zynaddsubfx/UI/PADnoteUI.fl b/source/native-plugins/zynaddsubfx/UI/PADnoteUI.fl index 93e53a362..5069b7667 100644 --- a/source/native-plugins/zynaddsubfx/UI/PADnoteUI.fl +++ b/source/native-plugins/zynaddsubfx/UI/PADnoteUI.fl @@ -32,6 +32,9 @@ decl {\#include } {private local decl {\#include } {public local } +decl {\#include "Osc_IntModel.h"} {private local +} + decl {\#include "Fl_Osc_TSlider.H"} {public local } @@ -71,19 +74,47 @@ oscui=NULL; osc_i = osc_; resui=new ResonanceUI(osc_i, location+"resonance/"); initialized = false; +applybutton = NULL; make_window(); -initialized = true;} {selected +apply_watcher = new Osc_IntModel(osc_i); +apply_watcher->callback=[this](int needsPrepare) { + if(needsPrepare) { + applybutton->color(FL_RED); + applybutton->redraw(); + if(oscui) { + oscui->applybutton->color(FL_RED); + oscui->applybutton->redraw(); + } + if(resui) { + resui->applybutton->color(FL_RED); + resui->applybutton->redraw(); + } + } else { + applybutton->color(FL_GRAY); + applybutton->redraw(); + if(oscui) { + oscui->applybutton->color(FL_GRAY); + oscui->applybutton->redraw(); + } + if(resui) { + resui->applybutton->color(FL_GRAY); + resui->applybutton->redraw(); + } } +}; +apply_watcher->doUpdate(location+"needPrepare"); +initialized = true;} {} } Function {make_window()} {open } { Fl_Window padnotewindow { label {PAD synth Parameters} open - xywh {52 324 535 435} type Double hide + xywh {52 324 535 430} type Double hide class Fl_Osc_Window } { Fl_Box dummy { + xywh {25 25 25 25} code0 {padnotewindow->init(osc_i, location);} } Fl_Tabs {} { @@ -281,8 +312,9 @@ oscui=new OscilEditor(false, location+"oscilgen/",osc_i);} Fl_Box cbwidget { label {Harmonic Content} callback {opui->update(); -applybutton->color(FL_RED); -applybutton->redraw();} + if(applybutton) { + applybutton->color(FL_RED); + applybutton->redraw();}} xywh {125 135 205 20} align 16 } Fl_Button {} { @@ -803,23 +835,23 @@ if (resui!=NULL) { resui->applybutton->color(FL_GRAY); resui->applybutton->redraw(); };} - xywh {300 400 135 30} box THIN_UP_BOX + xywh {200 400 135 25} box THIN_UP_BOX code0 {o->color(FL_RED);} } Fl_Button {} { label Close callback {padnotewindow->hide();} - xywh {440 400 90 30} box THIN_UP_BOX + xywh {470 400 60 25} box THIN_UP_BOX } Fl_Button {} { label C callback {presetsui->copy(padnotewindow->loc());} - xywh {65 400 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55 + xywh {400 405 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55 } Fl_Button {} { label P callback {presetsui->paste(padnotewindow->loc(),this);} - xywh {95 400 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55 + xywh {430 405 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55 } Fl_Button {} { label export @@ -828,7 +860,7 @@ filename=fl_file_chooser("Export samples:","(*.wav)",NULL,0); if (filename==NULL) return; fl_filename_setext(filename,""); o->oscWrite("export2wav", "s", filename);} - tooltip {export samples as wav file} xywh {5 400 55 30} box THIN_UP_BOX color 51 labelsize 11 align 128 + tooltip {export samples as wav file} xywh {5 400 55 25} box THIN_UP_BOX color 51 labelsize 11 align 128 class Fl_Osc_Button } } @@ -875,9 +907,12 @@ applybutton->color(FL_GRAY); applybutton->parent()->redraw();} {} } Function {~PADnoteUI()} {} { - code {delete(oscui); + code { +delete apply_watcher; +delete(oscui); delete(resui); + padnotewindow->hide(); delete padnotewindow;} {} } @@ -897,4 +932,6 @@ delete padnotewindow;} {} } decl {PADnoteOvertonePosition *opui;} {private local } + decl {class Osc_IntModel *apply_watcher;} {private local + } } diff --git a/source/native-plugins/zynaddsubfx/UI/PartUI.fl b/source/native-plugins/zynaddsubfx/UI/PartUI.fl index 25867bfc1..4bd33c7bb 100644 --- a/source/native-plugins/zynaddsubfx/UI/PartUI.fl +++ b/source/native-plugins/zynaddsubfx/UI/PartUI.fl @@ -61,7 +61,7 @@ class PartSysEffSend {open : {public Fl_Group} private xywh {604 244 100 100} type Double box NO_BOX class Fl_Group visible } { - Fl_Dial {} { + Fl_Dial widget { label 01 xywh {0 0 25 25} box ROUND_UP_BOX labelfont 1 labelsize 10 align 130 maximum 127 step 1 code0 {o->size(25,25);} @@ -83,6 +83,18 @@ make_window(); syseffsend->show(); end();} {} } + Function {rebase(int part)} {} { + code { + auto *osc = widget->osc; + std::string old = "Psysefxvol"+to_s(neff)+"/part"+to_s(npart); + std::string next = "Psysefxvol"+to_s(neff)+"/part"+to_s(part); + widget->ext = next; + osc->renameLink("/"+old, "/"+next, widget); + osc->requestValue("/"+next); + npart = part; + } {} + } + Function {~PartSysEffSend()} {} { code {syseffsend->hide(); //delete(syseffsend);} {} @@ -1186,6 +1198,12 @@ partfx->rebase(new_loc); instrumentkitlist->rebase(new_loc); instrumenteditwindow->rebase(new_loc); partenablebutton->rebase(new_loc); +int next_part = 0; +const char *tmp = new_loc.c_str(); +while(*tmp && !isdigit(*tmp)) tmp++; +next_part = atoi(tmp); +for (int i=0;irebase(next_part); } {selected } } diff --git a/source/native-plugins/zynaddsubfx/UI/SUBnoteUI.fl b/source/native-plugins/zynaddsubfx/UI/SUBnoteUI.fl index 8f54cde3f..7aec51b5e 100644 --- a/source/native-plugins/zynaddsubfx/UI/SUBnoteUI.fl +++ b/source/native-plugins/zynaddsubfx/UI/SUBnoteUI.fl @@ -136,7 +136,7 @@ class SUBnoteUI {open : {public PresetsUI_} } { Fl_Window SUBparameters { label {SUBsynth Parameters} open - xywh {542 511 735 470} type Double + xywh {542 511 735 475} type Double class Fl_Osc_Window visible } { Fl_Box {} { @@ -155,7 +155,7 @@ class SUBnoteUI {open : {public PresetsUI_} Fl_Button {} { label Close callback {SUBparameters->hide();} - xywh {625 446 105 20} box THIN_UP_BOX labelfont 1 labelsize 11 + xywh {670 446 60 25} box THIN_UP_BOX } Fl_Group {} { label AMPLITUDE open @@ -326,7 +326,7 @@ freqsettingsui->redraw();} h[0]->mag->oscWrite(h[0]->mag->ext, "c", 127); h[0]->bw->oscWrite(h[0]->bw->ext, "c", 64); SUBparameters->redraw();} - tooltip {Clear the harmonics} xywh {445 446 70 20} box THIN_UP_BOX labelfont 1 labelsize 11 + tooltip {Clear the harmonics} xywh {445 446 70 25} box THIN_UP_BOX class Fl_Osc_Button } Fl_Group bandwidthsettingsui { @@ -392,12 +392,12 @@ globalfiltergroup->redraw();} Fl_Button {} { label C callback {presetsui->copy(loc);} - xywh {540 451 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55 + xywh {600 451 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55 } Fl_Button {} { label P callback {presetsui->paste(loc,this);} - xywh {570 451 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55 + xywh {630 451 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55 } Fl_Group {} { label OVERTONES open diff --git a/source/native-plugins/zynaddsubfx/UI/WidgetPDial.cpp b/source/native-plugins/zynaddsubfx/UI/WidgetPDial.cpp index d88de1286..522be7430 100644 --- a/source/native-plugins/zynaddsubfx/UI/WidgetPDial.cpp +++ b/source/native-plugins/zynaddsubfx/UI/WidgetPDial.cpp @@ -113,7 +113,7 @@ int WidgetPDial::handle(int event) break; case FL_RELEASE: if (integer_step) { - int rounded = value() + 0.5; + float rounded = floorf(value() + 0.5); value(clamp(rounded)); } tipwin->hide(); diff --git a/source/native-plugins/zynaddsubfx/UI/guimain.cpp b/source/native-plugins/zynaddsubfx/UI/guimain.cpp index 1e71a5449..0d06f0c08 100644 --- a/source/native-plugins/zynaddsubfx/UI/guimain.cpp +++ b/source/native-plugins/zynaddsubfx/UI/guimain.cpp @@ -542,11 +542,38 @@ void watch_lo(void) lo_server_recv_noblock(server, 100); } +const char *help_message = +"zynaddsubfx-ext-gui [options] uri - Connect to remote ZynAddSubFX\n" +" --help print this help message\n" +" --no-uri run without a remote ZynAddSubFX\n" +"\n" +" example: zynaddsubfx-ext-gui osc.udp://localhost:1234/\n" +" use the -P option for zynaddsubfx to specify the port of the backend\n"; + #ifndef CARLA_VERSION_STRING int main(int argc, char *argv[]) { + const char *uri = NULL; + bool help = false; + bool no_uri = false; + for(int i=1; i