diff --git a/source/native-plugins/Makefile b/source/native-plugins/Makefile index 5dac84647..151ddfced 100644 --- a/source/native-plugins/Makefile +++ b/source/native-plugins/Makefile @@ -30,7 +30,7 @@ endif # EXPERIMENTAL_PLUGINS # Flags for ZynAddSubFX ifeq ($(HAVE_ZYN_DEPS),true) -ZYN_CXX_FLAGS = $(BUILD_CXX_FLAGS) -Izynaddsubfx -Izynaddsubfx/rtosc +ZYN_CXX_FLAGS = $(BUILD_CXX_FLAGS) -DHAVE_ASYNC -Izynaddsubfx -Izynaddsubfx/rtosc ZYN_CXX_FLAGS += $(shell pkg-config --cflags fftw3 mxml zlib) ZYN_LD_FLAGS = $(shell pkg-config --libs liblo) ZYN_LD_FLAGS += -ldl -lpthread diff --git a/source/native-plugins/zynaddsubfx/Containers/NotePool.cpp b/source/native-plugins/zynaddsubfx/Containers/NotePool.cpp index c13941ff1..e1535fb6c 100644 --- a/source/native-plugins/zynaddsubfx/Containers/NotePool.cpp +++ b/source/native-plugins/zynaddsubfx/Containers/NotePool.cpp @@ -5,12 +5,13 @@ #include "../Synth/SynthNote.h" #include #include +#include NotePool::NotePool(void) :needs_cleaning(0) { memset(ndesc, 0, sizeof(ndesc)); - memset(sdesc, 0, sizeof(ndesc)); + memset(sdesc, 0, sizeof(sdesc)); } NotePool::activeNotesIter NotePool::activeNotes(NoteDescriptor &n) { @@ -37,19 +38,21 @@ static int getMergeableDescriptor(uint8_t note, uint8_t sendto, bool legato, if(ndesc[desc_id].status == Part::KEY_OFF) break; - //Out of free descriptors - if(ndesc[desc_id].status != Part::KEY_OFF) - return -1; - if(desc_id != 0) { auto &nd = ndesc[desc_id-1]; if(nd.age == 0 && nd.note == note && nd.sendto == sendto && nd.status == Part::KEY_PLAYING && nd.legatoMirror == legato) return desc_id-1; } + + //Out of free descriptors + if(desc_id >= POLYPHONY || ndesc[desc_id].status != Part::KEY_OFF) { + return -1; + } + return desc_id; } - + NotePool::activeDescIter NotePool::activeDesc(void) { cleanup(); @@ -76,8 +79,11 @@ void NotePool::insertNote(uint8_t note, uint8_t sendto, SynthDescriptor desc, bo //Get first free synth descriptor int sdesc_id = 0; - while(sdesc[sdesc_id].note) + while(sdesc[sdesc_id].note && sdesc_id < POLYPHONY*EXPECTED_USAGE) sdesc_id++; + + assert(sdesc_id < POLYPHONY*EXPECTED_USAGE); + sdesc[sdesc_id] = desc; }; @@ -92,8 +98,12 @@ void NotePool::upgradeToLegato(void) void NotePool::insertLegatoNote(uint8_t note, uint8_t sendto, SynthDescriptor desc) { assert(desc.note); - desc.note = desc.note->cloneLegato(); - insertNote(note, sendto, desc, true); + try { + desc.note = desc.note->cloneLegato(); + insertNote(note, sendto, desc, true); + } catch (std::bad_alloc &ba) { + std::cerr << "failed to insert legato note: " << ba.what() << std::endl; + } }; //There should only be one pair of notes which are still playing @@ -102,7 +112,11 @@ void NotePool::applyLegato(LegatoParams &par) for(auto &desc:activeDesc()) { desc.note = par.midinote; for(auto &synth:activeNotes(desc)) - synth.note->legatonote(par); + try { + synth.note->legatonote(par); + } catch (std::bad_alloc& ba) { + std::cerr << "failed to create legato note: " << ba.what() << std::endl; + } } }; @@ -114,6 +128,15 @@ bool NotePool::full(void) const return true; } +bool NotePool::synthFull(int sdesc_count) const +{ + int actually_free=sizeof(sdesc)/sizeof(sdesc[0]); + for(const auto &desc:activeDesc()) { + actually_free -= desc.size; + } + return actually_free < sdesc_count; +} + //Note that isn't KEY_PLAYING or KEY_RELASED_AND_SUSTAINING bool NotePool::existsRunningNote(void) const { @@ -126,7 +149,8 @@ int NotePool::getRunningNotes(void) const bool running[256] = {0}; for(auto &desc:activeDesc()) { //printf("note!(%d)\n", desc.note); - if(desc.status == Part::KEY_PLAYING) + if(desc.status == Part::KEY_PLAYING || + desc.status == Part::KEY_RELEASED_AND_SUSTAINED) running[desc.note] = true; } @@ -151,7 +175,7 @@ int NotePool::enforceKeyLimit(int limit) const //if(oldestnotepos != -1) // ReleaseNotePos(oldestnotepos); //} - printf("Unimplemented enforceKeyLimit()\n"); + //printf("Unimplemented enforceKeyLimit()\n"); return -1; } diff --git a/source/native-plugins/zynaddsubfx/Containers/NotePool.h b/source/native-plugins/zynaddsubfx/Containers/NotePool.h index 9e69e8992..866479fa1 100644 --- a/source/native-plugins/zynaddsubfx/Containers/NotePool.h +++ b/source/native-plugins/zynaddsubfx/Containers/NotePool.h @@ -94,6 +94,7 @@ class NotePool void applyLegato(LegatoParams &par); bool full(void) const; + bool synthFull(int sdesc_count) const; //Note that isn't KEY_PLAYING or KEY_RELASED_AND_SUSTAINING bool existsRunningNote(void) const; diff --git a/source/native-plugins/zynaddsubfx/Effects/DynamicFilter.cpp b/source/native-plugins/zynaddsubfx/Effects/DynamicFilter.cpp index 13e8f6606..2afc87629 100644 --- a/source/native-plugins/zynaddsubfx/Effects/DynamicFilter.cpp +++ b/source/native-plugins/zynaddsubfx/Effects/DynamicFilter.cpp @@ -21,6 +21,7 @@ */ #include +#include #include "DynamicFilter.h" #include "../DSP/Filter.h" #include "../Misc/Allocator.h" @@ -133,8 +134,18 @@ void DynamicFilter::reinitfilter(void) { memory.dealloc(filterl); memory.dealloc(filterr); - filterl = Filter::generate(memory, filterpars, samplerate, buffersize); - filterr = Filter::generate(memory, filterpars, samplerate, buffersize); + + try { + filterl = Filter::generate(memory, filterpars, samplerate, buffersize); + } catch(std::bad_alloc& ba) { + std::cerr << "failed to generate left filter for dynamic filter: " << ba.what() << std::endl; + } + + try { + filterr = Filter::generate(memory, filterpars, samplerate, buffersize); + } catch(std::bad_alloc& ba) { + std::cerr << "failed to generate right filter for dynamic filter: " << ba.what() << std::endl; + } } void DynamicFilter::setpreset(unsigned char npreset) diff --git a/source/native-plugins/zynaddsubfx/Effects/EffectMgr.cpp b/source/native-plugins/zynaddsubfx/Effects/EffectMgr.cpp index 845a36765..621a94a38 100644 --- a/source/native-plugins/zynaddsubfx/Effects/EffectMgr.cpp +++ b/source/native-plugins/zynaddsubfx/Effects/EffectMgr.cpp @@ -22,6 +22,7 @@ #include #include +#include #include "EffectMgr.h" @@ -178,35 +179,40 @@ void EffectMgr::changeeffectrt(int _nefx, bool avoidSmash) memory.dealloc(efx); EffectParams pars(memory, insertion, efxoutl, efxoutr, 0, synth.samplerate, synth.buffersize); - switch(nefx) { - case 1: - efx = memory.alloc(pars); - break; - case 2: - efx = memory.alloc(pars); - break; - case 3: - efx = memory.alloc(pars); - break; - case 4: - efx = memory.alloc(pars); - break; - case 5: - efx = memory.alloc(pars); - break; - case 6: - efx = memory.alloc(pars); - break; - case 7: - efx = memory.alloc(pars); - break; - case 8: - efx = memory.alloc(pars); - break; - //put more effect here - default: - efx = NULL; - break; //no effect (thru) + try { + switch (nefx) { + case 1: + efx = memory.alloc(pars); + break; + case 2: + efx = memory.alloc(pars); + break; + case 3: + efx = memory.alloc(pars); + break; + case 4: + efx = memory.alloc(pars); + break; + case 5: + efx = memory.alloc(pars); + break; + case 6: + efx = memory.alloc(pars); + break; + case 7: + efx = memory.alloc(pars); + break; + case 8: + efx = memory.alloc(pars); + break; + //put more effect here + default: + efx = NULL; + break; //no effect (thru) + } + } catch (std::bad_alloc &ba) { + std::cerr << "failed to change effect " << _nefx << ": " << ba.what() << std::endl; + return; } if(efx) @@ -287,7 +293,11 @@ void EffectMgr::seteffectparrt(int npar, unsigned char value) settings[npar] = value; if(!efx) return; - efx->changepar(npar, value); + try { + efx->changepar(npar, value); + } catch (std::bad_alloc &ba) { + std::cerr << "failed to change effect parameter " << npar << " to " << value << ": " << ba.what() << std::endl; + } } //Change a parameter of the current effect @@ -407,55 +417,55 @@ void EffectMgr::paste(EffectMgr &e) seteffectparrt(i, e.settings[i]); } -void EffectMgr::add2XML(XMLwrapper *xml) +void EffectMgr::add2XML(XMLwrapper& xml) { - xml->addpar("type", geteffect()); + xml.addpar("type", geteffect()); if(!geteffect()) return; - xml->addpar("preset", preset); + xml.addpar("preset", preset); - xml->beginbranch("EFFECT_PARAMETERS"); + xml.beginbranch("EFFECT_PARAMETERS"); for(int n = 0; n < 128; ++n) { int par = geteffectpar(n); if(par == 0) continue; - xml->beginbranch("par_no", n); - xml->addpar("par", par); - xml->endbranch(); + xml.beginbranch("par_no", n); + xml.addpar("par", par); + xml.endbranch(); } if(filterpars) { - xml->beginbranch("FILTER"); + xml.beginbranch("FILTER"); filterpars->add2XML(xml); - xml->endbranch(); + xml.endbranch(); } - xml->endbranch(); + xml.endbranch(); } -void EffectMgr::getfromXML(XMLwrapper *xml) +void EffectMgr::getfromXML(XMLwrapper& xml) { - changeeffect(xml->getpar127("type", geteffect())); + changeeffect(xml.getpar127("type", geteffect())); if(!geteffect()) return; - preset = xml->getpar127("preset", preset); + preset = xml.getpar127("preset", preset); - if(xml->enterbranch("EFFECT_PARAMETERS")) { + if(xml.enterbranch("EFFECT_PARAMETERS")) { for(int n = 0; n < 128; ++n) { seteffectpar(n, 0); //erase effect parameter - if(xml->enterbranch("par_no", n) == 0) + if(xml.enterbranch("par_no", n) == 0) continue; int par = geteffectpar(n); - seteffectpar(n, xml->getpar127("par", par)); - xml->exitbranch(); + seteffectpar(n, xml.getpar127("par", par)); + xml.exitbranch(); } if(filterpars) - if(xml->enterbranch("FILTER")) { + if(xml.enterbranch("FILTER")) { filterpars->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); } - xml->exitbranch(); + xml.exitbranch(); } cleanup(); } diff --git a/source/native-plugins/zynaddsubfx/Effects/EffectMgr.h b/source/native-plugins/zynaddsubfx/Effects/EffectMgr.h index cc9968202..02a150fd7 100644 --- a/source/native-plugins/zynaddsubfx/Effects/EffectMgr.h +++ b/source/native-plugins/zynaddsubfx/Effects/EffectMgr.h @@ -40,9 +40,9 @@ class EffectMgr:public Presets ~EffectMgr(); void paste(EffectMgr &e); - void add2XML(XMLwrapper *xml); + void add2XML(XMLwrapper& xml); void defaults(void) REALTIME; - void getfromXML(XMLwrapper *xml); + void getfromXML(XMLwrapper& xml); void out(float *smpsl, float *smpsr) REALTIME; diff --git a/source/native-plugins/zynaddsubfx/Misc/Allocator.h b/source/native-plugins/zynaddsubfx/Misc/Allocator.h index 1f0d0d34a..140b7780f 100644 --- a/source/native-plugins/zynaddsubfx/Misc/Allocator.h +++ b/source/native-plugins/zynaddsubfx/Misc/Allocator.h @@ -1,6 +1,7 @@ #pragma once #include #include +#include //! Allocator Base class //! subclasses must specify allocation and deallocation @@ -14,21 +15,36 @@ class Allocator virtual void *alloc_mem(size_t mem_size) = 0; virtual void dealloc_mem(void *memory) = 0; + /** + * High level allocator method, which return a pointer to a class or struct + * allocated with the specialized subclass strategy + * @param ts argument(s) for the constructor of the type T + * @return a non null pointer to a new object of type T + * @throw std::bad_alloc is no memory could be allocated + */ template T *alloc(Ts&&... ts) { void *data = alloc_mem(sizeof(T)); if(!data) - return nullptr; + throw std::bad_alloc(); return new (data) T(std::forward(ts)...); } + /** + * High level allocator method, which return a pointer to an array of class or struct + * allocated with the specialized subclass strategy + * @param len the array length + * @param ts argument(s) for the constructor of the type T + * @return a non null pointer to an array of new object(s) of type T + * @throw std::bad_alloc is no memory could be allocated + */ template T *valloc(size_t len, Ts&&... ts) { T *data = (T*)alloc_mem(len*sizeof(T)); if(!data) - return nullptr; + throw std::bad_alloc(); for(unsigned i=0; i(ts)...); diff --git a/source/native-plugins/zynaddsubfx/Misc/Bank.cpp b/source/native-plugins/zynaddsubfx/Misc/Bank.cpp index e936d9d57..969f79c89 100644 --- a/source/native-plugins/zynaddsubfx/Misc/Bank.cpp +++ b/source/native-plugins/zynaddsubfx/Misc/Bank.cpp @@ -170,15 +170,10 @@ int Bank::savetoslot(unsigned int ninstrument, Part *part) snprintf(tmpfilename, maxfilename, - "%4d-%s", + "%04d-%s", ninstrument + 1, (char *)part->Pname); - //add the zeroes at the start of filename - for(int i = 0; i < 4; ++i) - if(tmpfilename[i] == ' ') - tmpfilename[i] = '0'; - string filename = dirname + '/' + legalizeFilename(tmpfilename) + ".xiz"; FILE *f = fopen(filename.c_str(), "r"); diff --git a/source/native-plugins/zynaddsubfx/Misc/Master.cpp b/source/native-plugins/zynaddsubfx/Misc/Master.cpp index bc662fc94..f64df62b7 100644 --- a/source/native-plugins/zynaddsubfx/Misc/Master.cpp +++ b/source/native-plugins/zynaddsubfx/Misc/Master.cpp @@ -954,193 +954,187 @@ void Master::initialize_rt(void) part[i]->initialize_rt(); } -void Master::add2XML(XMLwrapper *xml) +void Master::add2XML(XMLwrapper& xml) { - xml->addpar("volume", Pvolume); - xml->addpar("key_shift", Pkeyshift); - xml->addparbool("nrpn_receive", ctl.NRPN.receive); + xml.addpar("volume", Pvolume); + xml.addpar("key_shift", Pkeyshift); + xml.addparbool("nrpn_receive", ctl.NRPN.receive); - xml->beginbranch("MICROTONAL"); + xml.beginbranch("MICROTONAL"); microtonal.add2XML(xml); - xml->endbranch(); + xml.endbranch(); for(int npart = 0; npart < NUM_MIDI_PARTS; ++npart) { - xml->beginbranch("PART", npart); + xml.beginbranch("PART", npart); part[npart]->add2XML(xml); - xml->endbranch(); + xml.endbranch(); } - xml->beginbranch("SYSTEM_EFFECTS"); + xml.beginbranch("SYSTEM_EFFECTS"); for(int nefx = 0; nefx < NUM_SYS_EFX; ++nefx) { - xml->beginbranch("SYSTEM_EFFECT", nefx); - xml->beginbranch("EFFECT"); + xml.beginbranch("SYSTEM_EFFECT", nefx); + xml.beginbranch("EFFECT"); sysefx[nefx]->add2XML(xml); - xml->endbranch(); + xml.endbranch(); for(int pefx = 0; pefx < NUM_MIDI_PARTS; ++pefx) { - xml->beginbranch("VOLUME", pefx); - xml->addpar("vol", Psysefxvol[nefx][pefx]); - xml->endbranch(); + xml.beginbranch("VOLUME", pefx); + xml.addpar("vol", Psysefxvol[nefx][pefx]); + xml.endbranch(); } for(int tonefx = nefx + 1; tonefx < NUM_SYS_EFX; ++tonefx) { - xml->beginbranch("SENDTO", tonefx); - xml->addpar("send_vol", Psysefxsend[nefx][tonefx]); - xml->endbranch(); + xml.beginbranch("SENDTO", tonefx); + xml.addpar("send_vol", Psysefxsend[nefx][tonefx]); + xml.endbranch(); } - xml->endbranch(); + xml.endbranch(); } - xml->endbranch(); + xml.endbranch(); - xml->beginbranch("INSERTION_EFFECTS"); + xml.beginbranch("INSERTION_EFFECTS"); for(int nefx = 0; nefx < NUM_INS_EFX; ++nefx) { - xml->beginbranch("INSERTION_EFFECT", nefx); - xml->addpar("part", Pinsparts[nefx]); + xml.beginbranch("INSERTION_EFFECT", nefx); + xml.addpar("part", Pinsparts[nefx]); - xml->beginbranch("EFFECT"); + xml.beginbranch("EFFECT"); insefx[nefx]->add2XML(xml); - xml->endbranch(); - xml->endbranch(); + xml.endbranch(); + xml.endbranch(); } - xml->endbranch(); + xml.endbranch(); } int Master::getalldata(char **data) { - XMLwrapper *xml = new XMLwrapper(); + XMLwrapper xml; - xml->beginbranch("MASTER"); + xml.beginbranch("MASTER"); add2XML(xml); - xml->endbranch(); + xml.endbranch(); - *data = xml->getXMLdata(); - delete (xml); + *data = xml.getXMLdata(); return strlen(*data) + 1; } void Master::putalldata(const char *data) { - XMLwrapper *xml = new XMLwrapper(); - if(!xml->putXMLdata(data)) { - delete (xml); + XMLwrapper xml; + if(!xml.putXMLdata(data)) { return; } - if(xml->enterbranch("MASTER") == 0) + if(xml.enterbranch("MASTER") == 0) return; getfromXML(xml); - xml->exitbranch(); - - delete (xml); + xml.exitbranch(); } int Master::saveXML(const char *filename) { - XMLwrapper *xml = new XMLwrapper(); + XMLwrapper xml; - xml->beginbranch("MASTER"); + xml.beginbranch("MASTER"); add2XML(xml); - xml->endbranch(); + xml.endbranch(); - int result = xml->saveXMLfile(filename, gzip_compression); - delete (xml); - return result; + return xml.saveXMLfile(filename, gzip_compression); } int Master::loadXML(const char *filename) { - XMLwrapper *xml = new XMLwrapper(); - if(xml->loadXMLfile(filename) < 0) { - delete (xml); + XMLwrapper xml; + + if(xml.loadXMLfile(filename) < 0) { return -1; } - if(xml->enterbranch("MASTER") == 0) + if(xml.enterbranch("MASTER") == 0) return -10; + getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); - delete (xml); initialize_rt(); return 0; } -void Master::getfromXML(XMLwrapper *xml) +void Master::getfromXML(XMLwrapper& xml) { - setPvolume(xml->getpar127("volume", Pvolume)); - setPkeyshift(xml->getpar127("key_shift", Pkeyshift)); - ctl.NRPN.receive = xml->getparbool("nrpn_receive", ctl.NRPN.receive); + setPvolume(xml.getpar127("volume", Pvolume)); + setPkeyshift(xml.getpar127("key_shift", Pkeyshift)); + ctl.NRPN.receive = xml.getparbool("nrpn_receive", ctl.NRPN.receive); part[0]->Penabled = 0; for(int npart = 0; npart < NUM_MIDI_PARTS; ++npart) { - if(xml->enterbranch("PART", npart) == 0) + if(xml.enterbranch("PART", npart) == 0) continue; part[npart]->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); } - if(xml->enterbranch("MICROTONAL")) { + if(xml.enterbranch("MICROTONAL")) { microtonal.getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); } sysefx[0]->changeeffect(0); - if(xml->enterbranch("SYSTEM_EFFECTS")) { + if(xml.enterbranch("SYSTEM_EFFECTS")) { for(int nefx = 0; nefx < NUM_SYS_EFX; ++nefx) { - if(xml->enterbranch("SYSTEM_EFFECT", nefx) == 0) + if(xml.enterbranch("SYSTEM_EFFECT", nefx) == 0) continue; - if(xml->enterbranch("EFFECT")) { + if(xml.enterbranch("EFFECT")) { sysefx[nefx]->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); } for(int partefx = 0; partefx < NUM_MIDI_PARTS; ++partefx) { - if(xml->enterbranch("VOLUME", partefx) == 0) + if(xml.enterbranch("VOLUME", partefx) == 0) continue; setPsysefxvol(partefx, nefx, - xml->getpar127("vol", Psysefxvol[partefx][nefx])); - xml->exitbranch(); + xml.getpar127("vol", Psysefxvol[partefx][nefx])); + xml.exitbranch(); } for(int tonefx = nefx + 1; tonefx < NUM_SYS_EFX; ++tonefx) { - if(xml->enterbranch("SENDTO", tonefx) == 0) + if(xml.enterbranch("SENDTO", tonefx) == 0) continue; setPsysefxsend(nefx, tonefx, - xml->getpar127("send_vol", + xml.getpar127("send_vol", Psysefxsend[nefx][tonefx])); - xml->exitbranch(); + xml.exitbranch(); } - xml->exitbranch(); + xml.exitbranch(); } - xml->exitbranch(); + xml.exitbranch(); } - if(xml->enterbranch("INSERTION_EFFECTS")) { + if(xml.enterbranch("INSERTION_EFFECTS")) { for(int nefx = 0; nefx < NUM_INS_EFX; ++nefx) { - if(xml->enterbranch("INSERTION_EFFECT", nefx) == 0) + if(xml.enterbranch("INSERTION_EFFECT", nefx) == 0) continue; - Pinsparts[nefx] = xml->getpar("part", + Pinsparts[nefx] = xml.getpar("part", Pinsparts[nefx], -2, NUM_MIDI_PARTS); - if(xml->enterbranch("EFFECT")) { + if(xml.enterbranch("EFFECT")) { insefx[nefx]->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); } - xml->exitbranch(); + xml.exitbranch(); } - xml->exitbranch(); + xml.exitbranch(); } } diff --git a/source/native-plugins/zynaddsubfx/Misc/Master.h b/source/native-plugins/zynaddsubfx/Misc/Master.h index 5f51f823a..4d60dc28b 100644 --- a/source/native-plugins/zynaddsubfx/Misc/Master.h +++ b/source/native-plugins/zynaddsubfx/Misc/Master.h @@ -63,7 +63,7 @@ class Master int saveXML(const char *filename); /**This adds the parameters to the XML data*/ - void add2XML(XMLwrapper *xml); + void add2XML(XMLwrapper& xml); void defaults(); @@ -78,7 +78,7 @@ class Master //This must be called prior-to/at-the-time-of RT insertion void initialize_rt(void) REALTIME; - void getfromXML(XMLwrapper *xml); + void getfromXML(XMLwrapper& xml); /**get all data to a newly allocated array (used for plugin) * @return the datasize*/ diff --git a/source/native-plugins/zynaddsubfx/Misc/Microtonal.cpp b/source/native-plugins/zynaddsubfx/Misc/Microtonal.cpp index ea698cf5b..04035baec 100644 --- a/source/native-plugins/zynaddsubfx/Misc/Microtonal.cpp +++ b/source/native-plugins/zynaddsubfx/Misc/Microtonal.cpp @@ -566,87 +566,87 @@ int Microtonal::loadkbm(const char *filename) -void Microtonal::add2XML(XMLwrapper *xml) const +void Microtonal::add2XML(XMLwrapper& xml) const { - xml->addparstr("name", (char *) Pname); - xml->addparstr("comment", (char *) Pcomment); + xml.addparstr("name", (char *) Pname); + xml.addparstr("comment", (char *) Pcomment); - xml->addparbool("invert_up_down", Pinvertupdown); - xml->addpar("invert_up_down_center", Pinvertupdowncenter); + xml.addparbool("invert_up_down", Pinvertupdown); + xml.addpar("invert_up_down_center", Pinvertupdowncenter); - xml->addparbool("enabled", Penabled); - xml->addpar("global_fine_detune", Pglobalfinedetune); + xml.addparbool("enabled", Penabled); + xml.addpar("global_fine_detune", Pglobalfinedetune); - xml->addpar("a_note", PAnote); - xml->addparreal("a_freq", PAfreq); + xml.addpar("a_note", PAnote); + xml.addparreal("a_freq", PAfreq); - if((Penabled == 0) && (xml->minimal)) + if((Penabled == 0) && (xml.minimal)) return; - xml->beginbranch("SCALE"); - xml->addpar("scale_shift", Pscaleshift); - xml->addpar("first_key", Pfirstkey); - xml->addpar("last_key", Plastkey); - xml->addpar("middle_note", Pmiddlenote); + xml.beginbranch("SCALE"); + xml.addpar("scale_shift", Pscaleshift); + xml.addpar("first_key", Pfirstkey); + xml.addpar("last_key", Plastkey); + xml.addpar("middle_note", Pmiddlenote); - xml->beginbranch("OCTAVE"); - xml->addpar("octave_size", octavesize); + xml.beginbranch("OCTAVE"); + xml.addpar("octave_size", octavesize); for(int i = 0; i < octavesize; ++i) { - xml->beginbranch("DEGREE", i); + xml.beginbranch("DEGREE", i); if(octave[i].type == 1) - xml->addparreal("cents", octave[i].tuning); + xml.addparreal("cents", octave[i].tuning); ; if(octave[i].type == 2) { - xml->addpar("numerator", octave[i].x1); - xml->addpar("denominator", octave[i].x2); + xml.addpar("numerator", octave[i].x1); + xml.addpar("denominator", octave[i].x2); } - xml->endbranch(); + xml.endbranch(); } - xml->endbranch(); + xml.endbranch(); - xml->beginbranch("KEYBOARD_MAPPING"); - xml->addpar("map_size", Pmapsize); - xml->addpar("mapping_enabled", Pmappingenabled); + xml.beginbranch("KEYBOARD_MAPPING"); + xml.addpar("map_size", Pmapsize); + xml.addpar("mapping_enabled", Pmappingenabled); for(int i = 0; i < Pmapsize; ++i) { - xml->beginbranch("KEYMAP", i); - xml->addpar("degree", Pmapping[i]); - xml->endbranch(); + xml.beginbranch("KEYMAP", i); + xml.addpar("degree", Pmapping[i]); + xml.endbranch(); } - xml->endbranch(); - xml->endbranch(); + xml.endbranch(); + xml.endbranch(); } -void Microtonal::getfromXML(XMLwrapper *xml) +void Microtonal::getfromXML(XMLwrapper& xml) { - xml->getparstr("name", (char *) Pname, MICROTONAL_MAX_NAME_LEN); - xml->getparstr("comment", (char *) Pcomment, MICROTONAL_MAX_NAME_LEN); + xml.getparstr("name", (char *) Pname, MICROTONAL_MAX_NAME_LEN); + xml.getparstr("comment", (char *) Pcomment, MICROTONAL_MAX_NAME_LEN); - Pinvertupdown = xml->getparbool("invert_up_down", Pinvertupdown); - Pinvertupdowncenter = xml->getpar127("invert_up_down_center", + Pinvertupdown = xml.getparbool("invert_up_down", Pinvertupdown); + Pinvertupdowncenter = xml.getpar127("invert_up_down_center", Pinvertupdowncenter); - Penabled = xml->getparbool("enabled", Penabled); - Pglobalfinedetune = xml->getpar127("global_fine_detune", Pglobalfinedetune); + Penabled = xml.getparbool("enabled", Penabled); + Pglobalfinedetune = xml.getpar127("global_fine_detune", Pglobalfinedetune); - PAnote = xml->getpar127("a_note", PAnote); - PAfreq = xml->getparreal("a_freq", PAfreq, 1.0f, 10000.0f); + PAnote = xml.getpar127("a_note", PAnote); + PAfreq = xml.getparreal("a_freq", PAfreq, 1.0f, 10000.0f); - if(xml->enterbranch("SCALE")) { - Pscaleshift = xml->getpar127("scale_shift", Pscaleshift); - Pfirstkey = xml->getpar127("first_key", Pfirstkey); - Plastkey = xml->getpar127("last_key", Plastkey); - Pmiddlenote = xml->getpar127("middle_note", Pmiddlenote); + if(xml.enterbranch("SCALE")) { + Pscaleshift = xml.getpar127("scale_shift", Pscaleshift); + Pfirstkey = xml.getpar127("first_key", Pfirstkey); + Plastkey = xml.getpar127("last_key", Plastkey); + Pmiddlenote = xml.getpar127("middle_note", Pmiddlenote); - if(xml->enterbranch("OCTAVE")) { - octavesize = xml->getpar127("octave_size", octavesize); + if(xml.enterbranch("OCTAVE")) { + octavesize = xml.getpar127("octave_size", octavesize); for(int i = 0; i < octavesize; ++i) { - if(xml->enterbranch("DEGREE", i) == 0) + if(xml.enterbranch("DEGREE", i) == 0) continue; octave[i].x2 = 0; - octave[i].tuning = xml->getparreal("cents", octave[i].tuning); - octave[i].x1 = xml->getpar127("numerator", octave[i].x1); - octave[i].x2 = xml->getpar127("denominator", octave[i].x2); + octave[i].tuning = xml.getparreal("cents", octave[i].tuning); + octave[i].x1 = xml.getpar127("numerator", octave[i].x1); + octave[i].x2 = xml.getpar127("denominator", octave[i].x2); if(octave[i].x2 != 0) octave[i].type = 2; @@ -659,23 +659,23 @@ void Microtonal::getfromXML(XMLwrapper *xml) } - xml->exitbranch(); + xml.exitbranch(); } - xml->exitbranch(); + xml.exitbranch(); } - if(xml->enterbranch("KEYBOARD_MAPPING")) { - Pmapsize = xml->getpar127("map_size", Pmapsize); - Pmappingenabled = xml->getpar127("mapping_enabled", Pmappingenabled); + if(xml.enterbranch("KEYBOARD_MAPPING")) { + Pmapsize = xml.getpar127("map_size", Pmapsize); + Pmappingenabled = xml.getpar127("mapping_enabled", Pmappingenabled); for(int i = 0; i < Pmapsize; ++i) { - if(xml->enterbranch("KEYMAP", i) == 0) + if(xml.enterbranch("KEYMAP", i) == 0) continue; - Pmapping[i] = xml->getpar127("degree", Pmapping[i]); - xml->exitbranch(); + Pmapping[i] = xml.getpar127("degree", Pmapping[i]); + xml.exitbranch(); } - xml->exitbranch(); + xml.exitbranch(); } - xml->exitbranch(); + xml.exitbranch(); } } @@ -683,30 +683,26 @@ void Microtonal::getfromXML(XMLwrapper *xml) int Microtonal::saveXML(const char *filename) const { - XMLwrapper *xml = new XMLwrapper(); + XMLwrapper xml; - xml->beginbranch("MICROTONAL"); + xml.beginbranch("MICROTONAL"); add2XML(xml); - xml->endbranch(); + xml.endbranch(); - int result = xml->saveXMLfile(filename, gzip_compression); - delete (xml); - return result; + return xml.saveXMLfile(filename, gzip_compression); } int Microtonal::loadXML(const char *filename) { - XMLwrapper *xml = new XMLwrapper(); - if(xml->loadXMLfile(filename) < 0) { - delete (xml); + XMLwrapper xml; + if(xml.loadXMLfile(filename) < 0) { return -1; } - if(xml->enterbranch("MICROTONAL") == 0) + if(xml.enterbranch("MICROTONAL") == 0) return -10; getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); - delete (xml); return 0; } diff --git a/source/native-plugins/zynaddsubfx/Misc/Microtonal.h b/source/native-plugins/zynaddsubfx/Misc/Microtonal.h index bbbde5970..db5c9c924 100644 --- a/source/native-plugins/zynaddsubfx/Misc/Microtonal.h +++ b/source/native-plugins/zynaddsubfx/Misc/Microtonal.h @@ -105,8 +105,8 @@ class Microtonal /**Comment about the tuning*/ char Pcomment[MICROTONAL_MAX_NAME_LEN]; - void add2XML(XMLwrapper *xml) const; - void getfromXML(XMLwrapper *xml); + void add2XML(XMLwrapper& xml) const; + void getfromXML(XMLwrapper& xml); int saveXML(const char *filename) const; int loadXML(const char *filename); diff --git a/source/native-plugins/zynaddsubfx/Misc/MiddleWare.cpp b/source/native-plugins/zynaddsubfx/Misc/MiddleWare.cpp index 59e635be6..e7f577c7b 100644 --- a/source/native-plugins/zynaddsubfx/Misc/MiddleWare.cpp +++ b/source/native-plugins/zynaddsubfx/Misc/MiddleWare.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -500,6 +501,7 @@ public: config->cfg.GzipCompression, config->cfg.Interpolation, &master->microtonal, master->fft); + if(p->loadXMLinstrument(filename)) fprintf(stderr, "Warning: failed to load part<%s>!\n", filename); @@ -524,19 +526,20 @@ public: { if(npart == -1) return; + Part *p = new Part(*master->memory, synth, - master->time, - config->cfg.GzipCompression, - config->cfg.Interpolation, - &master->microtonal, master->fft); + master->time, + config->cfg.GzipCompression, + config->cfg.Interpolation, + &master->microtonal, master->fft); p->applyparameters(); obj_store.extractPart(p, npart); kits.extractPart(p, npart); //Give it to the backend and wait for the old part to return for //deallocation - parent->transmitMsg("/load-part", "ib", npart, sizeof(Part*), &p); - GUI::raiseUi(ui, "/damage", "s", ("/part"+to_s(npart)+"/").c_str()); + parent->transmitMsg("/load-part", "ib", npart, sizeof(Part *), &p); + GUI::raiseUi(ui, "/damage", "s", ("/part" + to_s(npart) + "/").c_str()); } //Well, you don't get much crazier than changing out all of your RT @@ -1058,7 +1061,7 @@ static rtosc::Ports middlewareReplyPorts = { void *ptr = *(void**)rtosc_argument(msg, 1).b.data; deallocate(type, ptr); rEnd}, - {"request_memory:", 0, 0, + {"request-memory:", 0, 0, rBegin; //Generate out more memory for the RT memory pool //5MBi chunk diff --git a/source/native-plugins/zynaddsubfx/Misc/Part.cpp b/source/native-plugins/zynaddsubfx/Misc/Part.cpp index cd917ae77..0f2915807 100644 --- a/source/native-plugins/zynaddsubfx/Misc/Part.cpp +++ b/source/native-plugins/zynaddsubfx/Misc/Part.cpp @@ -43,6 +43,7 @@ #include #include +#include using rtosc::Ports; using rtosc::RtData; @@ -376,7 +377,7 @@ Part::~Part() } } -void assert_kit_sanity(const Part::Kit *kits) +static void assert_kit_sanity(const Part::Kit *kits) { for(int i=0; i(kit[i].adpars, pars), 0, i}); - if(item.Psubenabled) - notePool.insertNote(note, sendto, - {memory.alloc(kit[i].subpars, pars), 1, i}); - if(item.Ppadenabled) - notePool.insertNote(note, sendto, - {memory.alloc(kit[i].padpars, pars, interpolation), 2, i}); + try { + if(item.Padenabled) + notePool.insertNote(note, sendto, + {memory.alloc(kit[i].adpars, pars), 0, i}); + if(item.Psubenabled) + notePool.insertNote(note, sendto, + {memory.alloc(kit[i].subpars, pars), 1, i}); + if(item.Ppadenabled) + notePool.insertNote(note, sendto, + {memory.alloc(kit[i].padpars, pars, interpolation), 2, i}); + } catch (std::bad_alloc & ba) { + std::cerr << "dropped new note: " << ba.what() << std::endl; + } //Partial Kit Use if(isNonKit() || (isSingleKit() && item.active())) @@ -480,6 +509,7 @@ void Part::NoteOn(unsigned char note, //Enforce the key limit setkeylimit(Pkeylimit); + return true; } /* @@ -823,102 +853,102 @@ void Part::setkititemstatus(unsigned kititem, bool Penabled_) } } -void Part::add2XMLinstrument(XMLwrapper *xml) +void Part::add2XMLinstrument(XMLwrapper& xml) { - xml->beginbranch("INFO"); - xml->addparstr("name", (char *)Pname); - xml->addparstr("author", (char *)info.Pauthor); - xml->addparstr("comments", (char *)info.Pcomments); - xml->addpar("type", info.Ptype); - xml->endbranch(); + xml.beginbranch("INFO"); + xml.addparstr("name", (char *)Pname); + xml.addparstr("author", (char *)info.Pauthor); + xml.addparstr("comments", (char *)info.Pcomments); + xml.addpar("type", info.Ptype); + xml.endbranch(); - xml->beginbranch("INSTRUMENT_KIT"); - xml->addpar("kit_mode", Pkitmode); - xml->addparbool("drum_mode", Pdrummode); + xml.beginbranch("INSTRUMENT_KIT"); + xml.addpar("kit_mode", Pkitmode); + xml.addparbool("drum_mode", Pdrummode); for(int i = 0; i < NUM_KIT_ITEMS; ++i) { - xml->beginbranch("INSTRUMENT_KIT_ITEM", i); - xml->addparbool("enabled", kit[i].Penabled); + xml.beginbranch("INSTRUMENT_KIT_ITEM", i); + xml.addparbool("enabled", kit[i].Penabled); if(kit[i].Penabled != 0) { - xml->addparstr("name", (char *)kit[i].Pname); + xml.addparstr("name", (char *)kit[i].Pname); - xml->addparbool("muted", kit[i].Pmuted); - xml->addpar("min_key", kit[i].Pminkey); - xml->addpar("max_key", kit[i].Pmaxkey); + xml.addparbool("muted", kit[i].Pmuted); + xml.addpar("min_key", kit[i].Pminkey); + xml.addpar("max_key", kit[i].Pmaxkey); - xml->addpar("send_to_instrument_effect", kit[i].Psendtoparteffect); + xml.addpar("send_to_instrument_effect", kit[i].Psendtoparteffect); - xml->addparbool("add_enabled", kit[i].Padenabled); + xml.addparbool("add_enabled", kit[i].Padenabled); if(kit[i].Padenabled && kit[i].adpars) { - xml->beginbranch("ADD_SYNTH_PARAMETERS"); + xml.beginbranch("ADD_SYNTH_PARAMETERS"); kit[i].adpars->add2XML(xml); - xml->endbranch(); + xml.endbranch(); } - xml->addparbool("sub_enabled", kit[i].Psubenabled); + xml.addparbool("sub_enabled", kit[i].Psubenabled); if(kit[i].Psubenabled && kit[i].subpars) { - xml->beginbranch("SUB_SYNTH_PARAMETERS"); + xml.beginbranch("SUB_SYNTH_PARAMETERS"); kit[i].subpars->add2XML(xml); - xml->endbranch(); + xml.endbranch(); } - xml->addparbool("pad_enabled", kit[i].Ppadenabled); + xml.addparbool("pad_enabled", kit[i].Ppadenabled); if(kit[i].Ppadenabled && kit[i].padpars) { - xml->beginbranch("PAD_SYNTH_PARAMETERS"); + xml.beginbranch("PAD_SYNTH_PARAMETERS"); kit[i].padpars->add2XML(xml); - xml->endbranch(); + xml.endbranch(); } } - xml->endbranch(); + xml.endbranch(); } - xml->endbranch(); + xml.endbranch(); - xml->beginbranch("INSTRUMENT_EFFECTS"); + xml.beginbranch("INSTRUMENT_EFFECTS"); for(int nefx = 0; nefx < NUM_PART_EFX; ++nefx) { - xml->beginbranch("INSTRUMENT_EFFECT", nefx); - xml->beginbranch("EFFECT"); + xml.beginbranch("INSTRUMENT_EFFECT", nefx); + xml.beginbranch("EFFECT"); partefx[nefx]->add2XML(xml); - xml->endbranch(); + xml.endbranch(); - xml->addpar("route", Pefxroute[nefx]); + xml.addpar("route", Pefxroute[nefx]); partefx[nefx]->setdryonly(Pefxroute[nefx] == 2); - xml->addparbool("bypass", Pefxbypass[nefx]); - xml->endbranch(); + xml.addparbool("bypass", Pefxbypass[nefx]); + xml.endbranch(); } - xml->endbranch(); + xml.endbranch(); } -void Part::add2XML(XMLwrapper *xml) +void Part::add2XML(XMLwrapper& xml) { //parameters - xml->addparbool("enabled", Penabled); - if((Penabled == 0) && (xml->minimal)) + xml.addparbool("enabled", Penabled); + if((Penabled == 0) && (xml.minimal)) return; - xml->addpar("volume", Pvolume); - xml->addpar("panning", Ppanning); + xml.addpar("volume", Pvolume); + xml.addpar("panning", Ppanning); - xml->addpar("min_key", Pminkey); - xml->addpar("max_key", Pmaxkey); - xml->addpar("key_shift", Pkeyshift); - xml->addpar("rcv_chn", Prcvchn); + xml.addpar("min_key", Pminkey); + xml.addpar("max_key", Pmaxkey); + xml.addpar("key_shift", Pkeyshift); + xml.addpar("rcv_chn", Prcvchn); - xml->addpar("velocity_sensing", Pvelsns); - xml->addpar("velocity_offset", Pveloffs); + xml.addpar("velocity_sensing", Pvelsns); + xml.addpar("velocity_offset", Pveloffs); - xml->addparbool("note_on", Pnoteon); - xml->addparbool("poly_mode", Ppolymode); - xml->addpar("legato_mode", Plegatomode); - xml->addpar("key_limit", Pkeylimit); + xml.addparbool("note_on", Pnoteon); + xml.addparbool("poly_mode", Ppolymode); + xml.addpar("legato_mode", Plegatomode); + xml.addpar("key_limit", Pkeylimit); - xml->beginbranch("INSTRUMENT"); + xml.beginbranch("INSTRUMENT"); add2XMLinstrument(xml); - xml->endbranch(); + xml.endbranch(); - xml->beginbranch("CONTROLLER"); + xml.beginbranch("CONTROLLER"); ctl.add2XML(xml); - xml->endbranch(); + xml.endbranch(); } int Part::saveXML(const char *filename) @@ -926,7 +956,7 @@ int Part::saveXML(const char *filename) XMLwrapper xml; xml.beginbranch("INSTRUMENT"); - add2XMLinstrument(&xml); + add2XMLinstrument(xml); xml.endbranch(); int result = xml.saveXMLfile(filename, gzip_compression); @@ -942,7 +972,7 @@ int Part::loadXMLinstrument(const char *filename) if(xml.enterbranch("INSTRUMENT") == 0) return -10; - getfromXMLinstrument(&xml); + getfromXMLinstrument(xml); xml.exitbranch(); return 0; @@ -1013,127 +1043,127 @@ void Part::monomemClear(void) monomemnotes[i] = -1; } -void Part::getfromXMLinstrument(XMLwrapper *xml) +void Part::getfromXMLinstrument(XMLwrapper& xml) { - if(xml->enterbranch("INFO")) { - xml->getparstr("name", (char *)Pname, PART_MAX_NAME_LEN); - xml->getparstr("author", (char *)info.Pauthor, MAX_INFO_TEXT_SIZE); - xml->getparstr("comments", (char *)info.Pcomments, MAX_INFO_TEXT_SIZE); - info.Ptype = xml->getpar("type", info.Ptype, 0, 16); + if(xml.enterbranch("INFO")) { + xml.getparstr("name", (char *)Pname, PART_MAX_NAME_LEN); + xml.getparstr("author", (char *)info.Pauthor, MAX_INFO_TEXT_SIZE); + xml.getparstr("comments", (char *)info.Pcomments, MAX_INFO_TEXT_SIZE); + info.Ptype = xml.getpar("type", info.Ptype, 0, 16); - xml->exitbranch(); + xml.exitbranch(); } - if(xml->enterbranch("INSTRUMENT_KIT")) { - Pkitmode = xml->getpar127("kit_mode", Pkitmode); - Pdrummode = xml->getparbool("drum_mode", Pdrummode); + if(xml.enterbranch("INSTRUMENT_KIT")) { + Pkitmode = xml.getpar127("kit_mode", Pkitmode); + Pdrummode = xml.getparbool("drum_mode", Pdrummode); setkititemstatus(0, 0); for(int i = 0; i < NUM_KIT_ITEMS; ++i) { - if(xml->enterbranch("INSTRUMENT_KIT_ITEM", i) == 0) + if(xml.enterbranch("INSTRUMENT_KIT_ITEM", i) == 0) continue; - setkititemstatus(i, xml->getparbool("enabled", kit[i].Penabled)); + setkititemstatus(i, xml.getparbool("enabled", kit[i].Penabled)); if(kit[i].Penabled == 0) { - xml->exitbranch(); + xml.exitbranch(); continue; } - xml->getparstr("name", (char *)kit[i].Pname, PART_MAX_NAME_LEN); + xml.getparstr("name", (char *)kit[i].Pname, PART_MAX_NAME_LEN); - kit[i].Pmuted = xml->getparbool("muted", kit[i].Pmuted); - kit[i].Pminkey = xml->getpar127("min_key", kit[i].Pminkey); - kit[i].Pmaxkey = xml->getpar127("max_key", kit[i].Pmaxkey); + kit[i].Pmuted = xml.getparbool("muted", kit[i].Pmuted); + kit[i].Pminkey = xml.getpar127("min_key", kit[i].Pminkey); + kit[i].Pmaxkey = xml.getpar127("max_key", kit[i].Pmaxkey); - kit[i].Psendtoparteffect = xml->getpar127( + kit[i].Psendtoparteffect = xml.getpar127( "send_to_instrument_effect", kit[i].Psendtoparteffect); - kit[i].Padenabled = xml->getparbool("add_enabled", + kit[i].Padenabled = xml.getparbool("add_enabled", kit[i].Padenabled); - if(xml->enterbranch("ADD_SYNTH_PARAMETERS")) { + if(xml.enterbranch("ADD_SYNTH_PARAMETERS")) { if(!kit[i].adpars) kit[i].adpars = new ADnoteParameters(synth, fft); kit[i].adpars->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); } - kit[i].Psubenabled = xml->getparbool("sub_enabled", + kit[i].Psubenabled = xml.getparbool("sub_enabled", kit[i].Psubenabled); - if(xml->enterbranch("SUB_SYNTH_PARAMETERS")) { + if(xml.enterbranch("SUB_SYNTH_PARAMETERS")) { if(!kit[i].subpars) kit[i].subpars = new SUBnoteParameters(); kit[i].subpars->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); } - kit[i].Ppadenabled = xml->getparbool("pad_enabled", + kit[i].Ppadenabled = xml.getparbool("pad_enabled", kit[i].Ppadenabled); - if(xml->enterbranch("PAD_SYNTH_PARAMETERS")) { + if(xml.enterbranch("PAD_SYNTH_PARAMETERS")) { if(!kit[i].padpars) kit[i].padpars = new PADnoteParameters(synth, fft); kit[i].padpars->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); } - xml->exitbranch(); + xml.exitbranch(); } - xml->exitbranch(); + xml.exitbranch(); } - if(xml->enterbranch("INSTRUMENT_EFFECTS")) { + if(xml.enterbranch("INSTRUMENT_EFFECTS")) { for(int nefx = 0; nefx < NUM_PART_EFX; ++nefx) { - if(xml->enterbranch("INSTRUMENT_EFFECT", nefx) == 0) + if(xml.enterbranch("INSTRUMENT_EFFECT", nefx) == 0) continue; - if(xml->enterbranch("EFFECT")) { + if(xml.enterbranch("EFFECT")) { partefx[nefx]->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); } - Pefxroute[nefx] = xml->getpar("route", + Pefxroute[nefx] = xml.getpar("route", Pefxroute[nefx], 0, NUM_PART_EFX); partefx[nefx]->setdryonly(Pefxroute[nefx] == 2); - Pefxbypass[nefx] = xml->getparbool("bypass", Pefxbypass[nefx]); - xml->exitbranch(); + Pefxbypass[nefx] = xml.getparbool("bypass", Pefxbypass[nefx]); + xml.exitbranch(); } - xml->exitbranch(); + xml.exitbranch(); } } -void Part::getfromXML(XMLwrapper *xml) +void Part::getfromXML(XMLwrapper& xml) { - Penabled = xml->getparbool("enabled", Penabled); + Penabled = xml.getparbool("enabled", Penabled); - setPvolume(xml->getpar127("volume", Pvolume)); - setPpanning(xml->getpar127("panning", Ppanning)); + setPvolume(xml.getpar127("volume", Pvolume)); + setPpanning(xml.getpar127("panning", Ppanning)); - Pminkey = xml->getpar127("min_key", Pminkey); - Pmaxkey = xml->getpar127("max_key", Pmaxkey); - Pkeyshift = xml->getpar127("key_shift", Pkeyshift); - Prcvchn = xml->getpar127("rcv_chn", Prcvchn); + Pminkey = xml.getpar127("min_key", Pminkey); + Pmaxkey = xml.getpar127("max_key", Pmaxkey); + Pkeyshift = xml.getpar127("key_shift", Pkeyshift); + Prcvchn = xml.getpar127("rcv_chn", Prcvchn); - Pvelsns = xml->getpar127("velocity_sensing", Pvelsns); - Pveloffs = xml->getpar127("velocity_offset", Pveloffs); + Pvelsns = xml.getpar127("velocity_sensing", Pvelsns); + Pveloffs = xml.getpar127("velocity_offset", Pveloffs); - Pnoteon = xml->getparbool("note_on", Pnoteon); - Ppolymode = xml->getparbool("poly_mode", Ppolymode); - Plegatomode = xml->getparbool("legato_mode", Plegatomode); //older versions + Pnoteon = xml.getparbool("note_on", Pnoteon); + Ppolymode = xml.getparbool("poly_mode", Ppolymode); + Plegatomode = xml.getparbool("legato_mode", Plegatomode); //older versions if(!Plegatomode) - Plegatomode = xml->getpar127("legato_mode", Plegatomode); - Pkeylimit = xml->getpar127("key_limit", Pkeylimit); + Plegatomode = xml.getpar127("legato_mode", Plegatomode); + Pkeylimit = xml.getpar127("key_limit", Pkeylimit); - if(xml->enterbranch("INSTRUMENT")) { + if(xml.enterbranch("INSTRUMENT")) { getfromXMLinstrument(xml); - xml->exitbranch(); + xml.exitbranch(); } - if(xml->enterbranch("CONTROLLER")) { + if(xml.enterbranch("CONTROLLER")) { ctl.getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); } } diff --git a/source/native-plugins/zynaddsubfx/Misc/Part.h b/source/native-plugins/zynaddsubfx/Misc/Part.h index 8b7d38ea2..dec2eedb2 100644 --- a/source/native-plugins/zynaddsubfx/Misc/Part.h +++ b/source/native-plugins/zynaddsubfx/Misc/Part.h @@ -48,7 +48,9 @@ class Part void cloneTraits(Part &part) const REALTIME; // Midi commands implemented - void NoteOn(unsigned char note, + + //returns true when note is successfully applied + bool NoteOn(unsigned char note, unsigned char velocity, int masterkeyshift) REALTIME; void NoteOff(unsigned char note) REALTIME; @@ -69,8 +71,8 @@ class Part int saveXML(const char *filename); int loadXMLinstrument(const char *filename); - void add2XML(XMLwrapper *xml); - void add2XMLinstrument(XMLwrapper *xml); + void add2XML(XMLwrapper& xml); + void add2XMLinstrument(XMLwrapper& xml); void defaults(); void defaultsinstrument(); @@ -81,8 +83,8 @@ class Part void initialize_rt(void) REALTIME; void kill_rt(void) REALTIME; - void getfromXML(XMLwrapper *xml); - void getfromXMLinstrument(XMLwrapper *xml); + void getfromXML(XMLwrapper& xml); + void getfromXMLinstrument(XMLwrapper& xml); void cleanup(bool final = false); diff --git a/source/native-plugins/zynaddsubfx/Misc/PresetExtractor.cpp b/source/native-plugins/zynaddsubfx/Misc/PresetExtractor.cpp index 71824f948..79ffee6d6 100644 --- a/source/native-plugins/zynaddsubfx/Misc/PresetExtractor.cpp +++ b/source/native-plugins/zynaddsubfx/Misc/PresetExtractor.cpp @@ -222,7 +222,7 @@ void doPaste(MiddleWare &mw, string url, string type, XMLwrapper &xml, Ts&&... a if(xml.enterbranch(type) == 0) return; - t->getfromXML(&xml); + t->getfromXML(xml); //Send the pointer string path = url+"paste"; @@ -264,7 +264,7 @@ void doArrayPaste(MiddleWare &mw, int field, string url, string type, return; } t->defaults(field); - t->getfromXMLsection(&xml, field); + t->getfromXMLsection(xml, field); xml.exitbranch(); //Send the pointer diff --git a/source/native-plugins/zynaddsubfx/Misc/Util.cpp b/source/native-plugins/zynaddsubfx/Misc/Util.cpp index c3f43fdc5..269449f1e 100644 --- a/source/native-plugins/zynaddsubfx/Misc/Util.cpp +++ b/source/native-plugins/zynaddsubfx/Misc/Util.cpp @@ -219,7 +219,7 @@ char *rtosc_splat(const char *path, std::set v) char argT[v.size()+1]; rtosc_arg_t arg[v.size()]; unsigned i=0; - for(auto vv : v) { + for(auto &vv : v) { argT[i] = 's'; arg[i].s = vv.c_str(); i++; diff --git a/source/native-plugins/zynaddsubfx/Misc/Util.h b/source/native-plugins/zynaddsubfx/Misc/Util.h index 682894cc5..7fb9f15b0 100644 --- a/source/native-plugins/zynaddsubfx/Misc/Util.h +++ b/source/native-plugins/zynaddsubfx/Misc/Util.h @@ -161,11 +161,14 @@ char *rtosc_splat(const char *path, std::set); [](const char *, rtosc::RtData &d){ \ d.reply(d.loc, "b", sizeof(d.obj), &d.obj);}}\ -#define rPaste \ +#define rPresetType \ {"preset-type:", rProp(internal) rDoc("clipboard type of object"), 0, \ [](const char *, rtosc::RtData &d){ \ rObject *obj = (rObject*)d.obj; \ - d.reply(d.loc, "s", obj->type);}},\ + d.reply(d.loc, "s", obj->type);}} + +#define rPaste \ +rPresetType, \ {"paste:b", rProp(internal) rDoc("paste port"), 0, \ [](const char *m, rtosc::RtData &d){ \ printf("rPaste...\n"); \ diff --git a/source/native-plugins/zynaddsubfx/Misc/XMLwrapper.cpp b/source/native-plugins/zynaddsubfx/Misc/XMLwrapper.cpp index 42ca6f96a..8ae71d5a6 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 = 1; + version.Revision = 2; minimal = true; diff --git a/source/native-plugins/zynaddsubfx/Nio/InMgr.cpp b/source/native-plugins/zynaddsubfx/Nio/InMgr.cpp index 45b08f705..77a87d9cb 100644 --- a/source/native-plugins/zynaddsubfx/Nio/InMgr.cpp +++ b/source/native-plugins/zynaddsubfx/Nio/InMgr.cpp @@ -88,11 +88,15 @@ void InMgr::flush(unsigned frameStart, unsigned frameStop) break; case M_CONTROLLER: - if(ev.num == C_bankselectmsb) // Change current bank + if(ev.num == C_bankselectmsb) { // Change current bank + middleware->spawnMaster()->bToU->write("/forward", ""); middleware->spawnMaster()->bToU->write("/bank/msb", "i", ev.value); - else if(ev.num == C_bankselectlsb) // Change current bank (LSB) + middleware->spawnMaster()->bToU->write("/bank/bank_select", "i", ev.value); + + } else if(ev.num == C_bankselectlsb) {// Change current bank (LSB) + middleware->spawnMaster()->bToU->write("/forward", ""); middleware->spawnMaster()->bToU->write("/bank/lsb", "i", ev.value); - else + } else master->setController(ev.channel, ev.num, ev.value); break; diff --git a/source/native-plugins/zynaddsubfx/Params/ADnoteParameters.cpp b/source/native-plugins/zynaddsubfx/Params/ADnoteParameters.cpp index 7254a0499..bd8a89432 100644 --- a/source/native-plugins/zynaddsubfx/Params/ADnoteParameters.cpp +++ b/source/native-plugins/zynaddsubfx/Params/ADnoteParameters.cpp @@ -567,7 +567,7 @@ ADnoteParameters::~ADnoteParameters() KillVoice(nvoice); } -void ADnoteParameters::add2XMLsection(XMLwrapper *xml, int n) +void ADnoteParameters::add2XMLsection(XMLwrapper& xml, int n) { int nvoice = n; if(nvoice >= NUM_VOICES) @@ -582,321 +582,321 @@ void ADnoteParameters::add2XMLsection(XMLwrapper *xml, int n) fmoscilused = 1; } - xml->addparbool("enabled", VoicePar[nvoice].Enabled); + xml.addparbool("enabled", VoicePar[nvoice].Enabled); if(((VoicePar[nvoice].Enabled == 0) && (oscilused == 0) - && (fmoscilused == 0)) && (xml->minimal)) + && (fmoscilused == 0)) && (xml.minimal)) return; VoicePar[nvoice].add2XML(xml, fmoscilused); } -void ADnoteVoiceParam::add2XML(XMLwrapper *xml, bool fmoscilused) +void ADnoteVoiceParam::add2XML(XMLwrapper& xml, bool fmoscilused) { - xml->addpar("type", Type); + xml.addpar("type", Type); - xml->addpar("unison_size", Unison_size); - xml->addpar("unison_frequency_spread", + xml.addpar("unison_size", Unison_size); + xml.addpar("unison_frequency_spread", Unison_frequency_spread); - xml->addpar("unison_stereo_spread", Unison_stereo_spread); - xml->addpar("unison_vibratto", Unison_vibratto); - xml->addpar("unison_vibratto_speed", Unison_vibratto_speed); - xml->addpar("unison_invert_phase", Unison_invert_phase); - xml->addpar("unison_phase_randomness", Unison_phase_randomness); + xml.addpar("unison_stereo_spread", Unison_stereo_spread); + xml.addpar("unison_vibratto", Unison_vibratto); + xml.addpar("unison_vibratto_speed", Unison_vibratto_speed); + xml.addpar("unison_invert_phase", Unison_invert_phase); + xml.addpar("unison_phase_randomness", Unison_phase_randomness); - xml->addpar("delay", PDelay); - xml->addparbool("resonance", Presonance); + xml.addpar("delay", PDelay); + xml.addparbool("resonance", Presonance); - xml->addpar("ext_oscil", Pextoscil); - xml->addpar("ext_fm_oscil", PextFMoscil); + xml.addpar("ext_oscil", Pextoscil); + xml.addpar("ext_fm_oscil", PextFMoscil); - xml->addpar("oscil_phase", Poscilphase); - xml->addpar("oscil_fm_phase", PFMoscilphase); + xml.addpar("oscil_phase", Poscilphase); + xml.addpar("oscil_fm_phase", PFMoscilphase); - xml->addparbool("filter_enabled", PFilterEnabled); - xml->addparbool("filter_bypass", Pfilterbypass); + xml.addparbool("filter_enabled", PFilterEnabled); + xml.addparbool("filter_bypass", Pfilterbypass); - xml->addpar("fm_enabled", PFMEnabled); + xml.addpar("fm_enabled", PFMEnabled); - xml->beginbranch("OSCIL"); + xml.beginbranch("OSCIL"); OscilSmp->add2XML(xml); - xml->endbranch(); + xml.endbranch(); - xml->beginbranch("AMPLITUDE_PARAMETERS"); - xml->addpar("panning", PPanning); - xml->addpar("volume", PVolume); - xml->addparbool("volume_minus", PVolumeminus); - xml->addpar("velocity_sensing", PAmpVelocityScaleFunction); + xml.beginbranch("AMPLITUDE_PARAMETERS"); + xml.addpar("panning", PPanning); + xml.addpar("volume", PVolume); + xml.addparbool("volume_minus", PVolumeminus); + xml.addpar("velocity_sensing", PAmpVelocityScaleFunction); - xml->addparbool("amp_envelope_enabled", + xml.addparbool("amp_envelope_enabled", PAmpEnvelopeEnabled); - if((PAmpEnvelopeEnabled != 0) || (!xml->minimal)) { - xml->beginbranch("AMPLITUDE_ENVELOPE"); + if((PAmpEnvelopeEnabled != 0) || (!xml.minimal)) { + xml.beginbranch("AMPLITUDE_ENVELOPE"); AmpEnvelope->add2XML(xml); - xml->endbranch(); + xml.endbranch(); } - xml->addparbool("amp_lfo_enabled", PAmpLfoEnabled); - if((PAmpLfoEnabled != 0) || (!xml->minimal)) { - xml->beginbranch("AMPLITUDE_LFO"); + xml.addparbool("amp_lfo_enabled", PAmpLfoEnabled); + if((PAmpLfoEnabled != 0) || (!xml.minimal)) { + xml.beginbranch("AMPLITUDE_LFO"); AmpLfo->add2XML(xml); - xml->endbranch(); + xml.endbranch(); } - xml->endbranch(); + xml.endbranch(); - xml->beginbranch("FREQUENCY_PARAMETERS"); - xml->addparbool("fixed_freq", Pfixedfreq); - xml->addpar("fixed_freq_et", PfixedfreqET); - xml->addpar("detune", PDetune); - xml->addpar("coarse_detune", PCoarseDetune); - xml->addpar("detune_type", PDetuneType); + xml.beginbranch("FREQUENCY_PARAMETERS"); + xml.addparbool("fixed_freq", Pfixedfreq); + xml.addpar("fixed_freq_et", PfixedfreqET); + xml.addpar("detune", PDetune); + xml.addpar("coarse_detune", PCoarseDetune); + xml.addpar("detune_type", PDetuneType); - xml->addparbool("freq_envelope_enabled", + xml.addparbool("freq_envelope_enabled", PFreqEnvelopeEnabled); - if((PFreqEnvelopeEnabled != 0) || (!xml->minimal)) { - xml->beginbranch("FREQUENCY_ENVELOPE"); + if((PFreqEnvelopeEnabled != 0) || (!xml.minimal)) { + xml.beginbranch("FREQUENCY_ENVELOPE"); FreqEnvelope->add2XML(xml); - xml->endbranch(); + xml.endbranch(); } - xml->addparbool("freq_lfo_enabled", PFreqLfoEnabled); - if((PFreqLfoEnabled != 0) || (!xml->minimal)) { - xml->beginbranch("FREQUENCY_LFO"); + xml.addparbool("freq_lfo_enabled", PFreqLfoEnabled); + if((PFreqLfoEnabled != 0) || (!xml.minimal)) { + xml.beginbranch("FREQUENCY_LFO"); FreqLfo->add2XML(xml); - xml->endbranch(); + xml.endbranch(); } - xml->endbranch(); + xml.endbranch(); - if((PFilterEnabled != 0) || (!xml->minimal)) { - xml->beginbranch("FILTER_PARAMETERS"); - xml->addpar("velocity_sensing_amplitude", PFilterVelocityScale); - xml->addpar("velocity_sensing", PFilterVelocityScaleFunction); - xml->beginbranch("FILTER"); + if((PFilterEnabled != 0) || (!xml.minimal)) { + xml.beginbranch("FILTER_PARAMETERS"); + xml.addpar("velocity_sensing_amplitude", PFilterVelocityScale); + xml.addpar("velocity_sensing", PFilterVelocityScaleFunction); + xml.beginbranch("FILTER"); VoiceFilter->add2XML(xml); - xml->endbranch(); + xml.endbranch(); - xml->addparbool("filter_envelope_enabled", + xml.addparbool("filter_envelope_enabled", PFilterEnvelopeEnabled); - if((PFilterEnvelopeEnabled != 0) || (!xml->minimal)) { - xml->beginbranch("FILTER_ENVELOPE"); + if((PFilterEnvelopeEnabled != 0) || (!xml.minimal)) { + xml.beginbranch("FILTER_ENVELOPE"); FilterEnvelope->add2XML(xml); - xml->endbranch(); + xml.endbranch(); } - xml->addparbool("filter_lfo_enabled", + xml.addparbool("filter_lfo_enabled", PFilterLfoEnabled); - if((PFilterLfoEnabled != 0) || (!xml->minimal)) { - xml->beginbranch("FILTER_LFO"); + if((PFilterLfoEnabled != 0) || (!xml.minimal)) { + xml.beginbranch("FILTER_LFO"); FilterLfo->add2XML(xml); - xml->endbranch(); + xml.endbranch(); } - xml->endbranch(); + xml.endbranch(); } if((PFMEnabled != 0) || (fmoscilused != 0) - || (!xml->minimal)) { - xml->beginbranch("FM_PARAMETERS"); - xml->addpar("input_voice", PFMVoice); + || (!xml.minimal)) { + xml.beginbranch("FM_PARAMETERS"); + xml.addpar("input_voice", PFMVoice); - xml->addpar("volume", PFMVolume); - xml->addpar("volume_damp", PFMVolumeDamp); - xml->addpar("velocity_sensing", + xml.addpar("volume", PFMVolume); + xml.addpar("volume_damp", PFMVolumeDamp); + xml.addpar("velocity_sensing", PFMVelocityScaleFunction); - xml->addparbool("amp_envelope_enabled", + xml.addparbool("amp_envelope_enabled", PFMAmpEnvelopeEnabled); - if((PFMAmpEnvelopeEnabled != 0) || (!xml->minimal)) { - xml->beginbranch("AMPLITUDE_ENVELOPE"); + if((PFMAmpEnvelopeEnabled != 0) || (!xml.minimal)) { + xml.beginbranch("AMPLITUDE_ENVELOPE"); FMAmpEnvelope->add2XML(xml); - xml->endbranch(); + xml.endbranch(); } - xml->beginbranch("MODULATOR"); - xml->addpar("detune", PFMDetune); - xml->addpar("coarse_detune", PFMCoarseDetune); - xml->addpar("detune_type", PFMDetuneType); + xml.beginbranch("MODULATOR"); + xml.addpar("detune", PFMDetune); + xml.addpar("coarse_detune", PFMCoarseDetune); + xml.addpar("detune_type", PFMDetuneType); - xml->addparbool("freq_envelope_enabled", + xml.addparbool("freq_envelope_enabled", PFMFreqEnvelopeEnabled); - if((PFMFreqEnvelopeEnabled != 0) || (!xml->minimal)) { - xml->beginbranch("FREQUENCY_ENVELOPE"); + if((PFMFreqEnvelopeEnabled != 0) || (!xml.minimal)) { + xml.beginbranch("FREQUENCY_ENVELOPE"); FMFreqEnvelope->add2XML(xml); - xml->endbranch(); + xml.endbranch(); } - xml->beginbranch("OSCIL"); + xml.beginbranch("OSCIL"); FMSmp->add2XML(xml); - xml->endbranch(); + xml.endbranch(); - xml->endbranch(); - xml->endbranch(); + xml.endbranch(); + xml.endbranch(); } } -void ADnoteGlobalParam::add2XML(XMLwrapper *xml) +void ADnoteGlobalParam::add2XML(XMLwrapper& xml) { - xml->addparbool("stereo", PStereo); - - xml->beginbranch("AMPLITUDE_PARAMETERS"); - xml->addpar("volume", PVolume); - xml->addpar("panning", PPanning); - xml->addpar("velocity_sensing", PAmpVelocityScaleFunction); - xml->addpar("fadein_adjustment", Fadein_adjustment); - xml->addpar("punch_strength", PPunchStrength); - xml->addpar("punch_time", PPunchTime); - xml->addpar("punch_stretch", PPunchStretch); - xml->addpar("punch_velocity_sensing", PPunchVelocitySensing); - xml->addpar("harmonic_randomness_grouping", Hrandgrouping); - - xml->beginbranch("AMPLITUDE_ENVELOPE"); + xml.addparbool("stereo", PStereo); + + xml.beginbranch("AMPLITUDE_PARAMETERS"); + xml.addpar("volume", PVolume); + xml.addpar("panning", PPanning); + xml.addpar("velocity_sensing", PAmpVelocityScaleFunction); + xml.addpar("fadein_adjustment", Fadein_adjustment); + xml.addpar("punch_strength", PPunchStrength); + xml.addpar("punch_time", PPunchTime); + xml.addpar("punch_stretch", PPunchStretch); + xml.addpar("punch_velocity_sensing", PPunchVelocitySensing); + xml.addpar("harmonic_randomness_grouping", Hrandgrouping); + + xml.beginbranch("AMPLITUDE_ENVELOPE"); AmpEnvelope->add2XML(xml); - xml->endbranch(); + xml.endbranch(); - xml->beginbranch("AMPLITUDE_LFO"); + xml.beginbranch("AMPLITUDE_LFO"); AmpLfo->add2XML(xml); - xml->endbranch(); - xml->endbranch(); + xml.endbranch(); + xml.endbranch(); - xml->beginbranch("FREQUENCY_PARAMETERS"); - xml->addpar("detune", PDetune); + xml.beginbranch("FREQUENCY_PARAMETERS"); + xml.addpar("detune", PDetune); - xml->addpar("coarse_detune", PCoarseDetune); - xml->addpar("detune_type", PDetuneType); + xml.addpar("coarse_detune", PCoarseDetune); + xml.addpar("detune_type", PDetuneType); - xml->addpar("bandwidth", PBandwidth); + xml.addpar("bandwidth", PBandwidth); - xml->beginbranch("FREQUENCY_ENVELOPE"); + xml.beginbranch("FREQUENCY_ENVELOPE"); FreqEnvelope->add2XML(xml); - xml->endbranch(); + xml.endbranch(); - xml->beginbranch("FREQUENCY_LFO"); + xml.beginbranch("FREQUENCY_LFO"); FreqLfo->add2XML(xml); - xml->endbranch(); - xml->endbranch(); + xml.endbranch(); + xml.endbranch(); - xml->beginbranch("FILTER_PARAMETERS"); - xml->addpar("velocity_sensing_amplitude", PFilterVelocityScale); - xml->addpar("velocity_sensing", PFilterVelocityScaleFunction); + xml.beginbranch("FILTER_PARAMETERS"); + xml.addpar("velocity_sensing_amplitude", PFilterVelocityScale); + xml.addpar("velocity_sensing", PFilterVelocityScaleFunction); - xml->beginbranch("FILTER"); + xml.beginbranch("FILTER"); GlobalFilter->add2XML(xml); - xml->endbranch(); + xml.endbranch(); - xml->beginbranch("FILTER_ENVELOPE"); + xml.beginbranch("FILTER_ENVELOPE"); FilterEnvelope->add2XML(xml); - xml->endbranch(); + xml.endbranch(); - xml->beginbranch("FILTER_LFO"); + xml.beginbranch("FILTER_LFO"); FilterLfo->add2XML(xml); - xml->endbranch(); - xml->endbranch(); + xml.endbranch(); + xml.endbranch(); - xml->beginbranch("RESONANCE"); + xml.beginbranch("RESONANCE"); Reson->add2XML(xml); - xml->endbranch(); + xml.endbranch(); } -void ADnoteParameters::add2XML(XMLwrapper *xml) +void ADnoteParameters::add2XML(XMLwrapper& xml) { GlobalPar.add2XML(xml); for(int nvoice = 0; nvoice < NUM_VOICES; ++nvoice) { - xml->beginbranch("VOICE", nvoice); + xml.beginbranch("VOICE", nvoice); add2XMLsection(xml, nvoice); - xml->endbranch(); + xml.endbranch(); } } -void ADnoteGlobalParam::getfromXML(XMLwrapper *xml) +void ADnoteGlobalParam::getfromXML(XMLwrapper& xml) { - PStereo = xml->getparbool("stereo", PStereo); + PStereo = xml.getparbool("stereo", PStereo); - if(xml->enterbranch("AMPLITUDE_PARAMETERS")) { - PVolume = xml->getpar127("volume", PVolume); - PPanning = xml->getpar127("panning", PPanning); - PAmpVelocityScaleFunction = xml->getpar127("velocity_sensing", + if(xml.enterbranch("AMPLITUDE_PARAMETERS")) { + PVolume = xml.getpar127("volume", PVolume); + PPanning = xml.getpar127("panning", PPanning); + PAmpVelocityScaleFunction = xml.getpar127("velocity_sensing", PAmpVelocityScaleFunction); - Fadein_adjustment = xml->getpar127("fadein_adjustment", Fadein_adjustment); - PPunchStrength = xml->getpar127("punch_strength", PPunchStrength); - PPunchTime = xml->getpar127("punch_time", PPunchTime); - PPunchStretch = xml->getpar127("punch_stretch", PPunchStretch); - PPunchVelocitySensing = xml->getpar127("punch_velocity_sensing", + Fadein_adjustment = xml.getpar127("fadein_adjustment", Fadein_adjustment); + PPunchStrength = xml.getpar127("punch_strength", PPunchStrength); + PPunchTime = xml.getpar127("punch_time", PPunchTime); + PPunchStretch = xml.getpar127("punch_stretch", PPunchStretch); + PPunchVelocitySensing = xml.getpar127("punch_velocity_sensing", PPunchVelocitySensing); - Hrandgrouping = xml->getpar127("harmonic_randomness_grouping", + Hrandgrouping = xml.getpar127("harmonic_randomness_grouping", Hrandgrouping); - if(xml->enterbranch("AMPLITUDE_ENVELOPE")) { + if(xml.enterbranch("AMPLITUDE_ENVELOPE")) { AmpEnvelope->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); } - if(xml->enterbranch("AMPLITUDE_LFO")) { + if(xml.enterbranch("AMPLITUDE_LFO")) { AmpLfo->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); } - xml->exitbranch(); + xml.exitbranch(); } - if(xml->enterbranch("FREQUENCY_PARAMETERS")) { - PDetune = xml->getpar("detune", PDetune, 0, 16383); - PCoarseDetune = xml->getpar("coarse_detune", PCoarseDetune, 0, 16383); - PDetuneType = xml->getpar127("detune_type", PDetuneType); - PBandwidth = xml->getpar127("bandwidth", PBandwidth); + if(xml.enterbranch("FREQUENCY_PARAMETERS")) { + PDetune = xml.getpar("detune", PDetune, 0, 16383); + PCoarseDetune = xml.getpar("coarse_detune", PCoarseDetune, 0, 16383); + PDetuneType = xml.getpar127("detune_type", PDetuneType); + PBandwidth = xml.getpar127("bandwidth", PBandwidth); - xml->enterbranch("FREQUENCY_ENVELOPE"); + xml.enterbranch("FREQUENCY_ENVELOPE"); FreqEnvelope->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); - xml->enterbranch("FREQUENCY_LFO"); + xml.enterbranch("FREQUENCY_LFO"); FreqLfo->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); - xml->exitbranch(); + xml.exitbranch(); } - if(xml->enterbranch("FILTER_PARAMETERS")) { - PFilterVelocityScale = xml->getpar127("velocity_sensing_amplitude", + if(xml.enterbranch("FILTER_PARAMETERS")) { + PFilterVelocityScale = xml.getpar127("velocity_sensing_amplitude", PFilterVelocityScale); - PFilterVelocityScaleFunction = xml->getpar127( + PFilterVelocityScaleFunction = xml.getpar127( "velocity_sensing", PFilterVelocityScaleFunction); - xml->enterbranch("FILTER"); + xml.enterbranch("FILTER"); GlobalFilter->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); - xml->enterbranch("FILTER_ENVELOPE"); + xml.enterbranch("FILTER_ENVELOPE"); FilterEnvelope->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); - xml->enterbranch("FILTER_LFO"); + xml.enterbranch("FILTER_LFO"); FilterLfo->getfromXML(xml); - xml->exitbranch(); - xml->exitbranch(); + xml.exitbranch(); + xml.exitbranch(); } - if(xml->enterbranch("RESONANCE")) { + if(xml.enterbranch("RESONANCE")) { Reson->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); } } -void ADnoteParameters::getfromXML(XMLwrapper *xml) +void ADnoteParameters::getfromXML(XMLwrapper& xml) { GlobalPar.getfromXML(xml); for(int nvoice = 0; nvoice < NUM_VOICES; ++nvoice) { VoicePar[nvoice].Enabled = 0; - if(xml->enterbranch("VOICE", nvoice) == 0) + if(xml.enterbranch("VOICE", nvoice) == 0) continue; getfromXMLsection(xml, nvoice); - xml->exitbranch(); + xml.exitbranch(); } } -void ADnoteParameters::getfromXMLsection(XMLwrapper *xml, int n) +void ADnoteParameters::getfromXMLsection(XMLwrapper& xml, int n) { int nvoice = n; if(nvoice >= NUM_VOICES) @@ -1042,149 +1042,149 @@ void ADnoteGlobalParam::paste(ADnoteGlobalParam &a) #undef copy #undef RCopy -void ADnoteVoiceParam::getfromXML(XMLwrapper *xml, unsigned nvoice) +void ADnoteVoiceParam::getfromXML(XMLwrapper& xml, unsigned nvoice) { - Enabled = xml->getparbool("enabled", 0); - Unison_size = xml->getpar127("unison_size", Unison_size); - Unison_frequency_spread = xml->getpar127("unison_frequency_spread", + Enabled = xml.getparbool("enabled", 0); + Unison_size = xml.getpar127("unison_size", Unison_size); + Unison_frequency_spread = xml.getpar127("unison_frequency_spread", Unison_frequency_spread); - Unison_stereo_spread = xml->getpar127("unison_stereo_spread", + Unison_stereo_spread = xml.getpar127("unison_stereo_spread", Unison_stereo_spread); - Unison_vibratto = xml->getpar127("unison_vibratto", Unison_vibratto); - Unison_vibratto_speed = xml->getpar127("unison_vibratto_speed", + Unison_vibratto = xml.getpar127("unison_vibratto", Unison_vibratto); + Unison_vibratto_speed = xml.getpar127("unison_vibratto_speed", Unison_vibratto_speed); - Unison_invert_phase = xml->getpar127("unison_invert_phase", + Unison_invert_phase = xml.getpar127("unison_invert_phase", Unison_invert_phase); - Unison_phase_randomness = xml->getpar127("unison_phase_randomness", + Unison_phase_randomness = xml.getpar127("unison_phase_randomness", Unison_phase_randomness); - Type = xml->getpar127("type", Type); - PDelay = xml->getpar127("delay", PDelay); - Presonance = xml->getparbool("resonance", Presonance); + Type = xml.getpar127("type", Type); + PDelay = xml.getpar127("delay", PDelay); + Presonance = xml.getparbool("resonance", Presonance); - Pextoscil = xml->getpar("ext_oscil", -1, -1, nvoice - 1); - PextFMoscil = xml->getpar("ext_fm_oscil", -1, -1, nvoice - 1); + Pextoscil = xml.getpar("ext_oscil", -1, -1, nvoice - 1); + PextFMoscil = xml.getpar("ext_fm_oscil", -1, -1, nvoice - 1); - Poscilphase = xml->getpar127("oscil_phase", Poscilphase); - PFMoscilphase = xml->getpar127("oscil_fm_phase", PFMoscilphase); - PFilterEnabled = xml->getparbool("filter_enabled", PFilterEnabled); - Pfilterbypass = xml->getparbool("filter_bypass", Pfilterbypass); - PFMEnabled = xml->getpar127("fm_enabled", PFMEnabled); + Poscilphase = xml.getpar127("oscil_phase", Poscilphase); + PFMoscilphase = xml.getpar127("oscil_fm_phase", PFMoscilphase); + PFilterEnabled = xml.getparbool("filter_enabled", PFilterEnabled); + Pfilterbypass = xml.getparbool("filter_bypass", Pfilterbypass); + PFMEnabled = xml.getpar127("fm_enabled", PFMEnabled); - if(xml->enterbranch("OSCIL")) { + if(xml.enterbranch("OSCIL")) { OscilSmp->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); } - if(xml->enterbranch("AMPLITUDE_PARAMETERS")) { - PPanning = xml->getpar127("panning", PPanning); - PVolume = xml->getpar127("volume", PVolume); - PVolumeminus = xml->getparbool("volume_minus", PVolumeminus); - PAmpVelocityScaleFunction = xml->getpar127("velocity_sensing", + if(xml.enterbranch("AMPLITUDE_PARAMETERS")) { + PPanning = xml.getpar127("panning", PPanning); + PVolume = xml.getpar127("volume", PVolume); + PVolumeminus = xml.getparbool("volume_minus", PVolumeminus); + PAmpVelocityScaleFunction = xml.getpar127("velocity_sensing", PAmpVelocityScaleFunction); - PAmpEnvelopeEnabled = xml->getparbool("amp_envelope_enabled", + PAmpEnvelopeEnabled = xml.getparbool("amp_envelope_enabled", PAmpEnvelopeEnabled); - if(xml->enterbranch("AMPLITUDE_ENVELOPE")) { + if(xml.enterbranch("AMPLITUDE_ENVELOPE")) { AmpEnvelope->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); } - PAmpLfoEnabled = xml->getparbool("amp_lfo_enabled", PAmpLfoEnabled); - if(xml->enterbranch("AMPLITUDE_LFO")) { + PAmpLfoEnabled = xml.getparbool("amp_lfo_enabled", PAmpLfoEnabled); + if(xml.enterbranch("AMPLITUDE_LFO")) { AmpLfo->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); } - xml->exitbranch(); + xml.exitbranch(); } - if(xml->enterbranch("FREQUENCY_PARAMETERS")) { - Pfixedfreq = xml->getparbool("fixed_freq", Pfixedfreq); - PfixedfreqET = xml->getpar127("fixed_freq_et", PfixedfreqET); - PDetune = xml->getpar("detune", PDetune, 0, 16383); - PCoarseDetune = xml->getpar("coarse_detune", PCoarseDetune, 0, 16383); - PDetuneType = xml->getpar127("detune_type", PDetuneType); - PFreqEnvelopeEnabled = xml->getparbool("freq_envelope_enabled", + if(xml.enterbranch("FREQUENCY_PARAMETERS")) { + Pfixedfreq = xml.getparbool("fixed_freq", Pfixedfreq); + PfixedfreqET = xml.getpar127("fixed_freq_et", PfixedfreqET); + PDetune = xml.getpar("detune", PDetune, 0, 16383); + PCoarseDetune = xml.getpar("coarse_detune", PCoarseDetune, 0, 16383); + PDetuneType = xml.getpar127("detune_type", PDetuneType); + PFreqEnvelopeEnabled = xml.getparbool("freq_envelope_enabled", PFreqEnvelopeEnabled); - if(xml->enterbranch("FREQUENCY_ENVELOPE")) { + if(xml.enterbranch("FREQUENCY_ENVELOPE")) { FreqEnvelope->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); } - PFreqLfoEnabled = xml->getparbool("freq_lfo_enabled", PFreqLfoEnabled); + PFreqLfoEnabled = xml.getparbool("freq_lfo_enabled", PFreqLfoEnabled); - if(xml->enterbranch("FREQUENCY_LFO")) { + if(xml.enterbranch("FREQUENCY_LFO")) { FreqLfo->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); } - xml->exitbranch(); + xml.exitbranch(); } - if(xml->enterbranch("FILTER_PARAMETERS")) { - PFilterVelocityScale = xml->getpar127("velocity_sensing_amplitude", + if(xml.enterbranch("FILTER_PARAMETERS")) { + PFilterVelocityScale = xml.getpar127("velocity_sensing_amplitude", PFilterVelocityScale); - PFilterVelocityScaleFunction = xml->getpar127( + PFilterVelocityScaleFunction = xml.getpar127( "velocity_sensing", PFilterVelocityScaleFunction); - if(xml->enterbranch("FILTER")) { + if(xml.enterbranch("FILTER")) { VoiceFilter->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); } - PFilterEnvelopeEnabled = xml->getparbool("filter_envelope_enabled", + PFilterEnvelopeEnabled = xml.getparbool("filter_envelope_enabled", PFilterEnvelopeEnabled); - if(xml->enterbranch("FILTER_ENVELOPE")) { + if(xml.enterbranch("FILTER_ENVELOPE")) { FilterEnvelope->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); } - PFilterLfoEnabled = xml->getparbool("filter_lfo_enabled", + PFilterLfoEnabled = xml.getparbool("filter_lfo_enabled", PFilterLfoEnabled); - if(xml->enterbranch("FILTER_LFO")) { + if(xml.enterbranch("FILTER_LFO")) { FilterLfo->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); } - xml->exitbranch(); + xml.exitbranch(); } - if(xml->enterbranch("FM_PARAMETERS")) { - PFMVoice = xml->getpar("input_voice", PFMVoice, -1, nvoice - 1); - PFMVolume = xml->getpar127("volume", PFMVolume); - PFMVolumeDamp = xml->getpar127("volume_damp", PFMVolumeDamp); - PFMVelocityScaleFunction = xml->getpar127("velocity_sensing", + if(xml.enterbranch("FM_PARAMETERS")) { + PFMVoice = xml.getpar("input_voice", PFMVoice, -1, nvoice - 1); + PFMVolume = xml.getpar127("volume", PFMVolume); + PFMVolumeDamp = xml.getpar127("volume_damp", PFMVolumeDamp); + PFMVelocityScaleFunction = xml.getpar127("velocity_sensing", PFMVelocityScaleFunction); - PFMAmpEnvelopeEnabled = xml->getparbool("amp_envelope_enabled", + PFMAmpEnvelopeEnabled = xml.getparbool("amp_envelope_enabled", PFMAmpEnvelopeEnabled); - if(xml->enterbranch("AMPLITUDE_ENVELOPE")) { + if(xml.enterbranch("AMPLITUDE_ENVELOPE")) { FMAmpEnvelope->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); } - if(xml->enterbranch("MODULATOR")) { - PFMDetune = xml->getpar("detune", PFMDetune, 0, 16383); - PFMCoarseDetune = xml->getpar("coarse_detune", + if(xml.enterbranch("MODULATOR")) { + PFMDetune = xml.getpar("detune", PFMDetune, 0, 16383); + PFMCoarseDetune = xml.getpar("coarse_detune", PFMCoarseDetune, 0, 16383); - PFMDetuneType = xml->getpar127("detune_type", PFMDetuneType); + PFMDetuneType = xml.getpar127("detune_type", PFMDetuneType); - PFMFreqEnvelopeEnabled = xml->getparbool("freq_envelope_enabled", + PFMFreqEnvelopeEnabled = xml.getparbool("freq_envelope_enabled", PFMFreqEnvelopeEnabled); - if(xml->enterbranch("FREQUENCY_ENVELOPE")) { + if(xml.enterbranch("FREQUENCY_ENVELOPE")) { FMFreqEnvelope->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); } - if(xml->enterbranch("OSCIL")) { + if(xml.enterbranch("OSCIL")) { FMSmp->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); } - xml->exitbranch(); + xml.exitbranch(); } - xml->exitbranch(); + xml.exitbranch(); } } diff --git a/source/native-plugins/zynaddsubfx/Params/ADnoteParameters.h b/source/native-plugins/zynaddsubfx/Params/ADnoteParameters.h index c86215205..13cd3b7bd 100644 --- a/source/native-plugins/zynaddsubfx/Params/ADnoteParameters.h +++ b/source/native-plugins/zynaddsubfx/Params/ADnoteParameters.h @@ -38,8 +38,8 @@ struct ADnoteGlobalParam { ADnoteGlobalParam(); ~ADnoteGlobalParam(); void defaults(); - void add2XML(XMLwrapper *xml); - void getfromXML(XMLwrapper *xml); + void add2XML(XMLwrapper& xml); + void getfromXML(XMLwrapper& xml); void paste(ADnoteGlobalParam &a); /* The instrument type - MONO/STEREO If the mode is MONO, the panning of voices are not used @@ -115,8 +115,8 @@ struct ADnoteGlobalParam { /* VOICE PARAMETERS */ /***********************************************************/ struct ADnoteVoiceParam { - void getfromXML(XMLwrapper *xml, unsigned nvoice); - void add2XML(XMLwrapper *xml, bool fmoscilused); + void getfromXML(XMLwrapper& xml, unsigned nvoice); + void add2XML(XMLwrapper& xml, bool fmoscilused); void paste(ADnoteVoiceParam &p); void defaults(void); void enable(const SYNTH_T &synth, FFTwrapper *fft, Resonance *Reson); @@ -306,8 +306,8 @@ class ADnoteParameters:public PresetsArray ADnoteVoiceParam VoicePar[NUM_VOICES]; void defaults(); - void add2XML(XMLwrapper *xml); - void getfromXML(XMLwrapper *xml); + void add2XML(XMLwrapper& xml); + void getfromXML(XMLwrapper& xml); void paste(ADnoteParameters &a); void pasteArray(ADnoteParameters &a, int section); @@ -317,8 +317,8 @@ class ADnoteParameters:public PresetsArray float getUnisonFrequencySpreadCents(int nvoice) const; static const rtosc::Ports &ports; void defaults(int n); //n is the nvoice - void add2XMLsection(XMLwrapper *xml, int n); - void getfromXMLsection(XMLwrapper *xml, int n); + void add2XMLsection(XMLwrapper& xml, int n); + void getfromXMLsection(XMLwrapper& xml, int n); private: void EnableVoice(const SYNTH_T &synth, int nvoice); diff --git a/source/native-plugins/zynaddsubfx/Params/Controller.cpp b/source/native-plugins/zynaddsubfx/Params/Controller.cpp index 0f998e6c6..421514718 100644 --- a/source/native-plugins/zynaddsubfx/Params/Controller.cpp +++ b/source/native-plugins/zynaddsubfx/Params/Controller.cpp @@ -384,90 +384,90 @@ void Controller::setparameternumber(unsigned int type, int value) -void Controller::add2XML(XMLwrapper *xml) +void Controller::add2XML(XMLwrapper& xml) { - xml->addpar("pitchwheel_bendrange", pitchwheel.bendrange); - xml->addpar("pitchwheel_bendrange_down", pitchwheel.bendrange_down); - xml->addparbool("pitchwheel_split", pitchwheel.is_split); - - xml->addparbool("expression_receive", expression.receive); - xml->addpar("panning_depth", panning.depth); - xml->addpar("filter_cutoff_depth", filtercutoff.depth); - xml->addpar("filter_q_depth", filterq.depth); - xml->addpar("bandwidth_depth", bandwidth.depth); - xml->addpar("mod_wheel_depth", modwheel.depth); - xml->addparbool("mod_wheel_exponential", modwheel.exponential); - xml->addparbool("fm_amp_receive", fmamp.receive); - xml->addparbool("volume_receive", volume.receive); - xml->addparbool("sustain_receive", sustain.receive); - - xml->addparbool("portamento_receive", portamento.receive); - xml->addpar("portamento_time", portamento.time); - xml->addpar("portamento_pitchthresh", portamento.pitchthresh); - xml->addpar("portamento_pitchthreshtype", portamento.pitchthreshtype); - xml->addpar("portamento_portamento", portamento.portamento); - xml->addpar("portamento_updowntimestretch", portamento.updowntimestretch); - xml->addpar("portamento_proportional", portamento.proportional); - xml->addpar("portamento_proprate", portamento.propRate); - xml->addpar("portamento_propdepth", portamento.propDepth); - - xml->addpar("resonance_center_depth", resonancecenter.depth); - xml->addpar("resonance_bandwidth_depth", resonancebandwidth.depth); + xml.addpar("pitchwheel_bendrange", pitchwheel.bendrange); + xml.addpar("pitchwheel_bendrange_down", pitchwheel.bendrange_down); + xml.addparbool("pitchwheel_split", pitchwheel.is_split); + + xml.addparbool("expression_receive", expression.receive); + xml.addpar("panning_depth", panning.depth); + xml.addpar("filter_cutoff_depth", filtercutoff.depth); + xml.addpar("filter_q_depth", filterq.depth); + xml.addpar("bandwidth_depth", bandwidth.depth); + xml.addpar("mod_wheel_depth", modwheel.depth); + xml.addparbool("mod_wheel_exponential", modwheel.exponential); + xml.addparbool("fm_amp_receive", fmamp.receive); + xml.addparbool("volume_receive", volume.receive); + xml.addparbool("sustain_receive", sustain.receive); + + xml.addparbool("portamento_receive", portamento.receive); + xml.addpar("portamento_time", portamento.time); + xml.addpar("portamento_pitchthresh", portamento.pitchthresh); + xml.addpar("portamento_pitchthreshtype", portamento.pitchthreshtype); + xml.addpar("portamento_portamento", portamento.portamento); + xml.addpar("portamento_updowntimestretch", portamento.updowntimestretch); + xml.addpar("portamento_proportional", portamento.proportional); + xml.addpar("portamento_proprate", portamento.propRate); + xml.addpar("portamento_propdepth", portamento.propDepth); + + xml.addpar("resonance_center_depth", resonancecenter.depth); + xml.addpar("resonance_bandwidth_depth", resonancebandwidth.depth); } -void Controller::getfromXML(XMLwrapper *xml) +void Controller::getfromXML(XMLwrapper& xml) { - pitchwheel.bendrange = xml->getpar("pitchwheel_bendrange", + pitchwheel.bendrange = xml.getpar("pitchwheel_bendrange", pitchwheel.bendrange, -6400, 6400); - pitchwheel.bendrange_down = xml->getpar("pitchwheel_bendrange_down", + pitchwheel.bendrange_down = xml.getpar("pitchwheel_bendrange_down", pitchwheel.bendrange_down, -6400, 6400); - pitchwheel.is_split = xml->getparbool("pitchwheel_split", + pitchwheel.is_split = xml.getparbool("pitchwheel_split", pitchwheel.is_split); - expression.receive = xml->getparbool("expression_receive", + expression.receive = xml.getparbool("expression_receive", expression.receive); - panning.depth = xml->getpar127("panning_depth", panning.depth); - filtercutoff.depth = xml->getpar127("filter_cutoff_depth", + panning.depth = xml.getpar127("panning_depth", panning.depth); + filtercutoff.depth = xml.getpar127("filter_cutoff_depth", filtercutoff.depth); - filterq.depth = xml->getpar127("filter_q_depth", filterq.depth); - bandwidth.depth = xml->getpar127("bandwidth_depth", bandwidth.depth); - modwheel.depth = xml->getpar127("mod_wheel_depth", modwheel.depth); - modwheel.exponential = xml->getparbool("mod_wheel_exponential", + filterq.depth = xml.getpar127("filter_q_depth", filterq.depth); + bandwidth.depth = xml.getpar127("bandwidth_depth", bandwidth.depth); + modwheel.depth = xml.getpar127("mod_wheel_depth", modwheel.depth); + modwheel.exponential = xml.getparbool("mod_wheel_exponential", modwheel.exponential); - fmamp.receive = xml->getparbool("fm_amp_receive", + fmamp.receive = xml.getparbool("fm_amp_receive", fmamp.receive); - volume.receive = xml->getparbool("volume_receive", + volume.receive = xml.getparbool("volume_receive", volume.receive); - sustain.receive = xml->getparbool("sustain_receive", + sustain.receive = xml.getparbool("sustain_receive", sustain.receive); - portamento.receive = xml->getparbool("portamento_receive", + portamento.receive = xml.getparbool("portamento_receive", portamento.receive); - portamento.time = xml->getpar127("portamento_time", + portamento.time = xml.getpar127("portamento_time", portamento.time); - portamento.pitchthresh = xml->getpar127("portamento_pitchthresh", + portamento.pitchthresh = xml.getpar127("portamento_pitchthresh", portamento.pitchthresh); - portamento.pitchthreshtype = xml->getpar127("portamento_pitchthreshtype", + portamento.pitchthreshtype = xml.getpar127("portamento_pitchthreshtype", portamento.pitchthreshtype); - portamento.portamento = xml->getpar127("portamento_portamento", + portamento.portamento = xml.getpar127("portamento_portamento", portamento.portamento); - portamento.updowntimestretch = xml->getpar127( + portamento.updowntimestretch = xml.getpar127( "portamento_updowntimestretch", portamento.updowntimestretch); - portamento.proportional = xml->getpar127("portamento_proportional", + portamento.proportional = xml.getpar127("portamento_proportional", portamento.proportional); - portamento.propRate = xml->getpar127("portamento_proprate", + portamento.propRate = xml.getpar127("portamento_proprate", portamento.propRate); - portamento.propDepth = xml->getpar127("portamento_propdepth", + portamento.propDepth = xml.getpar127("portamento_propdepth", portamento.propDepth); - resonancecenter.depth = xml->getpar127("resonance_center_depth", + resonancecenter.depth = xml.getpar127("resonance_center_depth", resonancecenter.depth); - resonancebandwidth.depth = xml->getpar127("resonance_bandwidth_depth", + resonancebandwidth.depth = xml.getpar127("resonance_bandwidth_depth", resonancebandwidth.depth); } diff --git a/source/native-plugins/zynaddsubfx/Params/Controller.h b/source/native-plugins/zynaddsubfx/Params/Controller.h index 77f3a33f5..0e7a8fbf6 100644 --- a/source/native-plugins/zynaddsubfx/Params/Controller.h +++ b/source/native-plugins/zynaddsubfx/Params/Controller.h @@ -35,9 +35,9 @@ class Controller ~Controller(); void resetall(); - void add2XML(XMLwrapper *xml); + void add2XML(XMLwrapper& xml); void defaults(); - void getfromXML(XMLwrapper *xml); + void getfromXML(XMLwrapper& xml); //Controllers functions void setpitchwheel(int value); diff --git a/source/native-plugins/zynaddsubfx/Params/EnvelopeParams.cpp b/source/native-plugins/zynaddsubfx/Params/EnvelopeParams.cpp index 6df860429..dd06b55dd 100644 --- a/source/native-plugins/zynaddsubfx/Params/EnvelopeParams.cpp +++ b/source/native-plugins/zynaddsubfx/Params/EnvelopeParams.cpp @@ -304,58 +304,58 @@ void EnvelopeParams::converttofree() -void EnvelopeParams::add2XML(XMLwrapper *xml) +void EnvelopeParams::add2XML(XMLwrapper& xml) { - xml->addparbool("free_mode", Pfreemode); - xml->addpar("env_points", Penvpoints); - xml->addpar("env_sustain", Penvsustain); - xml->addpar("env_stretch", Penvstretch); - xml->addparbool("forced_release", Pforcedrelease); - xml->addparbool("linear_envelope", Plinearenvelope); - xml->addpar("A_dt", PA_dt); - xml->addpar("D_dt", PD_dt); - xml->addpar("R_dt", PR_dt); - xml->addpar("A_val", PA_val); - xml->addpar("D_val", PD_val); - xml->addpar("S_val", PS_val); - xml->addpar("R_val", PR_val); - - if((Pfreemode != 0) || (!xml->minimal)) + xml.addparbool("free_mode", Pfreemode); + xml.addpar("env_points", Penvpoints); + xml.addpar("env_sustain", Penvsustain); + xml.addpar("env_stretch", Penvstretch); + xml.addparbool("forced_release", Pforcedrelease); + xml.addparbool("linear_envelope", Plinearenvelope); + xml.addpar("A_dt", PA_dt); + xml.addpar("D_dt", PD_dt); + xml.addpar("R_dt", PR_dt); + xml.addpar("A_val", PA_val); + xml.addpar("D_val", PD_val); + xml.addpar("S_val", PS_val); + xml.addpar("R_val", PR_val); + + if((Pfreemode != 0) || (!xml.minimal)) for(int i = 0; i < Penvpoints; ++i) { - xml->beginbranch("POINT", i); + xml.beginbranch("POINT", i); if(i != 0) - xml->addpar("dt", Penvdt[i]); - xml->addpar("val", Penvval[i]); - xml->endbranch(); + xml.addpar("dt", Penvdt[i]); + xml.addpar("val", Penvval[i]); + xml.endbranch(); } } -void EnvelopeParams::getfromXML(XMLwrapper *xml) +void EnvelopeParams::getfromXML(XMLwrapper& xml) { - Pfreemode = xml->getparbool("free_mode", Pfreemode); - Penvpoints = xml->getpar127("env_points", Penvpoints); - Penvsustain = xml->getpar127("env_sustain", Penvsustain); - Penvstretch = xml->getpar127("env_stretch", Penvstretch); - Pforcedrelease = xml->getparbool("forced_release", Pforcedrelease); - Plinearenvelope = xml->getparbool("linear_envelope", Plinearenvelope); - - PA_dt = xml->getpar127("A_dt", PA_dt); - PD_dt = xml->getpar127("D_dt", PD_dt); - PR_dt = xml->getpar127("R_dt", PR_dt); - PA_val = xml->getpar127("A_val", PA_val); - PD_val = xml->getpar127("D_val", PD_val); - PS_val = xml->getpar127("S_val", PS_val); - PR_val = xml->getpar127("R_val", PR_val); + Pfreemode = xml.getparbool("free_mode", Pfreemode); + Penvpoints = xml.getpar127("env_points", Penvpoints); + Penvsustain = xml.getpar127("env_sustain", Penvsustain); + Penvstretch = xml.getpar127("env_stretch", Penvstretch); + Pforcedrelease = xml.getparbool("forced_release", Pforcedrelease); + Plinearenvelope = xml.getparbool("linear_envelope", Plinearenvelope); + + PA_dt = xml.getpar127("A_dt", PA_dt); + PD_dt = xml.getpar127("D_dt", PD_dt); + PR_dt = xml.getpar127("R_dt", PR_dt); + PA_val = xml.getpar127("A_val", PA_val); + PD_val = xml.getpar127("D_val", PD_val); + PS_val = xml.getpar127("S_val", PS_val); + PR_val = xml.getpar127("R_val", PR_val); for(int i = 0; i < Penvpoints; ++i) { - if(xml->enterbranch("POINT", i) == 0) + if(xml.enterbranch("POINT", i) == 0) continue; if(i != 0) - Penvdt[i] = xml->getpar127("dt", Penvdt[i]); - Penvval[i] = xml->getpar127("val", Penvval[i]); - xml->exitbranch(); + Penvdt[i] = xml.getpar127("dt", Penvdt[i]); + Penvval[i] = xml.getpar127("val", Penvval[i]); + xml.exitbranch(); } if(!Pfreemode) diff --git a/source/native-plugins/zynaddsubfx/Params/EnvelopeParams.h b/source/native-plugins/zynaddsubfx/Params/EnvelopeParams.h index d6e65637c..7fbb1748c 100644 --- a/source/native-plugins/zynaddsubfx/Params/EnvelopeParams.h +++ b/source/native-plugins/zynaddsubfx/Params/EnvelopeParams.h @@ -46,9 +46,9 @@ class EnvelopeParams:public Presets void ASRinit_bw(char A_val, char A_dt, char R_val, char R_dt); void converttofree(); - void add2XML(XMLwrapper *xml); + void add2XML(XMLwrapper& xml); void defaults(); - void getfromXML(XMLwrapper *xml); + void getfromXML(XMLwrapper& xml); float getdt(char i) const; static float dt(char val); diff --git a/source/native-plugins/zynaddsubfx/Params/FilterParams.cpp b/source/native-plugins/zynaddsubfx/Params/FilterParams.cpp index 0af9dda05..9c5aa7fb1 100644 --- a/source/native-plugins/zynaddsubfx/Params/FilterParams.cpp +++ b/source/native-plugins/zynaddsubfx/Params/FilterParams.cpp @@ -309,114 +309,114 @@ float FilterParams::getformantq(unsigned char q) -void FilterParams::add2XMLsection(XMLwrapper *xml, int n) +void FilterParams::add2XMLsection(XMLwrapper& xml, int n) { int nvowel = n; for(int nformant = 0; nformant < FF_MAX_FORMANTS; ++nformant) { - xml->beginbranch("FORMANT", nformant); - xml->addpar("freq", Pvowels[nvowel].formants[nformant].freq); - xml->addpar("amp", Pvowels[nvowel].formants[nformant].amp); - xml->addpar("q", Pvowels[nvowel].formants[nformant].q); - xml->endbranch(); + xml.beginbranch("FORMANT", nformant); + xml.addpar("freq", Pvowels[nvowel].formants[nformant].freq); + xml.addpar("amp", Pvowels[nvowel].formants[nformant].amp); + xml.addpar("q", Pvowels[nvowel].formants[nformant].q); + xml.endbranch(); } } -void FilterParams::add2XML(XMLwrapper *xml) +void FilterParams::add2XML(XMLwrapper& xml) { //filter parameters - xml->addpar("category", Pcategory); - xml->addpar("type", Ptype); - xml->addpar("freq", Pfreq); - xml->addpar("q", Pq); - xml->addpar("stages", Pstages); - xml->addpar("freq_track", Pfreqtrack); - xml->addpar("gain", Pgain); + xml.addpar("category", Pcategory); + xml.addpar("type", Ptype); + xml.addpar("freq", Pfreq); + xml.addpar("q", Pq); + xml.addpar("stages", Pstages); + xml.addpar("freq_track", Pfreqtrack); + xml.addpar("gain", Pgain); //formant filter parameters - if((Pcategory == 1) || (!xml->minimal)) { - xml->beginbranch("FORMANT_FILTER"); - xml->addpar("num_formants", Pnumformants); - xml->addpar("formant_slowness", Pformantslowness); - xml->addpar("vowel_clearness", Pvowelclearness); - xml->addpar("center_freq", Pcenterfreq); - xml->addpar("octaves_freq", Poctavesfreq); + if((Pcategory == 1) || (!xml.minimal)) { + xml.beginbranch("FORMANT_FILTER"); + xml.addpar("num_formants", Pnumformants); + xml.addpar("formant_slowness", Pformantslowness); + xml.addpar("vowel_clearness", Pvowelclearness); + xml.addpar("center_freq", Pcenterfreq); + xml.addpar("octaves_freq", Poctavesfreq); for(int nvowel = 0; nvowel < FF_MAX_VOWELS; ++nvowel) { - xml->beginbranch("VOWEL", nvowel); + xml.beginbranch("VOWEL", nvowel); add2XMLsection(xml, nvowel); - xml->endbranch(); + xml.endbranch(); } - xml->addpar("sequence_size", Psequencesize); - xml->addpar("sequence_stretch", Psequencestretch); - xml->addparbool("sequence_reversed", Psequencereversed); + xml.addpar("sequence_size", Psequencesize); + xml.addpar("sequence_stretch", Psequencestretch); + xml.addparbool("sequence_reversed", Psequencereversed); for(int nseq = 0; nseq < FF_MAX_SEQUENCE; ++nseq) { - xml->beginbranch("SEQUENCE_POS", nseq); - xml->addpar("vowel_id", Psequence[nseq].nvowel); - xml->endbranch(); + xml.beginbranch("SEQUENCE_POS", nseq); + xml.addpar("vowel_id", Psequence[nseq].nvowel); + xml.endbranch(); } - xml->endbranch(); + xml.endbranch(); } } -void FilterParams::getfromXMLsection(XMLwrapper *xml, int n) +void FilterParams::getfromXMLsection(XMLwrapper& xml, int n) { int nvowel = n; for(int nformant = 0; nformant < FF_MAX_FORMANTS; ++nformant) { - if(xml->enterbranch("FORMANT", nformant) == 0) + if(xml.enterbranch("FORMANT", nformant) == 0) continue; - Pvowels[nvowel].formants[nformant].freq = xml->getpar127( + Pvowels[nvowel].formants[nformant].freq = xml.getpar127( "freq", Pvowels[nvowel ].formants[nformant].freq); - Pvowels[nvowel].formants[nformant].amp = xml->getpar127( + Pvowels[nvowel].formants[nformant].amp = xml.getpar127( "amp", Pvowels[nvowel ].formants[nformant].amp); Pvowels[nvowel].formants[nformant].q = - xml->getpar127("q", Pvowels[nvowel].formants[nformant].q); - xml->exitbranch(); + xml.getpar127("q", Pvowels[nvowel].formants[nformant].q); + xml.exitbranch(); } } -void FilterParams::getfromXML(XMLwrapper *xml) +void FilterParams::getfromXML(XMLwrapper& xml) { //filter parameters - Pcategory = xml->getpar127("category", Pcategory); - Ptype = xml->getpar127("type", Ptype); - Pfreq = xml->getpar127("freq", Pfreq); - Pq = xml->getpar127("q", Pq); - Pstages = xml->getpar127("stages", Pstages); - Pfreqtrack = xml->getpar127("freq_track", Pfreqtrack); - Pgain = xml->getpar127("gain", Pgain); + Pcategory = xml.getpar127("category", Pcategory); + Ptype = xml.getpar127("type", Ptype); + Pfreq = xml.getpar127("freq", Pfreq); + Pq = xml.getpar127("q", Pq); + Pstages = xml.getpar127("stages", Pstages); + Pfreqtrack = xml.getpar127("freq_track", Pfreqtrack); + Pgain = xml.getpar127("gain", Pgain); //formant filter parameters - if(xml->enterbranch("FORMANT_FILTER")) { - Pnumformants = xml->getpar127("num_formants", Pnumformants); - Pformantslowness = xml->getpar127("formant_slowness", Pformantslowness); - Pvowelclearness = xml->getpar127("vowel_clearness", Pvowelclearness); - Pcenterfreq = xml->getpar127("center_freq", Pcenterfreq); - Poctavesfreq = xml->getpar127("octaves_freq", Poctavesfreq); + if(xml.enterbranch("FORMANT_FILTER")) { + Pnumformants = xml.getpar127("num_formants", Pnumformants); + Pformantslowness = xml.getpar127("formant_slowness", Pformantslowness); + Pvowelclearness = xml.getpar127("vowel_clearness", Pvowelclearness); + Pcenterfreq = xml.getpar127("center_freq", Pcenterfreq); + Poctavesfreq = xml.getpar127("octaves_freq", Poctavesfreq); for(int nvowel = 0; nvowel < FF_MAX_VOWELS; ++nvowel) { - if(xml->enterbranch("VOWEL", nvowel) == 0) + if(xml.enterbranch("VOWEL", nvowel) == 0) continue; getfromXMLsection(xml, nvowel); - xml->exitbranch(); + xml.exitbranch(); } - Psequencesize = xml->getpar127("sequence_size", Psequencesize); - Psequencestretch = xml->getpar127("sequence_stretch", Psequencestretch); - Psequencereversed = xml->getparbool("sequence_reversed", + Psequencesize = xml.getpar127("sequence_size", Psequencesize); + Psequencestretch = xml.getpar127("sequence_stretch", Psequencestretch); + Psequencereversed = xml.getparbool("sequence_reversed", Psequencereversed); for(int nseq = 0; nseq < FF_MAX_SEQUENCE; ++nseq) { - if(xml->enterbranch("SEQUENCE_POS", nseq) == 0) + if(xml.enterbranch("SEQUENCE_POS", nseq) == 0) continue; - Psequence[nseq].nvowel = xml->getpar("vowel_id", + Psequence[nseq].nvowel = xml.getpar("vowel_id", Psequence[nseq].nvowel, 0, FF_MAX_VOWELS - 1); - xml->exitbranch(); + xml.exitbranch(); } - xml->exitbranch(); + xml.exitbranch(); } } diff --git a/source/native-plugins/zynaddsubfx/Params/FilterParams.h b/source/native-plugins/zynaddsubfx/Params/FilterParams.h index 67867aff8..2fdbe889f 100644 --- a/source/native-plugins/zynaddsubfx/Params/FilterParams.h +++ b/source/native-plugins/zynaddsubfx/Params/FilterParams.h @@ -36,11 +36,11 @@ class FilterParams:public PresetsArray unsigned char Pq_); ~FilterParams(); - void add2XML(XMLwrapper *xml); - void add2XMLsection(XMLwrapper *xml, int n); + void add2XML(XMLwrapper& xml); + void add2XMLsection(XMLwrapper& xml, int n); void defaults(); - void getfromXML(XMLwrapper *xml); - void getfromXMLsection(XMLwrapper *xml, int n); + void getfromXML(XMLwrapper& xml); + void getfromXMLsection(XMLwrapper& xml, int n); void paste(FilterParams &); void pasteArray(FilterParams &, int section); diff --git a/source/native-plugins/zynaddsubfx/Params/LFOParams.cpp b/source/native-plugins/zynaddsubfx/Params/LFOParams.cpp index b35cfb9e3..225a1d0a0 100644 --- a/source/native-plugins/zynaddsubfx/Params/LFOParams.cpp +++ b/source/native-plugins/zynaddsubfx/Params/LFOParams.cpp @@ -116,30 +116,30 @@ void LFOParams::defaults() } -void LFOParams::add2XML(XMLwrapper *xml) +void LFOParams::add2XML(XMLwrapper& xml) { - xml->addparreal("freq", Pfreq); - xml->addpar("intensity", Pintensity); - xml->addpar("start_phase", Pstartphase); - xml->addpar("lfo_type", PLFOtype); - xml->addpar("randomness_amplitude", Prandomness); - xml->addpar("randomness_frequency", Pfreqrand); - xml->addpar("delay", Pdelay); - xml->addpar("stretch", Pstretch); - xml->addparbool("continous", Pcontinous); + xml.addparreal("freq", Pfreq); + xml.addpar("intensity", Pintensity); + xml.addpar("start_phase", Pstartphase); + xml.addpar("lfo_type", PLFOtype); + xml.addpar("randomness_amplitude", Prandomness); + xml.addpar("randomness_frequency", Pfreqrand); + xml.addpar("delay", Pdelay); + xml.addpar("stretch", Pstretch); + xml.addparbool("continous", Pcontinous); } -void LFOParams::getfromXML(XMLwrapper *xml) +void LFOParams::getfromXML(XMLwrapper& xml) { - Pfreq = xml->getparreal("freq", Pfreq, 0.0f, 1.0f); - Pintensity = xml->getpar127("intensity", Pintensity); - Pstartphase = xml->getpar127("start_phase", Pstartphase); - PLFOtype = xml->getpar127("lfo_type", PLFOtype); - Prandomness = xml->getpar127("randomness_amplitude", Prandomness); - Pfreqrand = xml->getpar127("randomness_frequency", Pfreqrand); - Pdelay = xml->getpar127("delay", Pdelay); - Pstretch = xml->getpar127("stretch", Pstretch); - Pcontinous = xml->getparbool("continous", Pcontinous); + Pfreq = xml.getparreal("freq", Pfreq, 0.0f, 1.0f); + Pintensity = xml.getpar127("intensity", Pintensity); + Pstartphase = xml.getpar127("start_phase", Pstartphase); + PLFOtype = xml.getpar127("lfo_type", PLFOtype); + Prandomness = xml.getpar127("randomness_amplitude", Prandomness); + Pfreqrand = xml.getpar127("randomness_frequency", Pfreqrand); + Pdelay = xml.getpar127("delay", Pdelay); + Pstretch = xml.getpar127("stretch", Pstretch); + Pcontinous = xml.getparbool("continous", Pcontinous); } #define COPY(y) this->y=x.y diff --git a/source/native-plugins/zynaddsubfx/Params/LFOParams.h b/source/native-plugins/zynaddsubfx/Params/LFOParams.h index 08e5aa43e..565edd915 100644 --- a/source/native-plugins/zynaddsubfx/Params/LFOParams.h +++ b/source/native-plugins/zynaddsubfx/Params/LFOParams.h @@ -50,10 +50,10 @@ class LFOParams:public Presets char fel_); ~LFOParams(); - void add2XML(XMLwrapper *xml); + void add2XML(XMLwrapper& xml); void defaults(); /**Loads the LFO from the xml*/ - void getfromXML(XMLwrapper *xml); + void getfromXML(XMLwrapper& xml); void paste(LFOParams &); /* MIDI Parameters*/ diff --git a/source/native-plugins/zynaddsubfx/Params/PADnoteParameters.cpp b/source/native-plugins/zynaddsubfx/Params/PADnoteParameters.cpp index 575a8b63d..62d30ab50 100644 --- a/source/native-plugins/zynaddsubfx/Params/PADnoteParameters.cpp +++ b/source/native-plugins/zynaddsubfx/Params/PADnoteParameters.cpp @@ -35,7 +35,7 @@ using namespace rtosc; #define rObject PADnoteParameters -static const rtosc::Ports realtime_ports = +static const rtosc::Ports realtime_ports = { rRecurp(FreqLfo, "Frequency LFO"), rRecurp(AmpLfo, "Amplitude LFO"), @@ -119,10 +119,24 @@ static const rtosc::Ports realtime_ports = obj->PCoarseDetune = k + (obj->PCoarseDetune/1024)*1024; } }}, + {"paste:b", rProp(internal) rDoc("paste port"), 0, + [](const char *m, rtosc::RtData &d){ + rObject &paste = **(rObject **)rtosc_argument(m,0).b.data; + rObject &o = *(rObject*)d.obj; + o.pasteRT(paste);}} }; static const rtosc::Ports non_realtime_ports = { + rSelf(PADnoteParameters), + rPresetType, + {"paste:b", rProp(internal) rDoc("paste port"), 0, + [](const char *m, rtosc::RtData &d){ + rObject &paste = **(rObject **)rtosc_argument(m,0).b.data; + rObject &o = *(rObject*)d.obj; + o.paste(paste); + //avoid the match to forward the request along + d.matches--;}}, //Harmonic Source Distribution rRecurp(oscilgen, "Oscillator"), rRecurp(resonance, "Resonance"), @@ -227,8 +241,8 @@ const rtosc::Ports &PADnoteParameters::realtime_ports = ::realtime_ports; const rtosc::MergePorts PADnoteParameters::ports = { - &non_realtime_ports, - &realtime_ports + &realtime_ports, + &non_realtime_ports }; @@ -901,221 +915,294 @@ void PADnoteParameters::export2wav(std::string basefilename) } } -void PADnoteParameters::add2XML(XMLwrapper *xml) +void PADnoteParameters::add2XML(XMLwrapper& xml) { - xml->setPadSynth(true); - - xml->addparbool("stereo", PStereo); - xml->addpar("mode", Pmode); - xml->addpar("bandwidth", Pbandwidth); - xml->addpar("bandwidth_scale", Pbwscale); - - xml->beginbranch("HARMONIC_PROFILE"); - xml->addpar("base_type", Php.base.type); - xml->addpar("base_par1", Php.base.par1); - xml->addpar("frequency_multiplier", Php.freqmult); - xml->addpar("modulator_par1", Php.modulator.par1); - xml->addpar("modulator_frequency", Php.modulator.freq); - xml->addpar("width", Php.width); - xml->addpar("amplitude_multiplier_type", Php.amp.type); - xml->addpar("amplitude_multiplier_mode", Php.amp.mode); - xml->addpar("amplitude_multiplier_par1", Php.amp.par1); - xml->addpar("amplitude_multiplier_par2", Php.amp.par2); - xml->addparbool("autoscale", Php.autoscale); - xml->addpar("one_half", Php.onehalf); - xml->endbranch(); - - xml->beginbranch("OSCIL"); + xml.setPadSynth(true); + + xml.addparbool("stereo", PStereo); + xml.addpar("mode", Pmode); + xml.addpar("bandwidth", Pbandwidth); + xml.addpar("bandwidth_scale", Pbwscale); + + xml.beginbranch("HARMONIC_PROFILE"); + xml.addpar("base_type", Php.base.type); + xml.addpar("base_par1", Php.base.par1); + xml.addpar("frequency_multiplier", Php.freqmult); + xml.addpar("modulator_par1", Php.modulator.par1); + xml.addpar("modulator_frequency", Php.modulator.freq); + xml.addpar("width", Php.width); + xml.addpar("amplitude_multiplier_type", Php.amp.type); + xml.addpar("amplitude_multiplier_mode", Php.amp.mode); + xml.addpar("amplitude_multiplier_par1", Php.amp.par1); + xml.addpar("amplitude_multiplier_par2", Php.amp.par2); + xml.addparbool("autoscale", Php.autoscale); + xml.addpar("one_half", Php.onehalf); + xml.endbranch(); + + xml.beginbranch("OSCIL"); oscilgen->add2XML(xml); - xml->endbranch(); + xml.endbranch(); - xml->beginbranch("RESONANCE"); + xml.beginbranch("RESONANCE"); resonance->add2XML(xml); - xml->endbranch(); - - xml->beginbranch("HARMONIC_POSITION"); - xml->addpar("type", Phrpos.type); - xml->addpar("parameter1", Phrpos.par1); - xml->addpar("parameter2", Phrpos.par2); - xml->addpar("parameter3", Phrpos.par3); - xml->endbranch(); - - xml->beginbranch("SAMPLE_QUALITY"); - xml->addpar("samplesize", Pquality.samplesize); - xml->addpar("basenote", Pquality.basenote); - xml->addpar("octaves", Pquality.oct); - xml->addpar("samples_per_octave", Pquality.smpoct); - xml->endbranch(); - - xml->beginbranch("AMPLITUDE_PARAMETERS"); - xml->addpar("volume", PVolume); - xml->addpar("panning", PPanning); - xml->addpar("velocity_sensing", PAmpVelocityScaleFunction); - xml->addpar("fadein_adjustment", Fadein_adjustment); - xml->addpar("punch_strength", PPunchStrength); - xml->addpar("punch_time", PPunchTime); - xml->addpar("punch_stretch", PPunchStretch); - xml->addpar("punch_velocity_sensing", PPunchVelocitySensing); - - xml->beginbranch("AMPLITUDE_ENVELOPE"); + xml.endbranch(); + + xml.beginbranch("HARMONIC_POSITION"); + xml.addpar("type", Phrpos.type); + xml.addpar("parameter1", Phrpos.par1); + xml.addpar("parameter2", Phrpos.par2); + xml.addpar("parameter3", Phrpos.par3); + xml.endbranch(); + + xml.beginbranch("SAMPLE_QUALITY"); + xml.addpar("samplesize", Pquality.samplesize); + xml.addpar("basenote", Pquality.basenote); + xml.addpar("octaves", Pquality.oct); + xml.addpar("samples_per_octave", Pquality.smpoct); + xml.endbranch(); + + xml.beginbranch("AMPLITUDE_PARAMETERS"); + xml.addpar("volume", PVolume); + xml.addpar("panning", PPanning); + xml.addpar("velocity_sensing", PAmpVelocityScaleFunction); + xml.addpar("fadein_adjustment", Fadein_adjustment); + xml.addpar("punch_strength", PPunchStrength); + xml.addpar("punch_time", PPunchTime); + xml.addpar("punch_stretch", PPunchStretch); + xml.addpar("punch_velocity_sensing", PPunchVelocitySensing); + + xml.beginbranch("AMPLITUDE_ENVELOPE"); AmpEnvelope->add2XML(xml); - xml->endbranch(); + xml.endbranch(); - xml->beginbranch("AMPLITUDE_LFO"); + xml.beginbranch("AMPLITUDE_LFO"); AmpLfo->add2XML(xml); - xml->endbranch(); + xml.endbranch(); - xml->endbranch(); + xml.endbranch(); - xml->beginbranch("FREQUENCY_PARAMETERS"); - xml->addpar("fixed_freq", Pfixedfreq); - xml->addpar("fixed_freq_et", PfixedfreqET); - xml->addpar("detune", PDetune); - xml->addpar("coarse_detune", PCoarseDetune); - xml->addpar("detune_type", PDetuneType); + xml.beginbranch("FREQUENCY_PARAMETERS"); + xml.addpar("fixed_freq", Pfixedfreq); + xml.addpar("fixed_freq_et", PfixedfreqET); + xml.addpar("detune", PDetune); + xml.addpar("coarse_detune", PCoarseDetune); + xml.addpar("detune_type", PDetuneType); - xml->beginbranch("FREQUENCY_ENVELOPE"); + xml.beginbranch("FREQUENCY_ENVELOPE"); FreqEnvelope->add2XML(xml); - xml->endbranch(); + xml.endbranch(); - xml->beginbranch("FREQUENCY_LFO"); + xml.beginbranch("FREQUENCY_LFO"); FreqLfo->add2XML(xml); - xml->endbranch(); - xml->endbranch(); + xml.endbranch(); + xml.endbranch(); - xml->beginbranch("FILTER_PARAMETERS"); - xml->addpar("velocity_sensing_amplitude", PFilterVelocityScale); - xml->addpar("velocity_sensing", PFilterVelocityScaleFunction); + xml.beginbranch("FILTER_PARAMETERS"); + xml.addpar("velocity_sensing_amplitude", PFilterVelocityScale); + xml.addpar("velocity_sensing", PFilterVelocityScaleFunction); - xml->beginbranch("FILTER"); + xml.beginbranch("FILTER"); GlobalFilter->add2XML(xml); - xml->endbranch(); + xml.endbranch(); - xml->beginbranch("FILTER_ENVELOPE"); + xml.beginbranch("FILTER_ENVELOPE"); FilterEnvelope->add2XML(xml); - xml->endbranch(); + xml.endbranch(); - xml->beginbranch("FILTER_LFO"); + xml.beginbranch("FILTER_LFO"); FilterLfo->add2XML(xml); - xml->endbranch(); - xml->endbranch(); + xml.endbranch(); + xml.endbranch(); } -void PADnoteParameters::getfromXML(XMLwrapper *xml) +void PADnoteParameters::getfromXML(XMLwrapper& xml) { - PStereo = xml->getparbool("stereo", PStereo); - Pmode = xml->getpar127("mode", 0); - Pbandwidth = xml->getpar("bandwidth", Pbandwidth, 0, 1000); - Pbwscale = xml->getpar127("bandwidth_scale", Pbwscale); - - if(xml->enterbranch("HARMONIC_PROFILE")) { - Php.base.type = xml->getpar127("base_type", Php.base.type); - Php.base.par1 = xml->getpar127("base_par1", Php.base.par1); - Php.freqmult = xml->getpar127("frequency_multiplier", + PStereo = xml.getparbool("stereo", PStereo); + Pmode = xml.getpar127("mode", 0); + Pbandwidth = xml.getpar("bandwidth", Pbandwidth, 0, 1000); + Pbwscale = xml.getpar127("bandwidth_scale", Pbwscale); + + if(xml.enterbranch("HARMONIC_PROFILE")) { + Php.base.type = xml.getpar127("base_type", Php.base.type); + Php.base.par1 = xml.getpar127("base_par1", Php.base.par1); + Php.freqmult = xml.getpar127("frequency_multiplier", Php.freqmult); - Php.modulator.par1 = xml->getpar127("modulator_par1", + Php.modulator.par1 = xml.getpar127("modulator_par1", Php.modulator.par1); - Php.modulator.freq = xml->getpar127("modulator_frequency", + Php.modulator.freq = xml.getpar127("modulator_frequency", Php.modulator.freq); - Php.width = xml->getpar127("width", Php.width); - Php.amp.type = xml->getpar127("amplitude_multiplier_type", + Php.width = xml.getpar127("width", Php.width); + Php.amp.type = xml.getpar127("amplitude_multiplier_type", Php.amp.type); - Php.amp.mode = xml->getpar127("amplitude_multiplier_mode", + Php.amp.mode = xml.getpar127("amplitude_multiplier_mode", Php.amp.mode); - Php.amp.par1 = xml->getpar127("amplitude_multiplier_par1", + Php.amp.par1 = xml.getpar127("amplitude_multiplier_par1", Php.amp.par1); - Php.amp.par2 = xml->getpar127("amplitude_multiplier_par2", + Php.amp.par2 = xml.getpar127("amplitude_multiplier_par2", Php.amp.par2); - Php.autoscale = xml->getparbool("autoscale", Php.autoscale); - Php.onehalf = xml->getpar127("one_half", Php.onehalf); - xml->exitbranch(); + Php.autoscale = xml.getparbool("autoscale", Php.autoscale); + Php.onehalf = xml.getpar127("one_half", Php.onehalf); + xml.exitbranch(); } - if(xml->enterbranch("OSCIL")) { + if(xml.enterbranch("OSCIL")) { oscilgen->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); } - if(xml->enterbranch("RESONANCE")) { + if(xml.enterbranch("RESONANCE")) { resonance->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); } - if(xml->enterbranch("HARMONIC_POSITION")) { - Phrpos.type = xml->getpar127("type", Phrpos.type); - Phrpos.par1 = xml->getpar("parameter1", Phrpos.par1, 0, 255); - Phrpos.par2 = xml->getpar("parameter2", Phrpos.par2, 0, 255); - Phrpos.par3 = xml->getpar("parameter3", Phrpos.par3, 0, 255); - xml->exitbranch(); + if(xml.enterbranch("HARMONIC_POSITION")) { + Phrpos.type = xml.getpar127("type", Phrpos.type); + Phrpos.par1 = xml.getpar("parameter1", Phrpos.par1, 0, 255); + Phrpos.par2 = xml.getpar("parameter2", Phrpos.par2, 0, 255); + Phrpos.par3 = xml.getpar("parameter3", Phrpos.par3, 0, 255); + xml.exitbranch(); } - if(xml->enterbranch("SAMPLE_QUALITY")) { - Pquality.samplesize = xml->getpar127("samplesize", Pquality.samplesize); - Pquality.basenote = xml->getpar127("basenote", Pquality.basenote); - Pquality.oct = xml->getpar127("octaves", Pquality.oct); - Pquality.smpoct = xml->getpar127("samples_per_octave", + if(xml.enterbranch("SAMPLE_QUALITY")) { + Pquality.samplesize = xml.getpar127("samplesize", Pquality.samplesize); + Pquality.basenote = xml.getpar127("basenote", Pquality.basenote); + Pquality.oct = xml.getpar127("octaves", Pquality.oct); + Pquality.smpoct = xml.getpar127("samples_per_octave", Pquality.smpoct); - xml->exitbranch(); + xml.exitbranch(); } - if(xml->enterbranch("AMPLITUDE_PARAMETERS")) { - PVolume = xml->getpar127("volume", PVolume); - PPanning = xml->getpar127("panning", PPanning); - PAmpVelocityScaleFunction = xml->getpar127("velocity_sensing", + if(xml.enterbranch("AMPLITUDE_PARAMETERS")) { + PVolume = xml.getpar127("volume", PVolume); + PPanning = xml.getpar127("panning", PPanning); + PAmpVelocityScaleFunction = xml.getpar127("velocity_sensing", PAmpVelocityScaleFunction); - Fadein_adjustment = xml->getpar127("fadein_adjustment", Fadein_adjustment); - PPunchStrength = xml->getpar127("punch_strength", PPunchStrength); - PPunchTime = xml->getpar127("punch_time", PPunchTime); - PPunchStretch = xml->getpar127("punch_stretch", PPunchStretch); - PPunchVelocitySensing = xml->getpar127("punch_velocity_sensing", + Fadein_adjustment = xml.getpar127("fadein_adjustment", Fadein_adjustment); + PPunchStrength = xml.getpar127("punch_strength", PPunchStrength); + PPunchTime = xml.getpar127("punch_time", PPunchTime); + PPunchStretch = xml.getpar127("punch_stretch", PPunchStretch); + PPunchVelocitySensing = xml.getpar127("punch_velocity_sensing", PPunchVelocitySensing); - xml->enterbranch("AMPLITUDE_ENVELOPE"); + xml.enterbranch("AMPLITUDE_ENVELOPE"); AmpEnvelope->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); - xml->enterbranch("AMPLITUDE_LFO"); + xml.enterbranch("AMPLITUDE_LFO"); AmpLfo->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); - xml->exitbranch(); + xml.exitbranch(); } - if(xml->enterbranch("FREQUENCY_PARAMETERS")) { - Pfixedfreq = xml->getpar127("fixed_freq", Pfixedfreq); - PfixedfreqET = xml->getpar127("fixed_freq_et", PfixedfreqET); - PDetune = xml->getpar("detune", PDetune, 0, 16383); - PCoarseDetune = xml->getpar("coarse_detune", PCoarseDetune, 0, 16383); - PDetuneType = xml->getpar127("detune_type", PDetuneType); + if(xml.enterbranch("FREQUENCY_PARAMETERS")) { + Pfixedfreq = xml.getpar127("fixed_freq", Pfixedfreq); + PfixedfreqET = xml.getpar127("fixed_freq_et", PfixedfreqET); + PDetune = xml.getpar("detune", PDetune, 0, 16383); + PCoarseDetune = xml.getpar("coarse_detune", PCoarseDetune, 0, 16383); + PDetuneType = xml.getpar127("detune_type", PDetuneType); - xml->enterbranch("FREQUENCY_ENVELOPE"); + xml.enterbranch("FREQUENCY_ENVELOPE"); FreqEnvelope->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); - xml->enterbranch("FREQUENCY_LFO"); + xml.enterbranch("FREQUENCY_LFO"); FreqLfo->getfromXML(xml); - xml->exitbranch(); - xml->exitbranch(); + xml.exitbranch(); + xml.exitbranch(); } - if(xml->enterbranch("FILTER_PARAMETERS")) { - PFilterVelocityScale = xml->getpar127("velocity_sensing_amplitude", + if(xml.enterbranch("FILTER_PARAMETERS")) { + PFilterVelocityScale = xml.getpar127("velocity_sensing_amplitude", PFilterVelocityScale); - PFilterVelocityScaleFunction = xml->getpar127( + PFilterVelocityScaleFunction = xml.getpar127( "velocity_sensing", PFilterVelocityScaleFunction); - xml->enterbranch("FILTER"); + xml.enterbranch("FILTER"); GlobalFilter->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); - xml->enterbranch("FILTER_ENVELOPE"); + xml.enterbranch("FILTER_ENVELOPE"); FilterEnvelope->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); - xml->enterbranch("FILTER_LFO"); + xml.enterbranch("FILTER_LFO"); FilterLfo->getfromXML(xml); - xml->exitbranch(); - xml->exitbranch(); + xml.exitbranch(); + xml.exitbranch(); } } + +#define COPY(y) this->y = x.y +void PADnoteParameters::paste(PADnoteParameters &x) +{ + COPY(Pmode); + + COPY(Php.base.type); + COPY(Php.base.par1); + COPY(Php.freqmult); + COPY(Php.modulator.par1); + COPY(Php.modulator.freq); + COPY(Php.width); + COPY(Php.amp.mode); + COPY(Php.amp.type); + COPY(Php.amp.par1); + COPY(Php.amp.par2); + COPY(Php.autoscale); + COPY(Php.onehalf); + + COPY(Pbandwidth); + COPY(Pbwscale); + + COPY(Phrpos.type); + COPY(Phrpos.par1); + COPY(Phrpos.par2); + COPY(Phrpos.par3); + + COPY(Pquality.samplesize); + COPY(Pquality.basenote); + COPY(Pquality.oct); + COPY(Pquality.smpoct); + + oscilgen->paste(*x.oscilgen); + resonance->paste(*x.resonance); +} + +void PADnoteParameters::pasteRT(PADnoteParameters &x) +{ + //Realtime stuff + + COPY(Pfixedfreq); + + COPY(PfixedfreqET); + COPY(PDetune); + COPY(PCoarseDetune); + COPY(PDetuneType); + + FreqEnvelope->paste(*x.FreqEnvelope); + FreqLfo->paste(*x.FreqLfo); + + COPY(PStereo); + COPY(PPanning); + COPY(PVolume); + COPY(PAmpVelocityScaleFunction); + + AmpEnvelope->paste(*x.AmpEnvelope); + AmpLfo->paste(*x.AmpLfo); + + COPY(Fadein_adjustment); + COPY(PPunchStrength); + COPY(PPunchTime); + COPY(PPunchStretch); + COPY(PPunchVelocitySensing); + + GlobalFilter->paste(*x.GlobalFilter); + + COPY(PFilterVelocityScale); + COPY(PFilterVelocityScaleFunction); + + FilterEnvelope->paste(*x.FilterEnvelope); + FilterLfo->paste(*x.FilterLfo); +} +#undef COPY diff --git a/source/native-plugins/zynaddsubfx/Params/PADnoteParameters.h b/source/native-plugins/zynaddsubfx/Params/PADnoteParameters.h index c5e9ac73d..9bae972e9 100644 --- a/source/native-plugins/zynaddsubfx/Params/PADnoteParameters.h +++ b/source/native-plugins/zynaddsubfx/Params/PADnoteParameters.h @@ -46,8 +46,11 @@ class PADnoteParameters:public Presets ~PADnoteParameters(); void defaults(); - void add2XML(XMLwrapper *xml); - void getfromXML(XMLwrapper *xml); + void add2XML(XMLwrapper& xml); + void getfromXML(XMLwrapper& xml); + + void paste(PADnoteParameters &p); + void pasteRT(PADnoteParameters &p); //returns a value between 0.0f-1.0f that represents the estimation perceived bandwidth float getprofile(float *smp, int size); diff --git a/source/native-plugins/zynaddsubfx/Params/Presets.cpp b/source/native-plugins/zynaddsubfx/Params/Presets.cpp index 8e05cc63b..7df2efe4e 100644 --- a/source/native-plugins/zynaddsubfx/Params/Presets.cpp +++ b/source/native-plugins/zynaddsubfx/Params/Presets.cpp @@ -55,7 +55,7 @@ void Presets::copy(PresetsStore &ps, const char *name) strcpy(type, "Plfo"); xml.beginbranch(type); - add2XML(&xml); + add2XML(xml); xml.endbranch(); if(name == NULL) diff --git a/source/native-plugins/zynaddsubfx/Params/Presets.h b/source/native-plugins/zynaddsubfx/Params/Presets.h index 7dcd8f7b6..b1401d1d9 100644 --- a/source/native-plugins/zynaddsubfx/Params/Presets.h +++ b/source/native-plugins/zynaddsubfx/Params/Presets.h @@ -44,7 +44,7 @@ class Presets protected: void setpresettype(const char *type); private: - virtual void add2XML(XMLwrapper *xml) = 0; + virtual void add2XML(XMLwrapper& xml) = 0; //virtual void getfromXML(XMLwrapper *xml) = 0; //virtual void defaults() = 0; }; diff --git a/source/native-plugins/zynaddsubfx/Params/PresetsArray.cpp b/source/native-plugins/zynaddsubfx/Params/PresetsArray.cpp index 0f494f9f8..9583679d4 100644 --- a/source/native-plugins/zynaddsubfx/Params/PresetsArray.cpp +++ b/source/native-plugins/zynaddsubfx/Params/PresetsArray.cpp @@ -61,9 +61,9 @@ void PresetsArray::copy(PresetsStore &ps, int nelement, const char *name) xml.beginbranch(type); if(nelement == -1) - add2XML(&xml); + add2XML(xml); else - add2XMLsection(&xml, nelement); + add2XMLsection(xml, nelement); xml.endbranch(); if(name == NULL) diff --git a/source/native-plugins/zynaddsubfx/Params/PresetsArray.h b/source/native-plugins/zynaddsubfx/Params/PresetsArray.h index 5134340ae..cce1604c4 100644 --- a/source/native-plugins/zynaddsubfx/Params/PresetsArray.h +++ b/source/native-plugins/zynaddsubfx/Params/PresetsArray.h @@ -42,7 +42,7 @@ class PresetsArray:public Presets protected: void setpresettype(const char *type); private: - virtual void add2XMLsection(XMLwrapper *xml, int n) = 0; + virtual void add2XMLsection(XMLwrapper& xml, int n) = 0; //virtual void getfromXMLsection(XMLwrapper *xml, int n) = 0; //virtual void defaults() = 0; //virtual void defaults(int n) = 0; diff --git a/source/native-plugins/zynaddsubfx/Params/SUBnoteParameters.cpp b/source/native-plugins/zynaddsubfx/Params/SUBnoteParameters.cpp index 91b3ead12..3fc4aea00 100644 --- a/source/native-plugins/zynaddsubfx/Params/SUBnoteParameters.cpp +++ b/source/native-plugins/zynaddsubfx/Params/SUBnoteParameters.cpp @@ -202,80 +202,80 @@ SUBnoteParameters::~SUBnoteParameters() -void SUBnoteParameters::add2XML(XMLwrapper *xml) +void SUBnoteParameters::add2XML(XMLwrapper& xml) { - xml->addpar("num_stages", Pnumstages); - xml->addpar("harmonic_mag_type", Phmagtype); - xml->addpar("start", Pstart); + xml.addpar("num_stages", Pnumstages); + xml.addpar("harmonic_mag_type", Phmagtype); + xml.addpar("start", Pstart); - xml->beginbranch("HARMONICS"); + xml.beginbranch("HARMONICS"); for(int i = 0; i < MAX_SUB_HARMONICS; ++i) { - if((Phmag[i] == 0) && (xml->minimal)) + if((Phmag[i] == 0) && (xml.minimal)) continue; - xml->beginbranch("HARMONIC", i); - xml->addpar("mag", Phmag[i]); - xml->addpar("relbw", Phrelbw[i]); - xml->endbranch(); + xml.beginbranch("HARMONIC", i); + xml.addpar("mag", Phmag[i]); + xml.addpar("relbw", Phrelbw[i]); + xml.endbranch(); } - xml->endbranch(); - - xml->beginbranch("AMPLITUDE_PARAMETERS"); - xml->addparbool("stereo", Pstereo); - xml->addpar("volume", PVolume); - xml->addpar("panning", PPanning); - xml->addpar("velocity_sensing", PAmpVelocityScaleFunction); - xml->beginbranch("AMPLITUDE_ENVELOPE"); + xml.endbranch(); + + xml.beginbranch("AMPLITUDE_PARAMETERS"); + xml.addparbool("stereo", Pstereo); + xml.addpar("volume", PVolume); + xml.addpar("panning", PPanning); + xml.addpar("velocity_sensing", PAmpVelocityScaleFunction); + xml.beginbranch("AMPLITUDE_ENVELOPE"); AmpEnvelope->add2XML(xml); - xml->endbranch(); - xml->endbranch(); - - xml->beginbranch("FREQUENCY_PARAMETERS"); - xml->addparbool("fixed_freq", Pfixedfreq); - xml->addpar("fixed_freq_et", PfixedfreqET); - - xml->addpar("detune", PDetune); - xml->addpar("coarse_detune", PCoarseDetune); - xml->addpar("overtone_spread_type", POvertoneSpread.type); - xml->addpar("overtone_spread_par1", POvertoneSpread.par1); - xml->addpar("overtone_spread_par2", POvertoneSpread.par2); - xml->addpar("overtone_spread_par3", POvertoneSpread.par3); - xml->addpar("detune_type", PDetuneType); - - xml->addpar("bandwidth", Pbandwidth); - xml->addpar("bandwidth_scale", Pbwscale); - - xml->addparbool("freq_envelope_enabled", PFreqEnvelopeEnabled); - if((PFreqEnvelopeEnabled != 0) || (!xml->minimal)) { - xml->beginbranch("FREQUENCY_ENVELOPE"); + xml.endbranch(); + xml.endbranch(); + + xml.beginbranch("FREQUENCY_PARAMETERS"); + xml.addparbool("fixed_freq", Pfixedfreq); + xml.addpar("fixed_freq_et", PfixedfreqET); + + xml.addpar("detune", PDetune); + xml.addpar("coarse_detune", PCoarseDetune); + xml.addpar("overtone_spread_type", POvertoneSpread.type); + xml.addpar("overtone_spread_par1", POvertoneSpread.par1); + xml.addpar("overtone_spread_par2", POvertoneSpread.par2); + xml.addpar("overtone_spread_par3", POvertoneSpread.par3); + xml.addpar("detune_type", PDetuneType); + + xml.addpar("bandwidth", Pbandwidth); + xml.addpar("bandwidth_scale", Pbwscale); + + xml.addparbool("freq_envelope_enabled", PFreqEnvelopeEnabled); + if((PFreqEnvelopeEnabled != 0) || (!xml.minimal)) { + xml.beginbranch("FREQUENCY_ENVELOPE"); FreqEnvelope->add2XML(xml); - xml->endbranch(); + xml.endbranch(); } - xml->addparbool("band_width_envelope_enabled", PBandWidthEnvelopeEnabled); - if((PBandWidthEnvelopeEnabled != 0) || (!xml->minimal)) { - xml->beginbranch("BANDWIDTH_ENVELOPE"); + xml.addparbool("band_width_envelope_enabled", PBandWidthEnvelopeEnabled); + if((PBandWidthEnvelopeEnabled != 0) || (!xml.minimal)) { + xml.beginbranch("BANDWIDTH_ENVELOPE"); BandWidthEnvelope->add2XML(xml); - xml->endbranch(); + xml.endbranch(); } - xml->endbranch(); + xml.endbranch(); - xml->beginbranch("FILTER_PARAMETERS"); - xml->addparbool("enabled", PGlobalFilterEnabled); - if((PGlobalFilterEnabled != 0) || (!xml->minimal)) { - xml->beginbranch("FILTER"); + xml.beginbranch("FILTER_PARAMETERS"); + xml.addparbool("enabled", PGlobalFilterEnabled); + if((PGlobalFilterEnabled != 0) || (!xml.minimal)) { + xml.beginbranch("FILTER"); GlobalFilter->add2XML(xml); - xml->endbranch(); + xml.endbranch(); - xml->addpar("filter_velocity_sensing", + xml.addpar("filter_velocity_sensing", PGlobalFilterVelocityScaleFunction); - xml->addpar("filter_velocity_sensing_amplitude", + xml.addpar("filter_velocity_sensing_amplitude", PGlobalFilterVelocityScale); - xml->beginbranch("FILTER_ENVELOPE"); + xml.beginbranch("FILTER_ENVELOPE"); GlobalFilterEnvelope->add2XML(xml); - xml->endbranch(); + xml.endbranch(); } - xml->endbranch(); + xml.endbranch(); } @@ -389,94 +389,94 @@ void SUBnoteParameters::paste(SUBnoteParameters &sub) doPaste(Pstart); } -void SUBnoteParameters::getfromXML(XMLwrapper *xml) +void SUBnoteParameters::getfromXML(XMLwrapper& xml) { - Pnumstages = xml->getpar127("num_stages", Pnumstages); - Phmagtype = xml->getpar127("harmonic_mag_type", Phmagtype); - Pstart = xml->getpar127("start", Pstart); + Pnumstages = xml.getpar127("num_stages", Pnumstages); + Phmagtype = xml.getpar127("harmonic_mag_type", Phmagtype); + Pstart = xml.getpar127("start", Pstart); - if(xml->enterbranch("HARMONICS")) { + if(xml.enterbranch("HARMONICS")) { Phmag[0] = 0; for(int i = 0; i < MAX_SUB_HARMONICS; ++i) { - if(xml->enterbranch("HARMONIC", i) == 0) + if(xml.enterbranch("HARMONIC", i) == 0) continue; - Phmag[i] = xml->getpar127("mag", Phmag[i]); - Phrelbw[i] = xml->getpar127("relbw", Phrelbw[i]); - xml->exitbranch(); + Phmag[i] = xml.getpar127("mag", Phmag[i]); + Phrelbw[i] = xml.getpar127("relbw", Phrelbw[i]); + xml.exitbranch(); } - xml->exitbranch(); + xml.exitbranch(); } - if(xml->enterbranch("AMPLITUDE_PARAMETERS")) { - Pstereo = xml->getparbool("stereo", Pstereo); - PVolume = xml->getpar127("volume", PVolume); - PPanning = xml->getpar127("panning", PPanning); - PAmpVelocityScaleFunction = xml->getpar127("velocity_sensing", + if(xml.enterbranch("AMPLITUDE_PARAMETERS")) { + Pstereo = xml.getparbool("stereo", Pstereo); + PVolume = xml.getpar127("volume", PVolume); + PPanning = xml.getpar127("panning", PPanning); + PAmpVelocityScaleFunction = xml.getpar127("velocity_sensing", PAmpVelocityScaleFunction); - if(xml->enterbranch("AMPLITUDE_ENVELOPE")) { + if(xml.enterbranch("AMPLITUDE_ENVELOPE")) { AmpEnvelope->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); } - xml->exitbranch(); + xml.exitbranch(); } - if(xml->enterbranch("FREQUENCY_PARAMETERS")) { - Pfixedfreq = xml->getparbool("fixed_freq", Pfixedfreq); - PfixedfreqET = xml->getpar127("fixed_freq_et", PfixedfreqET); + if(xml.enterbranch("FREQUENCY_PARAMETERS")) { + Pfixedfreq = xml.getparbool("fixed_freq", Pfixedfreq); + PfixedfreqET = xml.getpar127("fixed_freq_et", PfixedfreqET); - PDetune = xml->getpar("detune", PDetune, 0, 16383); - PCoarseDetune = xml->getpar("coarse_detune", PCoarseDetune, 0, 16383); + PDetune = xml.getpar("detune", PDetune, 0, 16383); + PCoarseDetune = xml.getpar("coarse_detune", PCoarseDetune, 0, 16383); POvertoneSpread.type = - xml->getpar127("overtone_spread_type", POvertoneSpread.type); + xml.getpar127("overtone_spread_type", POvertoneSpread.type); POvertoneSpread.par1 = - xml->getpar("overtone_spread_par1", POvertoneSpread.par1, 0, 255); + xml.getpar("overtone_spread_par1", POvertoneSpread.par1, 0, 255); POvertoneSpread.par2 = - xml->getpar("overtone_spread_par2", POvertoneSpread.par2, 0, 255); + xml.getpar("overtone_spread_par2", POvertoneSpread.par2, 0, 255); POvertoneSpread.par3 = - xml->getpar("overtone_spread_par3", POvertoneSpread.par3, 0, 255); + xml.getpar("overtone_spread_par3", POvertoneSpread.par3, 0, 255); updateFrequencyMultipliers(); - PDetuneType = xml->getpar127("detune_type", PDetuneType); + PDetuneType = xml.getpar127("detune_type", PDetuneType); - Pbandwidth = xml->getpar127("bandwidth", Pbandwidth); - Pbwscale = xml->getpar127("bandwidth_scale", Pbwscale); + Pbandwidth = xml.getpar127("bandwidth", Pbandwidth); + Pbwscale = xml.getpar127("bandwidth_scale", Pbwscale); - PFreqEnvelopeEnabled = xml->getparbool("freq_envelope_enabled", + PFreqEnvelopeEnabled = xml.getparbool("freq_envelope_enabled", PFreqEnvelopeEnabled); - if(xml->enterbranch("FREQUENCY_ENVELOPE")) { + if(xml.enterbranch("FREQUENCY_ENVELOPE")) { FreqEnvelope->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); } - PBandWidthEnvelopeEnabled = xml->getparbool( + PBandWidthEnvelopeEnabled = xml.getparbool( "band_width_envelope_enabled", PBandWidthEnvelopeEnabled); - if(xml->enterbranch("BANDWIDTH_ENVELOPE")) { + if(xml.enterbranch("BANDWIDTH_ENVELOPE")) { BandWidthEnvelope->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); } - xml->exitbranch(); + xml.exitbranch(); } - if(xml->enterbranch("FILTER_PARAMETERS")) { - PGlobalFilterEnabled = xml->getparbool("enabled", PGlobalFilterEnabled); - if(xml->enterbranch("FILTER")) { + if(xml.enterbranch("FILTER_PARAMETERS")) { + PGlobalFilterEnabled = xml.getparbool("enabled", PGlobalFilterEnabled); + if(xml.enterbranch("FILTER")) { GlobalFilter->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); } - PGlobalFilterVelocityScaleFunction = xml->getpar127( + PGlobalFilterVelocityScaleFunction = xml.getpar127( "filter_velocity_sensing", PGlobalFilterVelocityScaleFunction); - PGlobalFilterVelocityScale = xml->getpar127( + PGlobalFilterVelocityScale = xml.getpar127( "filter_velocity_sensing_amplitude", PGlobalFilterVelocityScale); - if(xml->enterbranch("FILTER_ENVELOPE")) { + if(xml.enterbranch("FILTER_ENVELOPE")) { GlobalFilterEnvelope->getfromXML(xml); - xml->exitbranch(); + xml.exitbranch(); } - xml->exitbranch(); + xml.exitbranch(); } } diff --git a/source/native-plugins/zynaddsubfx/Params/SUBnoteParameters.h b/source/native-plugins/zynaddsubfx/Params/SUBnoteParameters.h index 6c088b968..304ea4319 100644 --- a/source/native-plugins/zynaddsubfx/Params/SUBnoteParameters.h +++ b/source/native-plugins/zynaddsubfx/Params/SUBnoteParameters.h @@ -32,9 +32,9 @@ class SUBnoteParameters:public Presets SUBnoteParameters(); ~SUBnoteParameters(); - void add2XML(XMLwrapper *xml); + void add2XML(XMLwrapper& xml); void defaults(); - void getfromXML(XMLwrapper *xml); + void getfromXML(XMLwrapper& xml); void updateFrequencyMultipliers(void); void paste(SUBnoteParameters &sub); diff --git a/source/native-plugins/zynaddsubfx/Synth/ADnote.cpp b/source/native-plugins/zynaddsubfx/Synth/ADnote.cpp index a9b946bf3..b15189780 100644 --- a/source/native-plugins/zynaddsubfx/Synth/ADnote.cpp +++ b/source/native-plugins/zynaddsubfx/Synth/ADnote.cpp @@ -286,6 +286,18 @@ ADnote::ADnote(ADnoteParameters *pars_, SynthParams &spars) getvoicebasefreq(nvoice), pars.VoicePar[nvoice].Presonance); + //Find range of generated wave + float min = NoteVoicePar[nvoice].OscilSmp[0]; + float max = min; + float *smpls = &(NoteVoicePar[nvoice].OscilSmp[1]); + for (int i = synth.oscilsize-1; i--; smpls++) + if (*smpls > max) + max = *smpls; + else if (*smpls < min) + min = *smpls; + NoteVoicePar[nvoice].OscilSmpMin = min; + NoteVoicePar[nvoice].OscilSmpMax = max; + //I store the first elments to the last position for speedups for(int i = 0; i < OSCIL_SMP_EXTRA_SAMPLES; ++i) NoteVoicePar[nvoice].OscilSmp[synth.oscilsize @@ -295,12 +307,12 @@ ADnote::ADnote(ADnoteParameters *pars_, SynthParams &spars) oscposhi_start += (int)((pars.VoicePar[nvoice].Poscilphase - 64.0f) / 128.0f * synth.oscilsize + synth.oscilsize * 4); - oscposhi_start %= synth.oscilsize; + int kth_start = oscposhi_start; for(int k = 0; k < unison; ++k) { - oscposhi[nvoice][k] = oscposhi_start; + oscposhi[nvoice][k] = kth_start % synth.oscilsize; //put random starting point for other subvoices - oscposhi_start = + kth_start = oscposhi_start + (int)(RND * pars.VoicePar[nvoice].Unison_phase_randomness / 127.0f * (synth.oscilsize - 1)); } diff --git a/source/native-plugins/zynaddsubfx/Synth/ADnote.h b/source/native-plugins/zynaddsubfx/Synth/ADnote.h index 66e661d64..9d2dcf754 100644 --- a/source/native-plugins/zynaddsubfx/Synth/ADnote.h +++ b/source/native-plugins/zynaddsubfx/Synth/ADnote.h @@ -187,6 +187,9 @@ class ADnote:public SynthNote /* Waveform of the Voice */ float *OscilSmp; + /* Range of waveform */ + float OscilSmpMin, OscilSmpMax; + /************************************ * FREQUENCY PARAMETERS * ************************************/ diff --git a/source/native-plugins/zynaddsubfx/Synth/OscilGen.cpp b/source/native-plugins/zynaddsubfx/Synth/OscilGen.cpp index 174320e7e..570313f2e 100644 --- a/source/native-plugins/zynaddsubfx/Synth/OscilGen.cpp +++ b/source/native-plugins/zynaddsubfx/Synth/OscilGen.cpp @@ -1227,161 +1227,161 @@ void OscilGen::paste(OscilGen &o) } #undef COPY -void OscilGen::add2XML(XMLwrapper *xml) +void OscilGen::add2XML(XMLwrapper& xml) { - xml->addpar("harmonic_mag_type", Phmagtype); + xml.addpar("harmonic_mag_type", Phmagtype); - xml->addpar("base_function", Pcurrentbasefunc); - xml->addpar("base_function_par", Pbasefuncpar); - xml->addpar("base_function_modulation", Pbasefuncmodulation); - xml->addpar("base_function_modulation_par1", Pbasefuncmodulationpar1); - xml->addpar("base_function_modulation_par2", Pbasefuncmodulationpar2); - xml->addpar("base_function_modulation_par3", Pbasefuncmodulationpar3); + xml.addpar("base_function", Pcurrentbasefunc); + xml.addpar("base_function_par", Pbasefuncpar); + xml.addpar("base_function_modulation", Pbasefuncmodulation); + xml.addpar("base_function_modulation_par1", Pbasefuncmodulationpar1); + xml.addpar("base_function_modulation_par2", Pbasefuncmodulationpar2); + xml.addpar("base_function_modulation_par3", Pbasefuncmodulationpar3); - xml->addpar("modulation", Pmodulation); - xml->addpar("modulation_par1", Pmodulationpar1); - xml->addpar("modulation_par2", Pmodulationpar2); - xml->addpar("modulation_par3", Pmodulationpar3); + xml.addpar("modulation", Pmodulation); + xml.addpar("modulation_par1", Pmodulationpar1); + xml.addpar("modulation_par2", Pmodulationpar2); + xml.addpar("modulation_par3", Pmodulationpar3); - xml->addpar("wave_shaping", Pwaveshaping); - xml->addpar("wave_shaping_function", Pwaveshapingfunction); + xml.addpar("wave_shaping", Pwaveshaping); + xml.addpar("wave_shaping_function", Pwaveshapingfunction); - xml->addpar("filter_type", Pfiltertype); - xml->addpar("filter_par1", Pfilterpar1); - xml->addpar("filter_par2", Pfilterpar2); - xml->addpar("filter_before_wave_shaping", Pfilterbeforews); + xml.addpar("filter_type", Pfiltertype); + xml.addpar("filter_par1", Pfilterpar1); + xml.addpar("filter_par2", Pfilterpar2); + xml.addpar("filter_before_wave_shaping", Pfilterbeforews); - xml->addpar("spectrum_adjust_type", Psatype); - xml->addpar("spectrum_adjust_par", Psapar); + xml.addpar("spectrum_adjust_type", Psatype); + xml.addpar("spectrum_adjust_par", Psapar); - xml->addpar("rand", Prand); - xml->addpar("amp_rand_type", Pamprandtype); - xml->addpar("amp_rand_power", Pamprandpower); + xml.addpar("rand", Prand); + xml.addpar("amp_rand_type", Pamprandtype); + xml.addpar("amp_rand_power", Pamprandpower); - xml->addpar("harmonic_shift", Pharmonicshift); - xml->addparbool("harmonic_shift_first", Pharmonicshiftfirst); + xml.addpar("harmonic_shift", Pharmonicshift); + xml.addparbool("harmonic_shift_first", Pharmonicshiftfirst); - xml->addpar("adaptive_harmonics", Padaptiveharmonics); - xml->addpar("adaptive_harmonics_base_frequency", Padaptiveharmonicsbasefreq); - xml->addpar("adaptive_harmonics_power", Padaptiveharmonicspower); + xml.addpar("adaptive_harmonics", Padaptiveharmonics); + xml.addpar("adaptive_harmonics_base_frequency", Padaptiveharmonicsbasefreq); + xml.addpar("adaptive_harmonics_power", Padaptiveharmonicspower); - xml->beginbranch("HARMONICS"); + xml.beginbranch("HARMONICS"); for(int n = 0; n < MAX_AD_HARMONICS; ++n) { if((Phmag[n] == 64) && (Phphase[n] == 64)) continue; - xml->beginbranch("HARMONIC", n + 1); - xml->addpar("mag", Phmag[n]); - xml->addpar("phase", Phphase[n]); - xml->endbranch(); + xml.beginbranch("HARMONIC", n + 1); + xml.addpar("mag", Phmag[n]); + xml.addpar("phase", Phphase[n]); + xml.endbranch(); } - xml->endbranch(); + xml.endbranch(); if(Pcurrentbasefunc == 127) { normalize(basefuncFFTfreqs, synth.oscilsize); - xml->beginbranch("BASE_FUNCTION"); + xml.beginbranch("BASE_FUNCTION"); for(int i = 1; i < synth.oscilsize / 2; ++i) { float xc = basefuncFFTfreqs[i].real(); float xs = basefuncFFTfreqs[i].imag(); if((fabs(xs) > 1e-6f) || (fabs(xc) > 1e-6f)) { - xml->beginbranch("BF_HARMONIC", i); - xml->addparreal("cos", xc); - xml->addparreal("sin", xs); - xml->endbranch(); + xml.beginbranch("BF_HARMONIC", i); + xml.addparreal("cos", xc); + xml.addparreal("sin", xs); + xml.endbranch(); } } - xml->endbranch(); + xml.endbranch(); } } -void OscilGen::getfromXML(XMLwrapper *xml) +void OscilGen::getfromXML(XMLwrapper& xml) { - Phmagtype = xml->getpar127("harmonic_mag_type", Phmagtype); + Phmagtype = xml.getpar127("harmonic_mag_type", Phmagtype); - Pcurrentbasefunc = xml->getpar127("base_function", Pcurrentbasefunc); - Pbasefuncpar = xml->getpar127("base_function_par", Pbasefuncpar); + Pcurrentbasefunc = xml.getpar127("base_function", Pcurrentbasefunc); + Pbasefuncpar = xml.getpar127("base_function_par", Pbasefuncpar); - Pbasefuncmodulation = xml->getpar127("base_function_modulation", + Pbasefuncmodulation = xml.getpar127("base_function_modulation", Pbasefuncmodulation); - Pbasefuncmodulationpar1 = xml->getpar127("base_function_modulation_par1", + Pbasefuncmodulationpar1 = xml.getpar127("base_function_modulation_par1", Pbasefuncmodulationpar1); - Pbasefuncmodulationpar2 = xml->getpar127("base_function_modulation_par2", + Pbasefuncmodulationpar2 = xml.getpar127("base_function_modulation_par2", Pbasefuncmodulationpar2); - Pbasefuncmodulationpar3 = xml->getpar127("base_function_modulation_par3", + Pbasefuncmodulationpar3 = xml.getpar127("base_function_modulation_par3", Pbasefuncmodulationpar3); - Pmodulation = xml->getpar127("modulation", Pmodulation); - Pmodulationpar1 = xml->getpar127("modulation_par1", + Pmodulation = xml.getpar127("modulation", Pmodulation); + Pmodulationpar1 = xml.getpar127("modulation_par1", Pmodulationpar1); - Pmodulationpar2 = xml->getpar127("modulation_par2", + Pmodulationpar2 = xml.getpar127("modulation_par2", Pmodulationpar2); - Pmodulationpar3 = xml->getpar127("modulation_par3", + Pmodulationpar3 = xml.getpar127("modulation_par3", Pmodulationpar3); - Pwaveshaping = xml->getpar127("wave_shaping", Pwaveshaping); - Pwaveshapingfunction = xml->getpar127("wave_shaping_function", + Pwaveshaping = xml.getpar127("wave_shaping", Pwaveshaping); + Pwaveshapingfunction = xml.getpar127("wave_shaping_function", Pwaveshapingfunction); - Pfiltertype = xml->getpar127("filter_type", Pfiltertype); - Pfilterpar1 = xml->getpar127("filter_par1", Pfilterpar1); - Pfilterpar2 = xml->getpar127("filter_par2", Pfilterpar2); - Pfilterbeforews = xml->getpar127("filter_before_wave_shaping", + Pfiltertype = xml.getpar127("filter_type", Pfiltertype); + Pfilterpar1 = xml.getpar127("filter_par1", Pfilterpar1); + Pfilterpar2 = xml.getpar127("filter_par2", Pfilterpar2); + Pfilterbeforews = xml.getpar127("filter_before_wave_shaping", Pfilterbeforews); - Psatype = xml->getpar127("spectrum_adjust_type", Psatype); - Psapar = xml->getpar127("spectrum_adjust_par", Psapar); + Psatype = xml.getpar127("spectrum_adjust_type", Psatype); + Psapar = xml.getpar127("spectrum_adjust_par", Psapar); - Prand = xml->getpar127("rand", Prand); - Pamprandtype = xml->getpar127("amp_rand_type", Pamprandtype); - Pamprandpower = xml->getpar127("amp_rand_power", Pamprandpower); + Prand = xml.getpar127("rand", Prand); + Pamprandtype = xml.getpar127("amp_rand_type", Pamprandtype); + Pamprandpower = xml.getpar127("amp_rand_power", Pamprandpower); - Pharmonicshift = xml->getpar("harmonic_shift", + Pharmonicshift = xml.getpar("harmonic_shift", Pharmonicshift, -64, 64); - Pharmonicshiftfirst = xml->getparbool("harmonic_shift_first", + Pharmonicshiftfirst = xml.getparbool("harmonic_shift_first", Pharmonicshiftfirst); - Padaptiveharmonics = xml->getpar("adaptive_harmonics", + Padaptiveharmonics = xml.getpar("adaptive_harmonics", Padaptiveharmonics, 0, 127); - Padaptiveharmonicsbasefreq = xml->getpar( + Padaptiveharmonicsbasefreq = xml.getpar( "adaptive_harmonics_base_frequency", Padaptiveharmonicsbasefreq, 0, 255); - Padaptiveharmonicspower = xml->getpar("adaptive_harmonics_power", + Padaptiveharmonicspower = xml.getpar("adaptive_harmonics_power", Padaptiveharmonicspower, 0, 200); - if(xml->enterbranch("HARMONICS")) { + if(xml.enterbranch("HARMONICS")) { Phmag[0] = 64; Phphase[0] = 64; for(int n = 0; n < MAX_AD_HARMONICS; ++n) { - if(xml->enterbranch("HARMONIC", n + 1) == 0) + if(xml.enterbranch("HARMONIC", n + 1) == 0) continue; - Phmag[n] = xml->getpar127("mag", 64); - Phphase[n] = xml->getpar127("phase", 64); - xml->exitbranch(); + Phmag[n] = xml.getpar127("mag", 64); + Phphase[n] = xml.getpar127("phase", 64); + xml.exitbranch(); } - xml->exitbranch(); + xml.exitbranch(); } if(Pcurrentbasefunc != 0) changebasefunction(); - if(xml->enterbranch("BASE_FUNCTION")) { + if(xml.enterbranch("BASE_FUNCTION")) { for(int i = 1; i < synth.oscilsize / 2; ++i) - if(xml->enterbranch("BF_HARMONIC", i)) { + if(xml.enterbranch("BF_HARMONIC", i)) { basefuncFFTfreqs[i] = - std::complex(xml->getparreal("cos", 0.0f), - xml->getparreal("sin", 0.0f)); - xml->exitbranch(); + std::complex(xml.getparreal("cos", 0.0f), + xml.getparreal("sin", 0.0f)); + xml.exitbranch(); } - xml->exitbranch(); + xml.exitbranch(); clearDC(basefuncFFTfreqs); normalize(basefuncFFTfreqs, synth.oscilsize); diff --git a/source/native-plugins/zynaddsubfx/Synth/OscilGen.h b/source/native-plugins/zynaddsubfx/Synth/OscilGen.h index 1157b4551..17ac8c8c3 100644 --- a/source/native-plugins/zynaddsubfx/Synth/OscilGen.h +++ b/source/native-plugins/zynaddsubfx/Synth/OscilGen.h @@ -52,9 +52,9 @@ class OscilGen:public Presets void useasbase(); void paste(OscilGen &o); - void add2XML(XMLwrapper *xml); + void add2XML(XMLwrapper& xml); void defaults(); - void getfromXML(XMLwrapper *xml); + void getfromXML(XMLwrapper& xml); void convert2sine(); diff --git a/source/native-plugins/zynaddsubfx/Synth/Resonance.cpp b/source/native-plugins/zynaddsubfx/Synth/Resonance.cpp index d2f2a360f..126ba7158 100644 --- a/source/native-plugins/zynaddsubfx/Synth/Resonance.cpp +++ b/source/native-plugins/zynaddsubfx/Synth/Resonance.cpp @@ -267,39 +267,39 @@ void Resonance::paste(Resonance &r) } #undef COPY -void Resonance::add2XML(XMLwrapper *xml) +void Resonance::add2XML(XMLwrapper& xml) { - xml->addparbool("enabled", Penabled); + xml.addparbool("enabled", Penabled); - if((Penabled == 0) && (xml->minimal)) + if((Penabled == 0) && (xml.minimal)) return; - xml->addpar("max_db", PmaxdB); - xml->addpar("center_freq", Pcenterfreq); - xml->addpar("octaves_freq", Poctavesfreq); - xml->addparbool("protect_fundamental_frequency", Pprotectthefundamental); - xml->addpar("resonance_points", N_RES_POINTS); + xml.addpar("max_db", PmaxdB); + xml.addpar("center_freq", Pcenterfreq); + xml.addpar("octaves_freq", Poctavesfreq); + xml.addparbool("protect_fundamental_frequency", Pprotectthefundamental); + xml.addpar("resonance_points", N_RES_POINTS); for(int i = 0; i < N_RES_POINTS; ++i) { - xml->beginbranch("RESPOINT", i); - xml->addpar("val", Prespoints[i]); - xml->endbranch(); + xml.beginbranch("RESPOINT", i); + xml.addpar("val", Prespoints[i]); + xml.endbranch(); } } -void Resonance::getfromXML(XMLwrapper *xml) +void Resonance::getfromXML(XMLwrapper& xml) { - Penabled = xml->getparbool("enabled", Penabled); + Penabled = xml.getparbool("enabled", Penabled); - PmaxdB = xml->getpar127("max_db", PmaxdB); - Pcenterfreq = xml->getpar127("center_freq", Pcenterfreq); - Poctavesfreq = xml->getpar127("octaves_freq", Poctavesfreq); - Pprotectthefundamental = xml->getparbool("protect_fundamental_frequency", + PmaxdB = xml.getpar127("max_db", PmaxdB); + Pcenterfreq = xml.getpar127("center_freq", Pcenterfreq); + Poctavesfreq = xml.getpar127("octaves_freq", Poctavesfreq); + Pprotectthefundamental = xml.getparbool("protect_fundamental_frequency", Pprotectthefundamental); for(int i = 0; i < N_RES_POINTS; ++i) { - if(xml->enterbranch("RESPOINT", i) == 0) + if(xml.enterbranch("RESPOINT", i) == 0) continue; - Prespoints[i] = xml->getpar127("val", Prespoints[i]); - xml->exitbranch(); + Prespoints[i] = xml.getpar127("val", Prespoints[i]); + xml.exitbranch(); } } diff --git a/source/native-plugins/zynaddsubfx/Synth/Resonance.h b/source/native-plugins/zynaddsubfx/Synth/Resonance.h index 95ae21f8a..1f63e8b65 100644 --- a/source/native-plugins/zynaddsubfx/Synth/Resonance.h +++ b/source/native-plugins/zynaddsubfx/Synth/Resonance.h @@ -43,9 +43,9 @@ class Resonance:public Presets void zero(void); void paste(Resonance &r); - void add2XML(XMLwrapper *xml); + void add2XML(XMLwrapper& xml); void defaults(void); - void getfromXML(XMLwrapper *xml); + void getfromXML(XMLwrapper& xml); //TODO remove unused methods diff --git a/source/native-plugins/zynaddsubfx/Synth/SUBnote.cpp b/source/native-plugins/zynaddsubfx/Synth/SUBnote.cpp index ea09d0d88..fa72eed7b 100644 --- a/source/native-plugins/zynaddsubfx/Synth/SUBnote.cpp +++ b/source/native-plugins/zynaddsubfx/Synth/SUBnote.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include "../globals.h" #include "SUBnote.h" #include "Envelope.h" @@ -224,8 +225,12 @@ void SUBnote::legatonote(LegatoParams pars) if(legato.update(pars)) return; - setup(pars.frequency, pars.velocity, pars.portamento, pars.midinote, - true); + try { + setup(pars.frequency, pars.velocity, pars.portamento, pars.midinote, + true); + } catch (std::bad_alloc &ba) { + std::cerr << "failed to set legato note parameter in SUBnote: " << ba.what() << std::endl; + } } SUBnote::~SUBnote() diff --git a/source/native-plugins/zynaddsubfx/Synth/SynthNote.cpp b/source/native-plugins/zynaddsubfx/Synth/SynthNote.cpp index 45054dfcb..1bbd358eb 100644 --- a/source/native-plugins/zynaddsubfx/Synth/SynthNote.cpp +++ b/source/native-plugins/zynaddsubfx/Synth/SynthNote.cpp @@ -1,6 +1,8 @@ #include "SynthNote.h" #include "../globals.h" #include +#include +#include SynthNote::SynthNote(SynthParams &pars) :memory(pars.memory), @@ -61,72 +63,76 @@ void SynthNote::Legato::apply(SynthNote ¬e, float *outl, float *outr) memset(outl, 0, synth.bufferbytes); memset(outr, 0, synth.bufferbytes); } - switch(msg) { - case LM_CatchUp: // Continue the catch-up... - if(decounter == -10) - decounter = fade.length; - //Yea, could be done without the loop... - for(int i = 0; i < synth.buffersize; ++i) { - decounter--; - if(decounter < 1) { - // Catching-up done, we can finally set - // the note to the actual parameters. - decounter = -10; - msg = LM_ToNorm; - LegatoParams pars{param.freq, param.vel, param.portamento, - param.midinote, false}; - note.legatonote(pars); - break; - } - } - break; - case LM_FadeIn: // Fade-in - if(decounter == -10) - decounter = fade.length; - silent = false; - for(int i = 0; i < synth.buffersize; ++i) { - decounter--; - if(decounter < 1) { - decounter = -10; - msg = LM_Norm; - break; + try { + switch (msg) { + case LM_CatchUp: // Continue the catch-up... + if (decounter == -10) + decounter = fade.length; + //Yea, could be done without the loop... + for (int i = 0; i < synth.buffersize; ++i) { + decounter--; + if (decounter < 1) { + // Catching-up done, we can finally set + // the note to the actual parameters. + decounter = -10; + msg = LM_ToNorm; + LegatoParams pars{param.freq, param.vel, param.portamento, + param.midinote, false}; + note.legatonote(pars); + break; + } } - fade.m += fade.step; - outl[i] *= fade.m; - outr[i] *= fade.m; - } - break; - case LM_FadeOut: // Fade-out, then set the catch-up - if(decounter == -10) - decounter = fade.length; - for(int i = 0; i < synth.buffersize; ++i) { - decounter--; - if(decounter < 1) { - for(int j = i; j < synth.buffersize; ++j) { - outl[j] = 0.0f; - outr[j] = 0.0f; + break; + case LM_FadeIn: // Fade-in + if (decounter == -10) + decounter = fade.length; + silent = false; + for (int i = 0; i < synth.buffersize; ++i) { + decounter--; + if (decounter < 1) { + decounter = -10; + msg = LM_Norm; + break; } - decounter = -10; - silent = true; - // Fading-out done, now set the catch-up : + fade.m += fade.step; + outl[i] *= fade.m; + outr[i] *= fade.m; + } + break; + case LM_FadeOut: // Fade-out, then set the catch-up + if (decounter == -10) decounter = fade.length; - msg = LM_CatchUp; - //This freq should make this now silent note to catch-up/resync - //with the heard note for the same length it stayed at the - //previous freq during the fadeout. - float catchupfreq = param.freq * (param.freq / lastfreq); - LegatoParams pars{catchupfreq, param.vel, param.portamento, - param.midinote, false}; - note.legatonote(pars); - break; + for (int i = 0; i < synth.buffersize; ++i) { + decounter--; + if (decounter < 1) { + for (int j = i; j < synth.buffersize; ++j) { + outl[j] = 0.0f; + outr[j] = 0.0f; + } + decounter = -10; + silent = true; + // Fading-out done, now set the catch-up : + decounter = fade.length; + msg = LM_CatchUp; + //This freq should make this now silent note to catch-up/resync + //with the heard note for the same length it stayed at the + //previous freq during the fadeout. + float catchupfreq = param.freq * (param.freq / lastfreq); + LegatoParams pars{catchupfreq, param.vel, param.portamento, + param.midinote, false}; + note.legatonote(pars); + break; + } + fade.m -= fade.step; + outl[i] *= fade.m; + outr[i] *= fade.m; } - fade.m -= fade.step; - outl[i] *= fade.m; - outr[i] *= fade.m; - } - break; - default: - break; + break; + default: + break; + } + } catch (std::bad_alloc &ba) { + std::cerr << "failed to apply legato: " << ba.what() << std::endl; } } @@ -134,6 +140,10 @@ void SynthNote::setVelocity(float velocity_) { legato.setSilent(true); //Let legato.update(...) returns 0. LegatoParams pars{legato.getFreq(), velocity_, legato.getPortamento(), legato.getMidinote(), true}; - legatonote(pars); + try { + legatonote(pars); + } catch (std::bad_alloc &ba) { + std::cerr << "failed to set velocity to legato note: " << ba.what() << std::endl; + } legato.setDecounter(0); //avoid chopping sound due fade-in } diff --git a/source/native-plugins/zynaddsubfx/UI/BankView.cpp b/source/native-plugins/zynaddsubfx/UI/BankView.cpp index 5fd11432d..85f564fc9 100644 --- a/source/native-plugins/zynaddsubfx/UI/BankView.cpp +++ b/source/native-plugins/zynaddsubfx/UI/BankView.cpp @@ -34,7 +34,12 @@ void BankList::OSC_raw(const char *msg) this->add(path); } if(!strcmp(msg, "/bank/bank_select")&& !strcmp(rtosc_argument_string(msg),"i")) { - value(rtosc_argument(msg, 0).i); + int val = rtosc_argument(msg, 0).i; + if(value() != val) { + value(val); + for(int i=0; i<160; ++i) + osc->write("/bank/slot"+to_s(i), ""); + } } } diff --git a/source/native-plugins/zynaddsubfx/UI/BankView.h b/source/native-plugins/zynaddsubfx/UI/BankView.h index 97494afea..49f48df1e 100644 --- a/source/native-plugins/zynaddsubfx/UI/BankView.h +++ b/source/native-plugins/zynaddsubfx/UI/BankView.h @@ -11,7 +11,7 @@ class Bank; class BankView; -class Fl_Light_Button; +class Fl_Check_Button; class BankList : public Fl_Osc_Choice { @@ -63,9 +63,9 @@ class BankViewControls: public Fl_Group //4 -> swap int mode_; - static void cb_clearbutton(Fl_Light_Button*, void*); - static void cb_readbutton(Fl_Light_Button*, void*); - static void cb_writebutton(Fl_Light_Button*, void*); + static void cb_clearbutton(Fl_Check_Button*, void*); + static void cb_readbutton(Fl_Check_Button*, void*); + static void cb_writebutton(Fl_Check_Button*, void*); }; class BankView: public Fl_Group, public Fl_Osc_Widget diff --git a/source/native-plugins/zynaddsubfx/UI/Connection.cpp b/source/native-plugins/zynaddsubfx/UI/Connection.cpp index b66c32c0d..b38d5cec0 100644 --- a/source/native-plugins/zynaddsubfx/UI/Connection.cpp +++ b/source/native-plugins/zynaddsubfx/UI/Connection.cpp @@ -26,20 +26,28 @@ using namespace GUI; class MasterUI *ui; - #ifdef NTK_GUI static Fl_Tiled_Image *module_backdrop; #endif -int undo_redo_handler(int) +int kb_shortcut_handler(int) { const bool undo_ = Fl::event_ctrl() && Fl::event_key() == 'z'; const bool redo = Fl::event_ctrl() && Fl::event_key() == 'r'; + const bool show = Fl::event_ctrl() && Fl::event_shift() && + Fl::event_key() == 's'; + const bool panel = Fl::event_ctrl() && Fl::event_shift() && + Fl::event_key() == 'p'; if(undo_) ui->osc->write("/undo", ""); else if(redo) ui->osc->write("/redo", ""); - return undo_ || redo; + else if (show) { + ui->simplemasterwindow->hide(); + ui->masterwindow->show(); + } else if (panel) + ui->panelwindow->show(); + return undo_ || redo || show; } void @@ -118,7 +126,7 @@ ui_handle_t GUI::createUi(Fl_Osc_Interface *osc, void *exit) //tree->osc = osc; //midi_win->show(); - Fl::add_handler(undo_redo_handler); + Fl::add_handler(kb_shortcut_handler); return (void*) (ui = new MasterUI((int*)exit, osc)); } void GUI::destroyUi(ui_handle_t ui) diff --git a/source/native-plugins/zynaddsubfx/UI/FilterUI.fl b/source/native-plugins/zynaddsubfx/UI/FilterUI.fl index 85b91535e..ff467e351 100644 --- a/source/native-plugins/zynaddsubfx/UI/FilterUI.fl +++ b/source/native-plugins/zynaddsubfx/UI/FilterUI.fl @@ -361,40 +361,40 @@ formantfiltergraph->redraw();} label {Num.Formants} callback {update_formant_window(); formantfiltergraph->redraw();} - xywh {485 15 65 20} type Simple labelfont 1 labelsize 10 align 5 minimum 0 maximum 127 step 1 + xywh {485 15 65 20} type Simple labelfont 0 labelsize 10 align 5 minimum 0 maximum 127 step 1 code0 {o->bounds(1,FF_MAX_FORMANTS);} code1 {o->init("Pnumformants");} class Fl_Osc_Counter } Fl_Dial frsldial { label {Fr.Sl.} - tooltip {Formant's Slowness (Morphing)} xywh {565 15 25 25} box ROUND_UP_BOX labelfont 1 labelsize 10 align 1 maximum 127 step 1 + tooltip {Formant's Slowness (Morphing)} xywh {565 15 25 25} box ROUND_UP_BOX labelfont 0 labelsize 10 align 1 maximum 127 step 1 code0 {o->init("Pformantslowness");} class Fl_Osc_Dial } Fl_Value_Output centerfreqvo { label {C.f.} callback {o->value(o->newvalue()/1000.0);} - tooltip {Center Frequency (kHz)} xywh {515 164 33 18} when 3 minimum 1 maximum 10 step 0.01 value 1 textfont 1 + tooltip {Center Frequency (kHz)} xywh {511 164 40 18} when 3 minimum 1 maximum 10 step 0.01 value 1 textfont 1 textsize 11 labelsize 13 code0 {o->init("centerfreq");} class Fl_Osc_Output } Fl_Value_Output octavesfreqvo { label {Oct.} callback {o->value(o->newvalue());} - tooltip {No. of octaves} xywh {515 182 33 18} when 3 minimum 1 maximum 127 step 1 value 5 textfont 1 + tooltip {No. of octaves} xywh {511 182 40 18} when 3 minimum 1 maximum 127 step 0.01 value 5 textfont 1 textsize 11 labelsize 13 code0 {o->init("octavesfreq");} class Fl_Osc_Output } Fl_Slider cfknob { - callback {/*formantfiltergraph->redraw();*/} - xywh {551 167 84 15} type {Horz Knob} box FLAT_BOX maximum 127 + callback {centerfreqvo->update();} + xywh {555 167 84 15} type {Horz Knob} box FLAT_BOX maximum 127 code0 {o->init("Pcenterfreq", 'i');} class Fl_Osc_Slider } Fl_Slider octknob { - callback {/*formantfiltergraph->redraw();*/} - xywh {551 185 84 15} type {Horz Knob} box FLAT_BOX maximum 127 + callback {octavesfreqvo->update();} + xywh {555 185 84 15} type {Horz Knob} box FLAT_BOX maximum 127 code0 {o->init("Poctavesfreq", 'i');} class Fl_Osc_Slider } @@ -405,7 +405,7 @@ formantfiltergraph->redraw();} } Fl_Dial wvknob { label {Vw.Cl.} - tooltip {Vowel "clearness" (how the mixed vowels are avoided)} xywh {600 15 25 25} box ROUND_UP_BOX labelfont 1 labelsize 10 align 1 maximum 127 step 1 + tooltip {Vowel "clearness" (how the mixed vowels are avoided)} xywh {600 15 25 25} box ROUND_UP_BOX labelfont 0 labelsize 10 align 1 maximum 127 step 1 code0 {o->init("Pvowelclearness");} class Fl_Osc_Dial } @@ -421,7 +421,7 @@ formantfiltergraph->redraw();} } Fl_Box {} { label Vowel - xywh {635 10 55 15} + xywh {635 6 55 15} labelfont 1 } } } diff --git a/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Dial.cpp b/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Dial.cpp index 77ceb297e..3f319e180 100644 --- a/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Dial.cpp +++ b/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Dial.cpp @@ -63,7 +63,7 @@ void Fl_Osc_Dial::callback(Fl_Callback *cb, void *p) int Fl_Osc_Dial::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 ctl_click = (ev == FL_PUSH && Fl::event_state(FL_BUTTON3) && 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"); diff --git a/source/native-plugins/zynaddsubfx/UI/Fl_Osc_DialF.cpp b/source/native-plugins/zynaddsubfx/UI/Fl_Osc_DialF.cpp index 502c5236f..0e2718d2b 100644 --- a/source/native-plugins/zynaddsubfx/UI/Fl_Osc_DialF.cpp +++ b/source/native-plugins/zynaddsubfx/UI/Fl_Osc_DialF.cpp @@ -54,7 +54,7 @@ void Fl_Osc_DialF::callback(Fl_Callback *cb, void *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 ctl_click = (ev == FL_PUSH && Fl::event_state(FL_BUTTON3) && 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"); diff --git a/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Slider.H b/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Slider.H index 7bc66cb2a..db4d303db 100644 --- a/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Slider.H +++ b/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Slider.H @@ -33,6 +33,9 @@ class Fl_Osc_Slider:public Fl_Slider, public Fl_Osc_Widget private: float old_value; + int mod_state; + int slow_state; int start_pos; + bool just_pushed; 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 d3c3e9b06..ba70d46a8 100644 --- a/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Slider.cpp +++ b/source/native-plugins/zynaddsubfx/UI/Fl_Osc_Slider.cpp @@ -16,7 +16,7 @@ static double min__(double a, double b) Fl_Osc_Slider::Fl_Osc_Slider(int X, int Y, int W, int H, const char *label) :Fl_Slider(X,Y,W,H,label), Fl_Osc_Widget(this), reset_value(0), - cb_data(NULL, NULL) + cb_data(NULL, NULL), just_pushed(true) { //bounds(0.0f,1.0f); Fl_Slider::callback(Fl_Osc_Slider::_cb); @@ -74,10 +74,12 @@ void Fl_Osc_Slider::callback(Fl_Callback *cb, void *p) cb_data.second = p; } +#define MOD_MASK (FL_CTRL | FL_SHIFT) + int Fl_Osc_Slider::handle(int ev, int X, int Y, int W, int H) { 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 ctl_click = (ev == FL_PUSH && Fl::event_state(FL_BUTTON3) && 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"); @@ -91,46 +93,46 @@ int Fl_Osc_Slider::handle(int ev, int X, int Y, int W, int H) int handled; float rounded; - if (ev != FL_MOUSEWHEEL) - handled = Fl_Slider::handle(ev, X, Y, W, H); + const float range = maximum() - minimum(); + const float absrange = (range > 0 ? range : -range)+1; + int old_mod_state; + const float normal_step = range / W; 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; - } + just_pushed = true; + mod_state = Fl::event_state() & MOD_MASK; + slow_state = 0; + handled = mod_state ? 1 : Fl_Slider::handle(ev, X, Y, W, H); break; case FL_MOUSEWHEEL: + mod_state = Fl::event_state() & MOD_MASK; + if (Fl::event_buttons()) + return 1; if (this == Fl::belowmouse() && Fl::e_dy != 0) { - int step = 1, divisor = 16; - switch (Fl::event_state() & ( FL_CTRL | FL_SHIFT)) { + int step_ = 1, divisor = 16; + + switch (mod_state) { case FL_SHIFT: - step = 8; + if (absrange > divisor * 8) + step_ = 8; case FL_SHIFT | FL_CTRL: break; case FL_CTRL: divisor = 128; default: - step = (fabs(maximum() - minimum()) + 1) / divisor; - if (step < 1) - step = 1; + step_ = absrange / divisor; + if (step_ < 1) + step_ = 1; } int dy = minimum() <= maximum() ? -Fl::e_dy : Fl::e_dy; // Flip sense for vertical sliders. dy = this->horizontal() ? dy : -dy; - handle_drag(clamp(value() + step * dy)); + handle_drag(clamp(value() + step_ * dy)); } return 1; case FL_RELEASE: + handled = Fl_Slider::handle(ev, X, Y, W, H); if (Fl::event_clicks() == 1) { Fl::event_clicks(0); value(reset_value); @@ -141,15 +143,75 @@ int Fl_Osc_Slider::handle(int ev, int X, int Y, int W, int H) value_damage(); 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(); + case FL_DRAG: { + old_mod_state = mod_state; + mod_state = Fl::event_state() & MOD_MASK; + if (slow_state == 0 && mod_state == 0) + return Fl_Slider::handle(ev, X, Y, W, H); + + if (mod_state != 0) { + slow_state = 1; + } else if (slow_state == 1) + slow_state = 2; + + if (just_pushed || old_mod_state != mod_state) { + just_pushed = false; + old_value = value(); + start_pos = horizontal() ? Fl::event_x() : Fl::event_y(); + if (slow_state == 1) { + denominator = 2.0; + float step_ = step(); + if (step_ == 0) step_ = 1; + + if (absrange / W / step_ > 32) + switch (mod_state) { + case FL_CTRL: + denominator = 0.15; + break; + case FL_SHIFT: + denominator = 0.7; + break; + case MOD_MASK: + denominator = 3.0; + break; + } + else if (mod_state & FL_SHIFT) + denominator = 5.0; + + if (range < 0) + denominator *= -1; + } + } + + int delta = (horizontal() ? Fl::event_x() : Fl::event_y()) + - start_pos; + float new_value; + if (slow_state == 1) { + new_value = old_value + delta / denominator; + } else { + new_value = old_value + delta * normal_step; + } + const float clamped_value = clamp(new_value); + rounded = floor(clamped_value + 0.5); + if (new_value != clamped_value) { + start_pos = horizontal() ? Fl::event_x() : Fl::event_y(); + old_value = rounded; + if (slow_state == 2 && + ((horizontal() && + (Fl::event_x() < X || Fl::event_x() > X + W)) || + (!horizontal() && + (Fl::event_y() < Y || Fl::event_y() > Y + H)))) + slow_state = 0; } + value(rounded); + value_damage(); + do_callback(); + + handled = 1; + break; + } + default: + handled = Fl_Slider::handle(ev, X, Y, W, H); } return handled; diff --git a/source/native-plugins/zynaddsubfx/UI/OscilGenUI.fl b/source/native-plugins/zynaddsubfx/UI/OscilGenUI.fl index 9fca9b139..7884dcd10 100644 --- a/source/native-plugins/zynaddsubfx/UI/OscilGenUI.fl +++ b/source/native-plugins/zynaddsubfx/UI/OscilGenUI.fl @@ -644,9 +644,9 @@ redrawoscil();} code0 {o->value(wshpar->value());} } } - Fl_Light_Button autoclearbutton { + Fl_Check_Button autoclearbutton { label {Clr.} - tooltip {Auto clear when using the oscillator as base function} xywh {100 318 35 20} box THIN_UP_BOX value 1 labelfont 1 labelsize 10 + tooltip {Auto clear when using the oscillator as base function} xywh {98 318 40 20} box THIN_UP_BOX value 1 labelfont 1 labelsize 10 } Fl_Group {} { xywh {290 313 155 30} box UP_FRAME diff --git a/source/native-plugins/zynaddsubfx/UI/PartUI.fl b/source/native-plugins/zynaddsubfx/UI/PartUI.fl index 4bd33c7bb..5980dfc54 100644 --- a/source/native-plugins/zynaddsubfx/UI/PartUI.fl +++ b/source/native-plugins/zynaddsubfx/UI/PartUI.fl @@ -531,7 +531,9 @@ else {bendrng->oscMove("pitchwheel.bendrange");}} } Fl_Button {} { label {Reset all controllers} - callback {o->oscWrite("defaults");//part->SetController(C_resetallcontrollers,0);} + callback {o->oscWrite("defaults");//part->SetController(C_resetallcontrollers,0); + ctlwindow->update(); + } xywh {5 110 210 20} box THIN_UP_BOX class Fl_Osc_Button } diff --git a/source/native-plugins/zynaddsubfx/UI/ResonanceUI.fl b/source/native-plugins/zynaddsubfx/UI/ResonanceUI.fl index 4b62baa70..0ce6cdd41 100644 --- a/source/native-plugins/zynaddsubfx/UI/ResonanceUI.fl +++ b/source/native-plugins/zynaddsubfx/UI/ResonanceUI.fl @@ -102,13 +102,13 @@ redrawPADnoteApply();} Fl_Slider maxdb { callback {maxdbvo->value(o->value()); redrawPADnoteApply();} - xywh {90 282 84 15} type Horizontal minimum 1 maximum 90 step 1 value 30 + xywh {90 285 84 15} box FLAT_BOX type {Horz Knob} minimum 1 maximum 90 step 1 value 30 code0 {o->init("PmaxdB", 'i'); o->reset_value = 30;} class Fl_Osc_Slider } Fl_Value_Output maxdbvo { label {Max.} - tooltip {The Maximum amplitude (dB)} xywh {126 264 24 18} labelsize 12 minimum 1 maximum 127 step 1 value 30 textfont 1 textsize 12 + tooltip {The Maximum amplitude (dB)} xywh {126 264 24 18} labelsize 12 minimum 1 maximum 127 step 1 value 30 textfont 0 textsize 12 } Fl_Box {} { label dB @@ -117,14 +117,14 @@ redrawPADnoteApply();} Fl_Value_Output centerfreqvo { label {C.f.} callback {o->value(o->newvalue()/1000.0);} - tooltip {Center Frequency (kHz)} xywh {210 264 33 18} labelsize 12 when 3 minimum 1 maximum 10 step 0.01 value 1 textfont 1 textsize 12 + tooltip {Center Frequency (kHz)} xywh {210 264 45 18} labelsize 12 when 3 minimum 1 maximum 10 step 0.01 value 1 textfont 1 textsize 12 code0 {o->init("centerfreq");} class Fl_Osc_Output } Fl_Value_Output octavesfreqvo { label {Oct.} callback {o->value(o->newvalue());} - tooltip {No. of octaves} xywh {210 282 33 18} labelsize 12 when 3 minimum 1 maximum 127 step 1 value 30 textfont 1 textsize 12 + tooltip {No. of octaves} xywh {210 282 45 18} labelsize 12 when 3 minimum 0 maximum 11 step 0.01 value 5 textfont 1 textsize 12 code0 {o->init("octavesfreq");} class Fl_Osc_Output } @@ -165,21 +165,19 @@ redrawPADnoteApply();} tooltip {Interpolate the peaks} xywh {365 265 46 15} box THIN_UP_BOX labelfont 1 labelsize 10 class Fl_Osc_Button } - Fl_Dial centerfreq { - label {C.f.} + Fl_Slider centerfreq { callback {centerfreqvo->do_callback(); redrawPADnoteApply();} - xywh {245 265 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1 - code0 {o->init("Pcenterfreq");} - class Fl_Osc_Dial + xywh {260 268 90 14} box FLAT_BOX type {Horz Knob} labelsize 10 maximum 127 step 1 + code0 {o->init("Pcenterfreq", 'i');} + class Fl_Osc_Slider } - Fl_Dial octavesfreq { - label {Oct.} + Fl_Slider octavesfreq { callback {octavesfreqvo->do_callback(); redrawPADnoteApply();} - xywh {280 265 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1 - code0 {o->init("Poctavesfreq");} - class Fl_Osc_Dial + xywh {260 286 90 14} box FLAT_BOX type {Horz Knob} labelsize 10 maximum 127 step 1 + code0 {o->init("Poctavesfreq", 'i');} + class Fl_Osc_Slider } Fl_Button {} { label C diff --git a/source/native-plugins/zynaddsubfx/UI/WidgetPDial.cpp b/source/native-plugins/zynaddsubfx/UI/WidgetPDial.cpp index 522be7430..9a52a6396 100644 --- a/source/native-plugins/zynaddsubfx/UI/WidgetPDial.cpp +++ b/source/native-plugins/zynaddsubfx/UI/WidgetPDial.cpp @@ -33,6 +33,8 @@ void WidgetPDial::setRounding(unsigned int digits) tipwin->setRounding(digits); } +#define MOD_MASK (FL_CTRL | FL_SHIFT) + int WidgetPDial::handle(int event) { double dragsize, min = minimum(), max = maximum(), result; @@ -47,25 +49,50 @@ int WidgetPDial::handle(int event) do_callback(); return 1; } - + + int old_mod_state; + switch(event) { case FL_PUSH: + mod_state = Fl::event_state() & MOD_MASK; if (integer_step) setRounding(0); - else if (Fl::event_shift()) + else if (mod_state == MOD_MASK) + setRounding(5); + else if (mod_state == FL_SHIFT) setRounding(4); else - setRounding(Fl::event_button1() ? 2 : 3); + setRounding((Fl::event_button3() || mod_state & FL_CTRL) + ? 3 : 2); oldvalue = value(); old_y = Fl::event_y(); case FL_DRAG: getPos(); + old_mod_state = mod_state; + mod_state = Fl::event_state() & MOD_MASK; + if (old_mod_state != mod_state) { + oldvalue = value(); + old_y = Fl::event_y(); + if (integer_step) + setRounding(0); + else if (mod_state == MOD_MASK) + setRounding(5); + else if (mod_state == FL_SHIFT) + setRounding(4); + else + setRounding((Fl::event_button3() || mod_state & FL_CTRL) + ? 3 : 2); + break; + } dy = old_y - Fl::event_y(); - if (Fl::event_shift()) + if (!integer_step && mod_state == MOD_MASK) + dragsize = 200000.0f; + else if (!integer_step && mod_state == FL_SHIFT) dragsize = 20000.0f; else - dragsize = Fl::event_button1() ? 200.0f : 2000.0f; + dragsize = (Fl::event_button3() || mod_state & MOD_MASK) + ? 1000.0f : 200.0f; value(clamp(oldvalue + dy / dragsize * (max - min))); tipwin->showValue(transform(value())); @@ -74,19 +101,25 @@ int WidgetPDial::handle(int event) do_callback(); return 1; case FL_MOUSEWHEEL: - if (Fl::belowmouse() != this) + if (Fl::event_buttons() || Fl::belowmouse() != this) return 1; + mod_state = Fl::event_state() & MOD_MASK; dy = - Fl::event_dy(); if (integer_step) { setRounding(0); - result = (int)(value() + dy * (Fl::event_ctrl() ? 1 : 8)); + result = (int)(value() + + dy * ((Fl::event_ctrl() || + Fl::event_shift()) ? 1 : 8)); } else { float dragsize; - if (Fl::event_shift()) { + if (mod_state == MOD_MASK) { + dragsize = 100000.0; + setRounding(5); + } else if (mod_state == FL_SHIFT) { dragsize = 10000.0; setRounding(4); - } else if (Fl::event_ctrl()) { + } else if (mod_state == FL_CTRL) { dragsize = 1000.0; setRounding(3); } else { @@ -121,7 +154,6 @@ int WidgetPDial::handle(int event) if(this->when() == 0) do_callback(); return 1; - break; } return 0; //#endif diff --git a/source/native-plugins/zynaddsubfx/UI/WidgetPDial.h b/source/native-plugins/zynaddsubfx/UI/WidgetPDial.h index 534e3d7c1..faf95141f 100644 --- a/source/native-plugins/zynaddsubfx/UI/WidgetPDial.h +++ b/source/native-plugins/zynaddsubfx/UI/WidgetPDial.h @@ -31,5 +31,6 @@ class WidgetPDial:public Fl_Dial class TipWin * tipwin; float value_offset; float value_scale; + int mod_state; }; #endif diff --git a/source/native-plugins/zynaddsubfx/UI/guimain.cpp b/source/native-plugins/zynaddsubfx/UI/guimain.cpp index 0d06f0c08..36cb9600c 100644 --- a/source/native-plugins/zynaddsubfx/UI/guimain.cpp +++ b/source/native-plugins/zynaddsubfx/UI/guimain.cpp @@ -89,15 +89,25 @@ class MasterUI *ui=0; static Fl_Tiled_Image *module_backdrop; #endif -int undo_redo_handler(int) +int kb_shortcut_handler(int) { const bool undo_ = Fl::event_ctrl() && Fl::event_key() == 'z'; const bool redo = Fl::event_ctrl() && Fl::event_key() == 'r'; + const bool show = Fl::event_ctrl() && Fl::event_shift() && + Fl::event_key() == 's'; + const bool panel = Fl::event_ctrl() && Fl::event_shift() && + Fl::event_key() == 'p'; if(undo_) ui->osc->write("/undo", ""); else if(redo) ui->osc->write("/redo", ""); - return undo_ || redo; + else if (show) { + ui->simplemasterwindow->hide(); + ui->masterwindow->show(); + } + else if (panel) + ui->panelwindow->show(); + return undo_ || redo || show; } void @@ -176,7 +186,7 @@ ui_handle_t GUI::createUi(Fl_Osc_Interface *osc, void *exit) //tree->osc = osc; //midi_win->show(); - Fl::add_handler(undo_redo_handler); + Fl::add_handler(kb_shortcut_handler); return (void*) (ui = new MasterUI((int*)exit, osc)); } void GUI::destroyUi(ui_handle_t ui) @@ -511,7 +521,7 @@ Fl_Osc_Interface *GUI::genOscInterface(MiddleWare *) return new UI_Interface(); } -rtosc::ThreadLink lo_buffer(4096, 1000); +rtosc::ThreadLink lo_buffer(4096*2, 1000); static void liblo_error_cb(int i, const char *m, const char *loc) { diff --git a/source/native-plugins/zynaddsubfx/main.cpp b/source/native-plugins/zynaddsubfx/main.cpp index ab8cdacbd..804c39b08 100644 --- a/source/native-plugins/zynaddsubfx/main.cpp +++ b/source/native-plugins/zynaddsubfx/main.cpp @@ -135,7 +135,7 @@ int main(int argc, char *argv[]) << "\nZynAddSubFX - Copyright (c) 2002-2013 Nasca Octavian Paul and others" << endl; cerr - << " Copyright (c) 2009-2014 Mark McCurry [active maintainer]" + << " Copyright (c) 2009-2015 Mark McCurry [active maintainer]" << endl; cerr << "Compiled: " << __DATE__ << " " << __TIME__ << endl; cerr << "This program is free software (GNU GPL v2 or later) and \n";