zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit 02085e2c7e87321279e461d3b647ad204c5f054c
parent e399d0587c7194f4d720db68684df6d7a2d93201
Author: fundamental <mark.d.mccurry@gmail.com>
Date:   Thu,  5 Mar 2015 21:38:35 -0500

UI: SUBnoteParameters Copy/Paste

Diffstat:
Msrc/Misc/PresetExtractor.cpp | 1+
Msrc/Params/SUBnoteParameters.cpp | 69+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
Msrc/Params/SUBnoteParameters.h | 1+
Msrc/UI/Fl_Osc_Pane.H | 1+
Msrc/UI/Fl_Osc_Pane.cpp | 27+++++++++++++++++++++++++++
Msrc/UI/Fl_Osc_Widget.cpp | 3++-
Msrc/UI/PresetsUI.fl | 2+-
Msrc/UI/SUBnoteUI.fl | 26++++++++++----------------
8 files changed, 104 insertions(+), 26 deletions(-)

diff --git a/src/Misc/PresetExtractor.cpp b/src/Misc/PresetExtractor.cpp @@ -169,6 +169,7 @@ std::string doClassCopy(std::string type, MiddleWare &mw, string url) std::string getUrlType(std::string url) { + assert(!url.empty()); printf("Searching for '%s'\n", (url+"self").c_str()); auto self = Master::ports.apropos((url+"self").c_str()); if(!self) diff --git a/src/Params/SUBnoteParameters.cpp b/src/Params/SUBnoteParameters.cpp @@ -34,6 +34,8 @@ #define rObject SUBnoteParameters using namespace rtosc; static rtosc::Ports localPorts = { + rSelf(SUBnoteParameters), + rPaste(), rToggle(Pstereo, "Stereo Enable"), rParamZyn(PVolume, "Volume"), rParamZyn(PPanning, "Left Right Panning"), @@ -334,6 +336,57 @@ void SUBnoteParameters::updateFrequencyMultipliers(void) { } } +#define doPaste(x) this->x = sub.x; +#define doPPaste(x) this->x->paste(*sub.x); +void SUBnoteParameters::paste(SUBnoteParameters &sub) +{ + doPaste(Pstereo); + doPaste(PVolume); + doPaste(PPanning); + doPaste(PAmpVelocityScaleFunction); + doPPaste(AmpEnvelope); + + //Frequency Parameters + doPaste(PDetune); + doPaste(PCoarseDetune); + doPaste(PDetuneType); + doPaste(PFreqEnvelopeEnabled); + doPPaste(FreqEnvelope); + doPaste(PBandWidthEnvelopeEnabled); + doPPaste(BandWidthEnvelope); + + //Filter Parameters (Global) + doPaste(PGlobalFilterEnabled); + doPPaste(GlobalFilter); + doPaste(PGlobalFilterVelocityScale); + doPaste(PGlobalFilterVelocityScaleFunction); + doPPaste(GlobalFilterEnvelope); + + + //Other Parameters + doPaste(Pfixedfreq); + doPaste(PfixedfreqET); + doPaste(POvertoneSpread.type); + doPaste(POvertoneSpread.par1); + doPaste(POvertoneSpread.par2); + doPaste(POvertoneSpread.par3); + + for(int i=0; i<MAX_SUB_HARMONICS; ++i) + doPaste(POvertoneFreqMult[i]); + + doPaste(Pnumstages); + doPaste(Pbandwidth); + doPaste(Phmagtype); + + for(int i=0; i<MAX_SUB_HARMONICS; ++i) { + doPaste(Phmag[i]); + doPaste(Phrelbw[i]); + } + + doPaste(Pbwscale); + doPaste(Pstart); +} + void SUBnoteParameters::getfromXML(XMLwrapper *xml) { Pnumstages = xml->getpar127("num_stages", Pnumstages); @@ -357,7 +410,7 @@ void SUBnoteParameters::getfromXML(XMLwrapper *xml) PVolume = xml->getpar127("volume", PVolume); PPanning = xml->getpar127("panning", PPanning); PAmpVelocityScaleFunction = xml->getpar127("velocity_sensing", - PAmpVelocityScaleFunction); + PAmpVelocityScaleFunction); if(xml->enterbranch("AMPLITUDE_ENVELOPE")) { AmpEnvelope->getfromXML(xml); xml->exitbranch(); @@ -386,15 +439,15 @@ void SUBnoteParameters::getfromXML(XMLwrapper *xml) Pbwscale = xml->getpar127("bandwidth_scale", Pbwscale); PFreqEnvelopeEnabled = xml->getparbool("freq_envelope_enabled", - PFreqEnvelopeEnabled); + PFreqEnvelopeEnabled); if(xml->enterbranch("FREQUENCY_ENVELOPE")) { FreqEnvelope->getfromXML(xml); xml->exitbranch(); } PBandWidthEnvelopeEnabled = xml->getparbool( - "band_width_envelope_enabled", - PBandWidthEnvelopeEnabled); + "band_width_envelope_enabled", + PBandWidthEnvelopeEnabled); if(xml->enterbranch("BANDWIDTH_ENVELOPE")) { BandWidthEnvelope->getfromXML(xml); xml->exitbranch(); @@ -411,11 +464,11 @@ void SUBnoteParameters::getfromXML(XMLwrapper *xml) } PGlobalFilterVelocityScaleFunction = xml->getpar127( - "filter_velocity_sensing", - PGlobalFilterVelocityScaleFunction); + "filter_velocity_sensing", + PGlobalFilterVelocityScaleFunction); PGlobalFilterVelocityScale = xml->getpar127( - "filter_velocity_sensing_amplitude", - PGlobalFilterVelocityScale); + "filter_velocity_sensing_amplitude", + PGlobalFilterVelocityScale); if(xml->enterbranch("FILTER_ENVELOPE")) { GlobalFilterEnvelope->getfromXML(xml); diff --git a/src/Params/SUBnoteParameters.h b/src/Params/SUBnoteParameters.h @@ -36,6 +36,7 @@ class SUBnoteParameters:public Presets void defaults(); void getfromXML(XMLwrapper *xml); void updateFrequencyMultipliers(void); + void paste(SUBnoteParameters &sub); //Parameters //AMPLITUDE PARAMETRERS diff --git a/src/UI/Fl_Osc_Pane.H b/src/UI/Fl_Osc_Pane.H @@ -22,6 +22,7 @@ class Fl_Osc_Window:public Fl_Double_Window, public Fl_Osc_Pane void init(Fl_Osc_Interface *osc_, std::string loc_); virtual std::string loc(void) const; virtual void rebase(std::string new_base); + void update(); }; diff --git a/src/UI/Fl_Osc_Pane.cpp b/src/UI/Fl_Osc_Pane.cpp @@ -23,6 +23,33 @@ std::string Fl_Osc_Window::loc(void) const return base; } +static void nested_update(Fl_Group *g) +{ + unsigned nchildren = g->children(); + for(unsigned i=0; i < nchildren; ++i) { + Fl_Widget *widget = g->child(i); + if(Fl_Osc_Widget *o = dynamic_cast<Fl_Osc_Widget*>(widget)) { + o->update(); + } else if(Fl_Group *o = dynamic_cast<Fl_Group*>(widget)) { + nested_update(o); + } + + } +} + +void Fl_Osc_Window::update(void) +{ + unsigned nchildren = this->children(); + for(unsigned i=0; i < nchildren; ++i) { + Fl_Widget *widget = this->child(i); + if(Fl_Osc_Widget *o = dynamic_cast<Fl_Osc_Widget*>(widget)) { + o->update(); + } + if(dynamic_cast<Fl_Group*>(widget)) + nested_update(dynamic_cast<Fl_Group*>(widget)); + } +} + static void nested_rebase(Fl_Group *g, std::string new_base) { unsigned nchildren = g->children(); diff --git a/src/UI/Fl_Osc_Widget.cpp b/src/UI/Fl_Osc_Widget.cpp @@ -79,7 +79,8 @@ void Fl_Osc_Widget::oscRegister(const char *path) void Fl_Osc_Widget::update(void) { - osc->requestValue(loc+ext); + if(*((loc+ext).rbegin()) != '/') + osc->requestValue(loc+ext); } Fl_Osc_Pane *Fl_Osc_Widget::fetch_osc_pane(Fl_Widget *w) diff --git a/src/UI/PresetsUI.fl b/src/UI/PresetsUI.fl @@ -166,7 +166,7 @@ class PresetsUI {} { presetname->cut(0,presetname->maximum_size()); if(but) { - presetCopy(url, ""); + presetCopy(url_, ""); } else { rescan(); copytypetext->label(presetClipboardType().c_str()); diff --git a/src/UI/SUBnoteUI.fl b/src/UI/SUBnoteUI.fl @@ -418,12 +418,12 @@ globalfiltergroup->redraw();} } Fl_Button {} { label C - callback {presetsui->copy(SUBparameters->loc());} + callback {presetsui->copy(loc);} xywh {540 451 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55 } Fl_Button {} { label P - callback {presetsui->paste(SUBparameters->loc(),this);} + callback {presetsui->paste(loc,this);} xywh {570 451 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55 } Fl_Group {} { @@ -491,20 +491,14 @@ globalfiltergroup->redraw();} } } Function {refresh()} {} { - code {//bwee->show(); -//bandwidthsettingsui->redraw(); - -//freqee->show(); -//freqsettingsui->redraw(); - -//filtere->show(); -globalfiltergroup->redraw(); - -ampenv->refresh(); -bandwidthenvelopegroup->refresh(); -freqenvelopegroup->refresh(); -filterui->refresh(); -filterenv->refresh();} {} + code { +SUBparameters->update(); +//globalfiltergroup->redraw(); +//ampenv->refresh(); +//bandwidthenvelopegroup->refresh(); +//freqenvelopegroup->refresh(); +//filterui->refresh(); +//filterenv->refresh();} {} } Function {SUBnoteUI(Fl_Osc_Interface *osc_, std::string loc_)} {} { code {osc = osc_;