From e4fffbc34fcdf8f788c6a6e6443bf863650785bd Mon Sep 17 00:00:00 2001 From: falkTX Date: Sun, 28 Jun 2015 00:25:42 +0200 Subject: [PATCH] Update zynaddsubfx --- .../zynaddsubfx/Misc/Master.cpp | 2 +- .../zynaddsubfx/Misc/MiddleWare.cpp | 16 +-- .../zynaddsubfx/Misc/MiddleWare.h | 2 +- .../zynaddsubfx/Misc/XMLwrapper.cpp | 2 +- .../zynaddsubfx/Params/EnvelopeParams.cpp | 4 + .../native-plugins/zynaddsubfx/UI/ADnoteUI.fl | 14 +-- .../zynaddsubfx/UI/BankView.cpp | 2 +- .../native-plugins/zynaddsubfx/UI/ConfigUI.fl | 28 ++++- .../zynaddsubfx/UI/EnvelopeFreeEdit.cpp | 9 +- .../zynaddsubfx/UI/EnvelopeUI.fl | 112 +++++++++--------- .../zynaddsubfx/UI/Fl_Osc_Numeric_Input.H | 17 +++ .../zynaddsubfx/UI/Fl_Osc_Numeric_Input.cpp | 36 ++++++ .../zynaddsubfx/UI/Fl_Osc_Output.H | 3 +- .../zynaddsubfx/UI/Fl_Osc_Output.cpp | 6 +- .../zynaddsubfx/UI/Fl_Oscilloscope.h | 3 + .../native-plugins/zynaddsubfx/UI/NioUI.cpp | 4 +- .../zynaddsubfx/UI/Osc_IntModel.h | 45 +++++++ .../zynaddsubfx/UI/OscilGenUI.fl | 8 +- source/native-plugins/zynaddsubfx/main.cpp | 18 +++ 19 files changed, 240 insertions(+), 91 deletions(-) create mode 100644 source/native-plugins/zynaddsubfx/UI/Fl_Osc_Numeric_Input.H create mode 100644 source/native-plugins/zynaddsubfx/UI/Fl_Osc_Numeric_Input.cpp create mode 100644 source/native-plugins/zynaddsubfx/UI/Osc_IntModel.h diff --git a/source/native-plugins/zynaddsubfx/Misc/Master.cpp b/source/native-plugins/zynaddsubfx/Misc/Master.cpp index 15b1d7438..b192ebf28 100644 --- a/source/native-plugins/zynaddsubfx/Misc/Master.cpp +++ b/source/native-plugins/zynaddsubfx/Misc/Master.cpp @@ -667,7 +667,7 @@ void Master::AudioOut(float *outl, float *outr) } if(events>1 && false) fprintf(stderr, "backend: %d events per cycle\n",events); - + //Swaps the Left channel with Right Channel if(swaplr) diff --git a/source/native-plugins/zynaddsubfx/Misc/MiddleWare.cpp b/source/native-plugins/zynaddsubfx/Misc/MiddleWare.cpp index c0a6b0631..58c64d3ff 100644 --- a/source/native-plugins/zynaddsubfx/Misc/MiddleWare.cpp +++ b/source/native-plugins/zynaddsubfx/Misc/MiddleWare.cpp @@ -347,14 +347,14 @@ struct NonRtObjStore { std::string base = "/part"+to_s(i)+"/kit"+to_s(j)+"/"; for(int k=0; kVoicePar[k]; - objmap[nbase+"oscil/"] = nobj.OscilSmp; - objmap[nbase+"mod-oscil/"] = nobj.FMSmp; + objmap[nbase+"OscilSmp/"] = nobj.OscilSmp; + objmap[nbase+"FMSmp/"] = nobj.FMSmp; } else { - objmap[nbase+"oscil/"] = nullptr; - objmap[nbase+"mod-oscil/"] = nullptr; + objmap[nbase+"OscilSmp/"] = nullptr; + objmap[nbase+"FMSmp/"] = nullptr; } } } @@ -365,10 +365,10 @@ struct NonRtObjStore for(int k=0; koscilgen; + objmap[base+"padpars/oscilgen/"] = padpars->oscilgen; } else { objmap[base+"padpars/"] = nullptr; - objmap[base+"padpars/oscil/"] = nullptr; + objmap[base+"padpars/oscilgen/"] = nullptr; } } } @@ -1214,8 +1214,8 @@ void MiddleWareImpl::kitEnable(int part, int kit, int type) */ void MiddleWareImpl::handleMsg(const char *msg) { - assert(!strstr(msg,"free")); assert(msg && *msg && rindex(msg, '/')[1]); + assert(strstr(msg,"free") == NULL || strstr(rtosc_argument_string(msg), "b") == NULL); assert(strcmp(msg, "/part0/Psysefxvol")); assert(strcmp(msg, "/Penabled")); assert(strcmp(msg, "part0/part0/Ppanning")); diff --git a/source/native-plugins/zynaddsubfx/Misc/MiddleWare.h b/source/native-plugins/zynaddsubfx/Misc/MiddleWare.h index dae91d2d9..50a87c6c0 100644 --- a/source/native-plugins/zynaddsubfx/Misc/MiddleWare.h +++ b/source/native-plugins/zynaddsubfx/Misc/MiddleWare.h @@ -4,7 +4,7 @@ #include struct SYNTH_T; -class Master; +class Master; //Link between realtime and non-realtime layers class MiddleWare { diff --git a/source/native-plugins/zynaddsubfx/Misc/XMLwrapper.cpp b/source/native-plugins/zynaddsubfx/Misc/XMLwrapper.cpp index e47e7e36b..11395f68c 100644 --- a/source/native-plugins/zynaddsubfx/Misc/XMLwrapper.cpp +++ b/source/native-plugins/zynaddsubfx/Misc/XMLwrapper.cpp @@ -98,7 +98,7 @@ XMLwrapper::XMLwrapper() { version.Major = 2; version.Minor = 5; - version.Revision = 0; + version.Revision = 1; minimal = true; diff --git a/source/native-plugins/zynaddsubfx/Params/EnvelopeParams.cpp b/source/native-plugins/zynaddsubfx/Params/EnvelopeParams.cpp index c27ac3991..a88a57f0d 100644 --- a/source/native-plugins/zynaddsubfx/Params/EnvelopeParams.cpp +++ b/source/native-plugins/zynaddsubfx/Params/EnvelopeParams.cpp @@ -34,7 +34,11 @@ using namespace rtosc; static const rtosc::Ports localPorts = { rSelf(EnvelopeParams), rPaste, +#undef rChangeCb +#define rChangeCb if(!obj->Pfreemode) obj->converttofree(); rToggle(Pfreemode, "Complex Envelope Definitions"), +#undef rChangeCb +#define rChangeCb rParamZyn(Penvpoints, rProp(internal), "Number of points in complex definition"), rParamZyn(Penvsustain, rProp(internal), "Location of the sustain point"), rParams(Penvdt, MAX_ENVELOPE_POINTS, "Envelope Delay Times"), diff --git a/source/native-plugins/zynaddsubfx/UI/ADnoteUI.fl b/source/native-plugins/zynaddsubfx/UI/ADnoteUI.fl index 2a5343e56..79e56cdd0 100644 --- a/source/native-plugins/zynaddsubfx/UI/ADnoteUI.fl +++ b/source/native-plugins/zynaddsubfx/UI/ADnoteUI.fl @@ -119,7 +119,7 @@ class ADvoicelistitem {open : {public Fl_Osc_Group} class Fl_Osc_Output } Fl_Slider voicedetune { - callback {//detunevalueoutput->do_callback();} + callback {detunevalueoutput->update();} tooltip {Fine Detune (cents)} xywh {315 5 185 20} type {Horz Knob} box NO_BOX minimum -8192 maximum 8191 step 1 code0 {o->init("PDetune",'i');} class Fl_Osc_Slider @@ -253,7 +253,7 @@ o->redraw();} class Fl_Osc_Counter } Fl_Slider {} { - callback {o->oscWrite("detunevalue");} + callback {fmdetunevalueoutput->update();} tooltip {Fine Detune (cents)} xywh {590 245 155 15} type {Horz Knob} box NO_BOX minimum -8192 maximum 8191 step 1 code0 {o->init("PFMDetune", 'i');} class Fl_Osc_Slider @@ -266,7 +266,7 @@ o->redraw();} } Fl_Choice {} { label {Detune Type} - callback {fmdetunevalueoutput->do_callback();} open + callback {fmdetunevalueoutput->update();} open xywh {540 280 75 15} down_box BORDER_BOX labelsize 10 align 5 textfont 1 textsize 10 code0 {o->add("Default");o->add("L35cents");o->add("L10cents");o->add("E100cents");o->add("E1200cents");} code1 {o->init("PFMDetuneType");} @@ -466,7 +466,7 @@ o->redraw();} class Fl_Osc_Counter } Fl_Slider {} { - callback {detunevalueoutput->do_callback();} + callback {detunevalueoutput->update();} tooltip {Fine Detune (cents)} xywh {58 287 392 13} type {Horz Knob} box NO_BOX minimum -8192 maximum 8191 step 1 code0 {o->init("PDetune", 'i');} class Fl_Osc_Slider @@ -493,7 +493,7 @@ o->redraw();} } Fl_Choice {} { label {Detune Type} - callback {detunevalueoutput->do_callback();} open + callback {detunevalueoutput->update();} open xywh {455 320 70 15} down_box BORDER_BOX labelsize 10 align 5 textfont 1 textsize 10 code0 {o->add("Default");o->add("L35cents");o->add("L10cents");o->add("E100cents");o->add("E1200cents");} code1 {o->init("PDetuneType");} @@ -866,7 +866,7 @@ class ADnoteUI {open : {public PresetsUI_} class LFOUI } {} Fl_Slider detune { - callback {o->oscWrite("detunevalue");} + callback {detunevalueoutput->update();} tooltip {Fine Detune (cents)} xywh {60 300 385 15} type {Horz Knob} box NO_BOX minimum -8192 maximum 8191 step 1 code0 {o->init("PDetune", 'i');} class Fl_Osc_Slider @@ -879,7 +879,7 @@ class ADnoteUI {open : {public PresetsUI_} } Fl_Choice detunetype { label {Detune Type} - callback {o->oscWrite("detunevalue");} open + callback {detunevalueoutput->update();} open xywh {455 340 75 15} down_box BORDER_BOX labelsize 10 align 5 textfont 1 textsize 10 code0 {o->add("L35cents");o->add("L10cents");o->add("E100cents");o->add("E1200cents");} code1 {o->init("PDetuneType",1);} diff --git a/source/native-plugins/zynaddsubfx/UI/BankView.cpp b/source/native-plugins/zynaddsubfx/UI/BankView.cpp index 0a9128efc..5946ef7ae 100644 --- a/source/native-plugins/zynaddsubfx/UI/BankView.cpp +++ b/source/native-plugins/zynaddsubfx/UI/BankView.cpp @@ -15,8 +15,8 @@ BankList::BankList(int x,int y, int w, int h, const char *label) void BankList::init(std::string path) { ext = path; + oscRegister("bank-list"); oscRegister(path.c_str()); - osc->createLink("/bank-list", this); } void BankList::OSC_raw(const char *msg) diff --git a/source/native-plugins/zynaddsubfx/UI/ConfigUI.fl b/source/native-plugins/zynaddsubfx/UI/ConfigUI.fl index add4604d8..83272e6d4 100644 --- a/source/native-plugins/zynaddsubfx/UI/ConfigUI.fl +++ b/source/native-plugins/zynaddsubfx/UI/ConfigUI.fl @@ -29,12 +29,18 @@ decl {\#include "Fl_Osc_Counter.H"} {public local decl {\#include "Fl_Osc_Choice.H"} {public local } +decl {\#include "Osc_IntModel.h"} {public local +} + decl {\#include "Fl_Osc_Check.H"} {public local } decl {\#include "Fl_Osc_Input.H"} {public local } +decl {\#include "Fl_Osc_Numeric_Input.H"} {public local +} + decl {\#include "Fl_Osc_ListView.H"} {public local } @@ -71,14 +77,14 @@ class ConfigUI {} { Fl_Input samplerateinput { xywh {115 50 60 20} type Int textfont 1 code0 {o->init("cfg.SampleRate");} - class Fl_Osc_Input + class Fl_Osc_Numeric_Input } } Fl_Input {} { label {Buffer Size} tooltip {Internal Sound Buffer Size (samples)} xywh {190 45 60 20} type Int labelsize 11 align 129 textfont 1 code0 {o->init("cfg.SoundBufferSize");} - class Fl_Osc_Input + class Fl_Osc_Numeric_Input } Fl_Check_Button {} { label {Swap Stereo } @@ -86,11 +92,12 @@ class ConfigUI {} { code0 {o->init("cfg.SwapStereo");} class Fl_Osc_Check } - Fl_Choice {} { + Fl_Choice oscilsize_widget { label OscilSize + callback{ + oscilsize->updateVal((int)(o->value()+7)); + } tooltip {ADSynth Oscillator Size (samples)} xywh {175 80 75 20} down_box BORDER_BOX labelfont 1 labelsize 11 textsize 10 - code0 {o->init("cfg.OscilPower");} - class Fl_Osc_Choice } { MenuItem {} { label 128 @@ -279,7 +286,14 @@ activatebutton_presetdir(true);} Function {ConfigUI(Fl_Osc_Interface *osc_)} {} { code { osc = osc_; - make_window();} {} + make_window(); + oscilsize = new Osc_IntModel(osc); + oscilsize->callback = [this](int i){ + oscilsize_widget->value(i-7); + }; + oscilsize->update("/config/cfg.OscilPower"); + + } {} } Function {activatebutton_rootdir(bool active)} {} { code {if (active) { @@ -308,4 +322,6 @@ activatebutton_presetdir(true);} } decl {class Fl_Osc_Interface *osc;} {public local } + decl {class Osc_IntModel *oscilsize;} {public local + } } diff --git a/source/native-plugins/zynaddsubfx/UI/EnvelopeFreeEdit.cpp b/source/native-plugins/zynaddsubfx/UI/EnvelopeFreeEdit.cpp index a7e4e5731..b4ea5a980 100644 --- a/source/native-plugins/zynaddsubfx/UI/EnvelopeFreeEdit.cpp +++ b/source/native-plugins/zynaddsubfx/UI/EnvelopeFreeEdit.cpp @@ -26,7 +26,7 @@ void EnvelopeFreeEdit::init(void) void EnvelopeFreeEdit::OSC_raw(const char *msg) { const char *args = rtosc_argument_string(msg); - if(strstr(msg,"Penvpoints") && !strcmp(args, "c")) { + if(strstr(msg,"Penvpoints") && !strcmp(args, "i")) { Penvpoints = rtosc_argument(msg, 0).i; } else if(strstr(msg,"Penvdt") && !strcmp(args, "b")) { rtosc_blob_t b = rtosc_argument(msg, 0).b; @@ -36,7 +36,7 @@ void EnvelopeFreeEdit::OSC_raw(const char *msg) rtosc_blob_t b = rtosc_argument(msg, 0).b; assert(b.len == MAX_ENVELOPE_POINTS); memcpy(Penvval, b.data, MAX_ENVELOPE_POINTS); - } else if(strstr(msg,"Penvsustain") && !strcmp(args, "c")) { + } else if(strstr(msg,"Penvsustain") && !strcmp(args, "i")) { Penvsustain = rtosc_argument(msg, 0).i; } redraw(); @@ -202,7 +202,10 @@ int EnvelopeFreeEdit::handle(int event) else Penvdt[currentpoint]=0; - oscWrite(to_s("Penvdt")+to_s(currentpoint), "c", newdt); + oscWrite(to_s("Penvval")+to_s(currentpoint), "c", ny); + oscWrite(to_s("Penvdt")+to_s(currentpoint), "c", newdt); + oscWrite("Penvdt",""); + oscWrite("Penvval",""); redraw(); if(pair) diff --git a/source/native-plugins/zynaddsubfx/UI/EnvelopeUI.fl b/source/native-plugins/zynaddsubfx/UI/EnvelopeUI.fl index ff4fdd4cb..713a34bf9 100644 --- a/source/native-plugins/zynaddsubfx/UI/EnvelopeUI.fl +++ b/source/native-plugins/zynaddsubfx/UI/EnvelopeUI.fl @@ -126,11 +126,15 @@ sustaincounter->update(); } Fl_Check_Button freemodebutton { label FreeMode - callback {reinit(); + callback { + o->oscWrite("Pfreemode", o->value() ? "T" : "F"); + reinit(o->value()); freeedit->lastpoint=-1; freeedit->redraw();} tooltip {Enable or disable the freemode} xywh {10 155 95 20} labelsize 11 + code0{o->init("Pfreemode");} + class Fl_Osc_Check } Fl_Check_Button forcedreleasecheck { label frcR @@ -503,7 +507,6 @@ envfree->redraw();} base = base_; ext = ext_; Envmode = env_type; - Pfreemode = false; Penvsustain = false; Penvpoints = 3; Penvstretch = 0; @@ -537,59 +540,60 @@ refresh();} {} code {Fl_Osc_Group::rebase(new_base); freemodeeditwindow->rebase(new_base+ext);} {} } - Function {reinit()} {open + Function {reinit(bool Pfreemode)} {open } { - code {if(Pfreemode){ - int answer=fl_choice("Disable the free mode of the Envelope?","No","Yes",NULL); - freemodebutton->value(Pfreemode); - if (answer==0) - return; -}; - -Pfreemode = !Pfreemode; - -hide(); -const int winx=freemodeeditwindow->x(); -const int winy=freemodeeditwindow->y(); - -freemodeeditwindow->hide(); - -envwindow->hide(); -Fl_Group *par=envwindow->parent(); -par->hide(); - - -refresh(); -envwindow->show(); -par->redraw(); - -par->show(); -show(); -freemodeeditwindow->position(winx,winy); -freemodeeditwindow->show(); - -if (Pfreemode) { - freemodebutton->value(1); - addpoint->show(); - deletepoint->show(); - forcedreleasecheck->show(); - sustaincounter->show(); - envstretchdial->show(); -} else{ - freemodebutton->value(0); - addpoint->hide(); - deletepoint->hide(); - forcedreleasecheck->hide(); - sustaincounter->hide(); - envstretchdial->hide(); -}; + code { + //if(!Pfreemode){ + // int answer=fl_choice("Disable the free mode of the Envelope?","No","Yes",NULL); + // freemodebutton->value(Pfreemode); + // if (answer==0) + // return; + //}; + freeedit->update(); + + hide(); + const int winx=freemodeeditwindow->x(); + const int winy=freemodeeditwindow->y(); + + bool reshow = freemodeeditwindow->visible(); + freemodeeditwindow->hide(); + + envwindow->hide(); + Fl_Group *par=envwindow->parent(); + par->hide(); + + + refresh(); + envwindow->show(); + par->redraw(); + + par->show(); + show(); + freemodeeditwindow->position(winx,winy); + if(reshow) + freemodeeditwindow->show(); + + if (Pfreemode) { + freemodebutton->value(1); + addpoint->show(); + deletepoint->show(); + forcedreleasecheck->show(); + sustaincounter->show(); + envstretchdial->show(); + } else{ + freemodebutton->value(0); + addpoint->hide(); + deletepoint->hide(); + forcedreleasecheck->hide(); + sustaincounter->hide(); + envstretchdial->hide(); + }; } {selected } } Function {refresh()} {open } { - code {freemodebutton->value(Pfreemode); - + code { sustaincounter->value(Penvsustain); sustaincounter->maximum(Penvpoints-2); @@ -598,7 +602,7 @@ if (Pfreemode) { linearenvelopecheck->value(Plinearenvelope); //Conditionally display widgets - if(Pfreemode) { + if(freemodebutton->value()) { freemodebutton->value(1); addpoint->show(); deletepoint->show(); @@ -614,14 +618,14 @@ linearenvelopecheck->value(Plinearenvelope); envstretchdial->hide(); } - if(Pfreemode || Envmode>2) + if(freemodebutton->value() || Envmode>2) linearenvelopecheck->hide(); else linearenvelopecheck->show(); forcedreleasecheck->value(Pforcedrelease); -if (Pfreemode==0){ +if (freemodebutton->value()==0){ addpoint->hide(); deletepoint->hide(); } else { @@ -635,7 +639,7 @@ envADSRfilter->hide(); envASRbw->hide(); envfree->hide(); -if (Pfreemode==0){ +if (freemodebutton->value()==0){ switch(Envmode){ case 1: case 2: @@ -664,8 +668,6 @@ envwindow->show();} {} } decl {int Envmode;} {private local } - decl {int Pfreemode;} {private local - } decl {int Penvsustain;} {private local } decl {int Penvpoints;} {private local diff --git a/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Numeric_Input.H b/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Numeric_Input.H new file mode 100644 index 000000000..fd2e7c926 --- /dev/null +++ b/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Numeric_Input.H @@ -0,0 +1,17 @@ +#pragma once +#include +#include "Fl_Osc_Widget.H" + +class Fl_Osc_Numeric_Input: public Fl_Input, public Fl_Osc_Widget +{ + public: + Fl_Osc_Numeric_Input(int X, int Y, int W, int H, const char *label = NULL); + virtual ~Fl_Osc_Numeric_Input(void); + + //Normal Initialization + void init(const char *path); + + virtual void OSC_value(int i) override; + virtual void OSC_value(float f) override; + static void numeric_callback(Fl_Widget *w); +}; diff --git a/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Numeric_Input.cpp b/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Numeric_Input.cpp new file mode 100644 index 000000000..0afc68429 --- /dev/null +++ b/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Numeric_Input.cpp @@ -0,0 +1,36 @@ +#include "Fl_Osc_Numeric_Input.H" + +Fl_Osc_Numeric_Input::Fl_Osc_Numeric_Input(int X, int Y, int W, int H, const char *label) + :Fl_Input(X,Y,W,H, label), Fl_Osc_Widget(this) +{ + callback(numeric_callback); +} + +Fl_Osc_Numeric_Input::~Fl_Osc_Numeric_Input(void) +{} + +void Fl_Osc_Numeric_Input::init(const char *path) +{ + ext = path; + oscRegister(path); +} + +void Fl_Osc_Numeric_Input::OSC_value(float f) +{ + OSC_value((int)f); +} + +void Fl_Osc_Numeric_Input::OSC_value(int i) +{ + char buf[128]; + snprintf(buf, 128, "%d", i); + value(buf); +} + +void Fl_Osc_Numeric_Input::numeric_callback(Fl_Widget *w) +{ + auto &ww = *(Fl_Osc_Numeric_Input *)w; + int x = atoi(ww.value()); + if(x) + ww.oscWrite(ww.ext, "i", x); +} diff --git a/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Output.H b/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Output.H index d2e941281..e01ef4639 100644 --- a/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Output.H +++ b/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Output.H @@ -2,7 +2,7 @@ #include #include "Fl_Osc_Widget.H" -class Fl_Osc_Output:public Fl_Value_Output, Fl_Osc_Widget +class Fl_Osc_Output:public Fl_Value_Output, public Fl_Osc_Widget { public: Fl_Osc_Output(int x, int y, int w, int h, const char *label = NULL); @@ -19,6 +19,5 @@ class Fl_Osc_Output:public Fl_Value_Output, Fl_Osc_Widget void cb(void); private: float newvalue_; - std::string name; std::pair cb_data; }; diff --git a/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Output.cpp b/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Output.cpp index 9ee7afbe3..4cd0b2fa8 100644 --- a/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Output.cpp +++ b/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Output.cpp @@ -19,7 +19,7 @@ Fl_Osc_Output::Fl_Osc_Output(int X, int Y, int W, int H, const char *label) void Fl_Osc_Output::init(const char *path) { - name = path; + ext = path; oscRegister(path); }; @@ -51,7 +51,7 @@ void Fl_Osc_Output::OSC_value(float v) void Fl_Osc_Output::update(void) { - oscWrite(name); + oscWrite(ext); } float Fl_Osc_Output::newvalue(void) const @@ -61,5 +61,5 @@ float Fl_Osc_Output::newvalue(void) const void Fl_Osc_Output::cb(void) { - oscWrite(name); + oscWrite(ext); } diff --git a/source/native-plugins/zynaddsubfx/UI/Fl_Oscilloscope.h b/source/native-plugins/zynaddsubfx/UI/Fl_Oscilloscope.h index 54aec9e67..5b319c131 100644 --- a/source/native-plugins/zynaddsubfx/UI/Fl_Oscilloscope.h +++ b/source/native-plugins/zynaddsubfx/UI/Fl_Oscilloscope.h @@ -54,6 +54,9 @@ class Fl_Oscilloscope : public Fl_Box, public Fl_Osc_Widget virtual void OSC_value(unsigned N, void *data) override { + if(oscilsize == 0) + OSC_value((int)N/4); + assert(N==(unsigned)(oscilsize*4)); memcpy(smps, data, N); diff --git a/source/native-plugins/zynaddsubfx/UI/NioUI.cpp b/source/native-plugins/zynaddsubfx/UI/NioUI.cpp index 0421fe5fc..b08793705 100644 --- a/source/native-plugins/zynaddsubfx/UI/NioUI.cpp +++ b/source/native-plugins/zynaddsubfx/UI/NioUI.cpp @@ -56,7 +56,7 @@ class Fl_Osc_StrChoice:public Fl_Choice, public Fl_Osc_Widget cb_data.first = cb; cb_data.second = p; } - + void cb(void) { assert(osc); @@ -110,7 +110,7 @@ NioUI::NioUI(Fl_Osc_Interface *osc) for(auto io:list) audio->add(io.c_str()); }; - + midi_opt->update("/io/source-list"); audio_opt->update("/io/sink-list"); diff --git a/source/native-plugins/zynaddsubfx/UI/Osc_IntModel.h b/source/native-plugins/zynaddsubfx/UI/Osc_IntModel.h new file mode 100644 index 000000000..4fe297b6f --- /dev/null +++ b/source/native-plugins/zynaddsubfx/UI/Osc_IntModel.h @@ -0,0 +1,45 @@ +#pragma once +#include "Fl_Osc_Widget.H" +#include +#include +#include + +class Osc_IntModel:public Fl_Osc_Widget +{ + public: + Osc_IntModel(Fl_Osc_Interface *osc_) + :Fl_Osc_Widget("", osc_), value(0) + { + assert(osc); + } + + typedef int value_t; + value_t value; + std::function callback; + + void updateVal(value_t v) + { + value = v; + oscWrite(ext, "i", v); + } + + void update(std::string url) + { + if(!ext.empty()) + osc->removeLink(this); + ext = url; + + oscRegister(ext.c_str()); + } + + //Raw messages + virtual void OSC_raw(const char *msg) + { + std::string args = rtosc_argument_string(msg); + if(args == "i") { + value = rtosc_argument(msg, 0).i; + if(callback) + callback(value); + } + } +}; diff --git a/source/native-plugins/zynaddsubfx/UI/OscilGenUI.fl b/source/native-plugins/zynaddsubfx/UI/OscilGenUI.fl index ae974cf3b..49368aa0b 100644 --- a/source/native-plugins/zynaddsubfx/UI/OscilGenUI.fl +++ b/source/native-plugins/zynaddsubfx/UI/OscilGenUI.fl @@ -119,7 +119,7 @@ class Oscilharmonic {: {public Fl_Group} Fl_Slider mag { callback {int x=64; if (Fl::event_button3()) o->value(x); - else x=127-(int)o->value(); + else x=128-(int)o->value(); if (x==64) o->selection_color(0); else o->selection_color(222); @@ -496,12 +496,15 @@ redrawoscil();} if (autoclearbutton->value()){ for (int i=0;imag->value(64); + h[i]->mag->do_callback(); h[i]->phase->value(64); + h[i]->phase->do_callback(); }; harmonicshiftcounter->value(0); h[0]->mag->value(0); + h[0]->mag->do_callback(); wshbutton->value(0); wshbutton->do_callback(); fltbutton->value(0); @@ -527,9 +530,12 @@ redrawoscil();} for (int i=0;imag->value(64); + h[i]->mag->do_callback(); h[i]->phase->value(64); + h[i]->phase->do_callback(); }; h[0]->mag->value(0); +h[0]->mag->do_callback(); //for (int i=0;iPhmag[i]==64) h[i]->mag->selection_color(0); diff --git a/source/native-plugins/zynaddsubfx/main.cpp b/source/native-plugins/zynaddsubfx/main.cpp index b5434d086..7069506de 100644 --- a/source/native-plugins/zynaddsubfx/main.cpp +++ b/source/native-plugins/zynaddsubfx/main.cpp @@ -429,11 +429,29 @@ int main(int argc, char *argv[]) gui = NULL; + + //Capture Startup Responses + typedef std::vector wait_t; + wait_t msg_waitlist; + middleware->setUiCallback([](void*v,const char*msg) { + wait_t &wait = *(wait_t*)v; + size_t len = rtosc_message_length(msg, -1); + char *copy = new char[len]; + memcpy(copy, msg, len); + wait.push_back(copy); + }, &msg_waitlist); + if(!noui) gui = GUI::createUi(middleware->spawnUiApi(), &Pexitprogram); middleware->setUiCallback(GUI::raiseUi, gui); middleware->setIdleCallback([](void*){GUI::tickUi(gui);}, NULL); + //Replay Startup Responses + for(auto msg:msg_waitlist) { + GUI::raiseUi(gui, msg); + delete [] msg; + } + if(!noui) { GUI::raiseUi(gui, "/show", "i", config.cfg.UserInterfaceMode);