diff --git a/plugins/zynaddsubfx/CMakeLists.txt b/plugins/zynaddsubfx/CMakeLists.txt index 2da4bd7ac..aad16f605 100644 --- a/plugins/zynaddsubfx/CMakeLists.txt +++ b/plugins/zynaddsubfx/CMakeLists.txt @@ -59,7 +59,6 @@ set(ZASF_CORE_LIBS zynaddsubfx_params zynaddsubfx_dsp zynaddsubfx_samples - zynaddsubfx_controls ) macro(unit_test NAME CXX_FILE FILES) @@ -67,7 +66,6 @@ endmacro(unit_test) add_subdirectory(src/Misc) add_subdirectory(src/Input) -add_subdirectory(src/Controls) add_subdirectory(src/Synth) add_subdirectory(src/Output) add_subdirectory(src/Seq) @@ -75,6 +73,7 @@ add_subdirectory(src/Effects) add_subdirectory(src/Params) add_subdirectory(src/DSP) add_subdirectory(src/Samples) +add_subdirectory(src/Tests) ADD_LIBRARY(ZynAddSubFxCore SHARED LocalZynAddSubFx.cpp) TARGET_LINK_LIBRARIES(ZynAddSubFxCore ${ZASF_CORE_LIBS} ${FFTW3F_LIBRARIES} ${QT_LIBRARIES} -lz -lpthread) diff --git a/plugins/zynaddsubfx/src/Controls/CMakeLists.txt b/plugins/zynaddsubfx/src/Controls/CMakeLists.txt deleted file mode 100644 index 07ee3eaf4..000000000 --- a/plugins/zynaddsubfx/src/Controls/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -set(zynaddsubfx_controls_SRCS - Control.cpp - DelayCtl.cpp -) - -add_library(zynaddsubfx_controls STATIC - ${zynaddsubfx_controls_SRCS} - ) diff --git a/plugins/zynaddsubfx/src/Controls/Control.cpp b/plugins/zynaddsubfx/src/Controls/Control.cpp deleted file mode 100644 index d7cf5cb9d..000000000 --- a/plugins/zynaddsubfx/src/Controls/Control.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - ZynAddSubFX - a software synthesizer - - Control.C - Control base class - Copyright (C) 2009-2009 Mark McCurry - Author: Mark McCurry - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License - as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License (version 2 or later) for more details. - - You should have received a copy of the GNU General Public License (version 2) - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*/ -#include "Control.h" - -Control::Control(char ndefaultval) - :defaultval(ndefaultval), lockqueue(-1), locked(false) -{} - -void Control::lock() -{ - locked = true; - lockqueue = -1; -} - -void Control::ulock() -{ - if(locked && (lockqueue >= 0)) - setmVal(lockqueue); - locked = false; -} - diff --git a/plugins/zynaddsubfx/src/Controls/Control.h b/plugins/zynaddsubfx/src/Controls/Control.h deleted file mode 100644 index 931a4745c..000000000 --- a/plugins/zynaddsubfx/src/Controls/Control.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - ZynAddSubFX - a software synthesizer - - Control.h - Control base class - Copyright (C) 2009-2009 Mark McCurry - Author: Mark McCurry - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License - as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License (version 2 or later) for more details. - - You should have received a copy of the GNU General Public License (version 2) - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*/ -#ifndef CONTROL_H -#define CONTROL_H -#include -/**A control for a parameter within the program*/ -class Control -{ - public: - Control(char ndefaultval); /**\todo create proper initialization list*/ - ~Control() {} - /**Return the string, which represents the internal value - * @return a string representation of the current value*/ - virtual std::string getString() const = 0; - /**Set the Control to the given value - * @param nval A number 0-127*/ - virtual void setmVal(char nval) = 0; - /**Return the midi value (aka the char) - * @return the current value*/ - virtual char getmVal() const = 0; - /** Will lock the Control until it is ulocked - * - * Locking a Control will Stop it from having - * its internal data altered*/ - void lock(); - /** Will unlock the Control - * - * This will also update the Control - * if something attempted to update it while it was locked*/ - void ulock(); - private: - char defaultval; /** - -DelayCtl::DelayCtl() - :Control(64), value(64 / 127.0 * 1.5) {} /**\todo finishme*/ - -std::string DelayCtl::getString() const -{ - std::ostringstream buf; - buf << value; - return buf.str() + " Seconds"; -} - -void DelayCtl::setmVal(char nval) -{ - /**\todo add locking code*/ - //value=1+(int)(nval/127.0*SAMPLE_RATE*1.5);//0 .. 1.5 sec - value = (nval / 127.0 * 1.5); //0 .. 1.5 sec -} - -char DelayCtl::getmVal() const -{ - return (char)(value / 1.5 * 127.0); -} - -float DelayCtl::getiVal() const -{ - return value; -} - diff --git a/plugins/zynaddsubfx/src/Controls/DelayCtl.h b/plugins/zynaddsubfx/src/Controls/DelayCtl.h deleted file mode 100644 index e63020876..000000000 --- a/plugins/zynaddsubfx/src/Controls/DelayCtl.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - ZynAddSubFX - a software synthesizer - - DelayCtl.h - Control For Delays - Copyright (C) 2009-2009 Mark McCurry - Author: Mark McCurry - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License - as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License (version 2 or later) for more details. - - You should have received a copy of the GNU General Public License (version 2) - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*/ -#include "Control.h" - -#ifndef DELAYCTL_H -#define DELAYCTL_H -/**A Control for Delays - * - * Will vary from 0 seconds to 1.5 seconds*/ -class DelayCtl:public Control -{ - public: - DelayCtl(); - ~DelayCtl() {} - std::string getString() const; - void setmVal(char nval); - char getmVal() const; - float getiVal() const; - private: - float value; -}; - -#endif - diff --git a/plugins/zynaddsubfx/src/DSP/AnalogFilter.cpp b/plugins/zynaddsubfx/src/DSP/AnalogFilter.cpp index 2c2ed5525..bb1ad75c8 100644 --- a/plugins/zynaddsubfx/src/DSP/AnalogFilter.cpp +++ b/plugins/zynaddsubfx/src/DSP/AnalogFilter.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - AnalogFilter.C - Several analog filters (lowpass, highpass...) + AnalogFilter.cpp - Several analog filters (lowpass, highpass...) Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul diff --git a/plugins/zynaddsubfx/src/DSP/CMakeLists.txt b/plugins/zynaddsubfx/src/DSP/CMakeLists.txt index c13cd316c..263a1babb 100644 --- a/plugins/zynaddsubfx/src/DSP/CMakeLists.txt +++ b/plugins/zynaddsubfx/src/DSP/CMakeLists.txt @@ -4,7 +4,7 @@ set(zynaddsubfx_dsp_SRCS Filter.cpp FormantFilter.cpp SVFilter.cpp - Unison.cpp + Unison.cpp ) add_library(zynaddsubfx_dsp STATIC diff --git a/plugins/zynaddsubfx/src/DSP/Filter.cpp b/plugins/zynaddsubfx/src/DSP/Filter.cpp index d95abe448..c6a3ce976 100644 --- a/plugins/zynaddsubfx/src/DSP/Filter.cpp +++ b/plugins/zynaddsubfx/src/DSP/Filter.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - Filter.C - Filters, uses analog,formant,etc. filters + Filter.cpp - Filters, uses analog,formant,etc. filters Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul diff --git a/plugins/zynaddsubfx/src/DSP/FormantFilter.cpp b/plugins/zynaddsubfx/src/DSP/FormantFilter.cpp index 529c210c2..6d6771901 100644 --- a/plugins/zynaddsubfx/src/DSP/FormantFilter.cpp +++ b/plugins/zynaddsubfx/src/DSP/FormantFilter.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - FormantFilter.C - formant filters + FormantFilter.cpp - formant filters Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul diff --git a/plugins/zynaddsubfx/src/DSP/SVFilter.cpp b/plugins/zynaddsubfx/src/DSP/SVFilter.cpp index d79c80fa3..636835a8c 100644 --- a/plugins/zynaddsubfx/src/DSP/SVFilter.cpp +++ b/plugins/zynaddsubfx/src/DSP/SVFilter.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - SVFilter.C - Several state-variable filters + SVFilter.cpp - Several state-variable filters Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul diff --git a/plugins/zynaddsubfx/src/Effects/Alienwah.cpp b/plugins/zynaddsubfx/src/Effects/Alienwah.cpp index fb07d4f11..9d13ea8c1 100644 --- a/plugins/zynaddsubfx/src/Effects/Alienwah.cpp +++ b/plugins/zynaddsubfx/src/Effects/Alienwah.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - Alienwah.C - "AlienWah" effect + Alienwah.cpp - "AlienWah" effect Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul @@ -46,7 +46,7 @@ Alienwah::~Alienwah() /* * Apply the effect */ -void Alienwah::out(REALTYPE *smpsl, REALTYPE *smpsr) +void Alienwah::out(const Stereo &smp) { REALTYPE lfol, lfor; //Left/Right LFOs complex clfol, clfor, out, tmp; @@ -67,7 +67,7 @@ void Alienwah::out(REALTYPE *smpsl, REALTYPE *smpsr) tmp = clfol * x + oldclfol * x1; out = tmp * oldl[oldk]; - out.real() += (1 - fabs(fb)) * smpsr[i] * (1.0 - panning); + out.real() += (1 - fabs(fb)) * smp.l[i] * (1.0 - panning); oldl[oldk] = out; REALTYPE l = out.real() * 10.0 * (fb + 0.1); @@ -76,7 +76,7 @@ void Alienwah::out(REALTYPE *smpsl, REALTYPE *smpsr) tmp = clfor * x + oldclfor * x1; out = tmp * oldr[oldk]; - out.real() += (1 - fabs(fb)) * smpsr[i] * (1.0 - panning); + out.real() += (1 - fabs(fb)) * smp.r[i] * (1.0 - panning); oldr[oldk] = out; REALTYPE r = out.real() * 10.0 * (fb + 0.1); @@ -110,13 +110,13 @@ void Alienwah::cleanup() * Parameter control */ -void Alienwah::setdepth(const unsigned char &Pdepth) +void Alienwah::setdepth(unsigned char Pdepth) { this->Pdepth = Pdepth; depth = (Pdepth / 127.0); } -void Alienwah::setfb(const unsigned char &Pfb) +void Alienwah::setfb(unsigned char Pfb) { this->Pfb = Pfb; fb = fabs((Pfb - 64.0) / 64.1); @@ -127,7 +127,7 @@ void Alienwah::setfb(const unsigned char &Pfb) fb = -fb; } -void Alienwah::setvolume(const unsigned char &Pvolume) +void Alienwah::setvolume(unsigned char Pvolume) { this->Pvolume = Pvolume; outvolume = Pvolume / 127.0; @@ -137,25 +137,25 @@ void Alienwah::setvolume(const unsigned char &Pvolume) volume = outvolume; } -void Alienwah::setpanning(const unsigned char &Ppanning) +void Alienwah::setpanning(unsigned char Ppanning) { this->Ppanning = Ppanning; panning = Ppanning / 127.0; } -void Alienwah::setlrcross(const unsigned char &Plrcross) +void Alienwah::setlrcross(unsigned char Plrcross) { this->Plrcross = Plrcross; lrcross = Plrcross / 127.0; } -void Alienwah::setphase(const unsigned char &Pphase) +void Alienwah::setphase(unsigned char Pphase) { this->Pphase = Pphase; phase = (Pphase - 64.0) / 64.0 * PI; } -void Alienwah::setdelay(const unsigned char &Pdelay) +void Alienwah::setdelay(unsigned char Pdelay) { if(oldl != NULL) delete [] oldl; @@ -190,12 +190,12 @@ void Alienwah::setpreset(unsigned char npreset) for(int n = 0; n < PRESET_SIZE; n++) changepar(n, presets[npreset][n]); if(insertion == 0) - changepar(0, presets[npreset][0] / 2); //lower the volume if this is system effect + changepar(0, presets[npreset][0] / 2); //lower the volume if this is system effect Ppreset = npreset; } -void Alienwah::changepar(const int &npar, const unsigned char &value) +void Alienwah::changepar(int npar, unsigned char value) { switch(npar) { case 0: @@ -238,7 +238,7 @@ void Alienwah::changepar(const int &npar, const unsigned char &value) } } -unsigned char Alienwah::getpar(const int &npar) const +unsigned char Alienwah::getpar(int npar) const { switch(npar) { case 0: diff --git a/plugins/zynaddsubfx/src/Effects/Alienwah.h b/plugins/zynaddsubfx/src/Effects/Alienwah.h index 175c41f24..9ad695403 100644 --- a/plugins/zynaddsubfx/src/Effects/Alienwah.h +++ b/plugins/zynaddsubfx/src/Effects/Alienwah.h @@ -46,11 +46,11 @@ class Alienwah:public Effect REALTYPE *const efxoutl_, REALTYPE *const efxoutr_); ~Alienwah(); - void out(REALTYPE *const smpsl, REALTYPE *const smpsr); + void out(const Stereo &smp); void setpreset(unsigned char npreset); - void changepar(const int &npar, const unsigned char &value); - unsigned char getpar(const int &npar) const; + void changepar(int npar, unsigned char value); + unsigned char getpar(int npar) const; void cleanup(); private: @@ -66,13 +66,13 @@ class Alienwah:public Effect //Control Parameters - void setvolume(const unsigned char &Pvolume); - void setpanning(const unsigned char &Ppanning); - void setdepth(const unsigned char &Pdepth); - void setfb(const unsigned char &Pfb); - void setlrcross(const unsigned char &Plrcross); - void setdelay(const unsigned char &Pdelay); - void setphase(const unsigned char &Pphase); + void setvolume(unsigned char Pvolume); + void setpanning(unsigned char Ppanning); + void setdepth(unsigned char Pdepth); + void setfb(unsigned char Pfb); + void setlrcross(unsigned char Plrcross); + void setdelay(unsigned char Pdelay); + void setphase(unsigned char Pphase); //Internal Values REALTYPE panning, fb, depth, lrcross, phase; diff --git a/plugins/zynaddsubfx/src/Effects/Chorus.cpp b/plugins/zynaddsubfx/src/Effects/Chorus.cpp index 708c0cd75..b39c0032b 100644 --- a/plugins/zynaddsubfx/src/Effects/Chorus.cpp +++ b/plugins/zynaddsubfx/src/Effects/Chorus.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - Chorus.C - Chorus and Flange effects + Chorus.cpp - Chorus and Flange effects Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul @@ -35,9 +35,6 @@ Chorus::Chorus(const int &insertion_, { dlk = 0; drk = 0; - //maxdelay=(int)(MAX_CHORUS_DELAY/1000.0*SAMPLE_RATE); - //delayl=new REALTYPE[maxdelay]; - //delayr=new REALTYPE[maxdelay]; setpreset(Ppreset); @@ -65,24 +62,13 @@ REALTYPE Chorus::getdelay(REALTYPE xlfo) if((result + 0.5) >= maxdelay) { cerr << - "WARNING: Chorus.C::getdelay(..) too big delay (see setdelay and setdepth funcs.)\n"; + "WARNING: Chorus.cpp::getdelay(..) too big delay (see setdelay and setdepth funcs.)\n"; result = maxdelay - 1.0; } return result; } -/* - * Apply the effect - */ -void Chorus::out(REALTYPE *smpsl, REALTYPE *smpsr) -{ - const Stereo input(AuSample(SOUND_BUFFER_SIZE, smpsl), AuSample( - SOUND_BUFFER_SIZE, - smpsr)); - out(input); -} - -void Chorus::out(const Stereo &input) +void Chorus::out(const Stereo &input) { const REALTYPE one = 1.0; dl1 = dl2; @@ -92,14 +78,14 @@ void Chorus::out(const Stereo &input) dl2 = getdelay(lfol); dr2 = getdelay(lfor); - for(int i = 0; i < input.l().size(); i++) { - REALTYPE inl = input.l()[i]; - REALTYPE inr = input.r()[i]; + for(int i = 0; i < SOUND_BUFFER_SIZE; i++) { + REALTYPE inl = input.l[i]; + REALTYPE inr = input.r[i]; //LRcross Stereo tmpc(inl, inr); //REALTYPE r=inr; - inl = tmpc.l() * (1.0 - lrcross) + tmpc.r() * lrcross; - inr = tmpc.r() * (1.0 - lrcross) + tmpc.l() * lrcross; + inl = tmpc.l * (1.0 - lrcross) + tmpc.r * lrcross; + inr = tmpc.r * (1.0 - lrcross) + tmpc.l * lrcross; //Left channel @@ -114,9 +100,9 @@ void Chorus::out(const Stereo &input) dlhi2 = (dlhi - 1 + maxdelay) % maxdelay; dllo = 1.0 - fmod(tmp, one); - efxoutl[i] = delaySample.l()[dlhi2] * dllo + delaySample.l()[dlhi] + efxoutl[i] = delaySample.l[dlhi2] * dllo + delaySample.l[dlhi] * (1.0 - dllo); - delaySample.l()[dlk] = inl + efxoutl[i] * fb; + delaySample.l[dlk] = inl + efxoutl[i] * fb; //Right channel @@ -131,20 +117,20 @@ void Chorus::out(const Stereo &input) dlhi2 = (dlhi - 1 + maxdelay) % maxdelay; dllo = 1.0 - fmod(tmp, one); - efxoutr[i] = delaySample.r()[dlhi2] * dllo + delaySample.r()[dlhi] + efxoutr[i] = delaySample.r[dlhi2] * dllo + delaySample.r[dlhi] * (1.0 - dllo); - delaySample.r()[dlk] = inr + efxoutr[i] * fb; + delaySample.r[dlk] = inr + efxoutr[i] * fb; } if(Poutsub != 0) - for(int i = 0; i < input.l().size(); i++) { + for(int i = 0; i < SOUND_BUFFER_SIZE; i++) { efxoutl[i] *= -1.0; efxoutr[i] *= -1.0; } ; - for(int i = 0; i < input.l().size(); i++) { + for(int i = 0; i < SOUND_BUFFER_SIZE; i++) { efxoutl[i] *= panning; efxoutr[i] *= (1.0 - panning); } @@ -155,31 +141,31 @@ void Chorus::out(const Stereo &input) */ void Chorus::cleanup() { - delaySample.l().clear(); - delaySample.r().clear(); + delaySample.l.clear(); + delaySample.r.clear(); } /* * Parameter control */ -void Chorus::setdepth(const unsigned char &Pdepth) +void Chorus::setdepth(unsigned char Pdepth) { this->Pdepth = Pdepth; depth = (pow(8.0, (Pdepth / 127.0) * 2.0) - 1.0) / 1000.0; //seconds } -void Chorus::setdelay(const unsigned char &Pdelay) +void Chorus::setdelay(unsigned char Pdelay) { this->Pdelay = Pdelay; delay = (pow(10.0, (Pdelay / 127.0) * 2.0) - 1.0) / 1000.0; //seconds } -void Chorus::setfb(const unsigned char &Pfb) +void Chorus::setfb(unsigned char Pfb) { this->Pfb = Pfb; fb = (Pfb - 64.0) / 64.1; } -void Chorus::setvolume(const unsigned char &Pvolume) +void Chorus::setvolume(unsigned char Pvolume) { this->Pvolume = Pvolume; outvolume = Pvolume / 127.0; @@ -189,13 +175,13 @@ void Chorus::setvolume(const unsigned char &Pvolume) volume = outvolume; } -void Chorus::setpanning(const unsigned char &Ppanning) +void Chorus::setpanning(unsigned char Ppanning) { this->Ppanning = Ppanning; panning = Ppanning / 127.0; } -void Chorus::setlrcross(const unsigned char &Plrcross) +void Chorus::setlrcross(unsigned char Plrcross) { this->Plrcross = Plrcross; lrcross = Plrcross / 127.0; @@ -236,7 +222,7 @@ void Chorus::setpreset(unsigned char npreset) } -void Chorus::changepar(const int &npar, const unsigned char &value) +void Chorus::changepar(int npar, unsigned char value) { switch(npar) { case 0: @@ -288,7 +274,7 @@ void Chorus::changepar(const int &npar, const unsigned char &value) } } -unsigned char Chorus::getpar(const int &npar) const +unsigned char Chorus::getpar(int npar) const { switch(npar) { case 0: diff --git a/plugins/zynaddsubfx/src/Effects/Chorus.h b/plugins/zynaddsubfx/src/Effects/Chorus.h index 748ce5eaf..2aeb1a191 100644 --- a/plugins/zynaddsubfx/src/Effects/Chorus.h +++ b/plugins/zynaddsubfx/src/Effects/Chorus.h @@ -25,7 +25,7 @@ #include "../globals.h" #include "Effect.h" #include "EffectLFO.h" -#include "../Samples/AuSample.h" +#include "../Samples/Sample.h" #include "../Misc/Stereo.h" #define MAX_CHORUS_DELAY 250.0 //ms @@ -37,8 +37,7 @@ class Chorus:public Effect Chorus(const int &insetion_, REALTYPE *efxoutl_, REALTYPE *efxoutr_); /**Destructor*/ ~Chorus(); - void out(REALTYPE *smpsl, REALTYPE *smpsr); - void out(const Stereo &input); + void out(const Stereo &input); void setpreset(unsigned char npreset); /** * Sets the value of the chosen variable @@ -58,7 +57,7 @@ class Chorus:public Effect * @param npar number of chosen parameter * @param value the new value */ - void changepar(const int &npar, const unsigned char &value); + void changepar(int npar, unsigned char value); /** * Gets the value of the chosen variable * @@ -77,7 +76,7 @@ class Chorus:public Effect * @param npar number of chosen parameter * @return the value of the parameter */ - unsigned char getpar(const int &npar) const; + unsigned char getpar(int npar) const; void cleanup(); private: @@ -94,19 +93,18 @@ class Chorus:public Effect //Parameter Controls - void setvolume(const unsigned char &Pvolume); - void setpanning(const unsigned char &Ppanning); - void setdepth(const unsigned char &Pdepth); - void setdelay(const unsigned char &Pdelay); - void setfb(const unsigned char &Pfb); - void setlrcross(const unsigned char &Plrcross); + void setvolume(unsigned char Pvolume); + void setpanning(unsigned char Ppanning); + void setdepth(unsigned char Pdepth); + void setdelay(unsigned char Pdelay); + void setfb(unsigned char Pfb); + void setlrcross(unsigned char Plrcross); //Internal Values REALTYPE depth, delay, fb, lrcross, panning; REALTYPE dl1, dl2, dr1, dr2, lfol, lfor; int maxdelay; - Stereo delaySample; - //REALTYPE *delayl,*delayr; + Stereo delaySample; int dlk, drk, dlhi, dlhi2; REALTYPE getdelay(REALTYPE xlfo); REALTYPE dllo, mdel; diff --git a/plugins/zynaddsubfx/src/Effects/Distorsion.cpp b/plugins/zynaddsubfx/src/Effects/Distorsion.cpp index 61fe9966b..a0b6a2e62 100644 --- a/plugins/zynaddsubfx/src/Effects/Distorsion.cpp +++ b/plugins/zynaddsubfx/src/Effects/Distorsion.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - Distorsion.C - Distorsion effect + Distorsion.cpp - Distorsion effect Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul @@ -260,7 +260,7 @@ void Distorsion::applyfilters(REALTYPE *efxoutl, REALTYPE *efxoutr) /* * Effect output */ -void Distorsion::out(REALTYPE *smpsl, REALTYPE *smpsr) +void Distorsion::out(const Stereo &smp) { int i; REALTYPE l, r, lout, rout; @@ -271,14 +271,14 @@ void Distorsion::out(REALTYPE *smpsl, REALTYPE *smpsr) if(Pstereo != 0) { //Stereo for(i = 0; i < SOUND_BUFFER_SIZE; i++) { - efxoutl[i] = smpsl[i] * inputvol * panning; - efxoutr[i] = smpsr[i] * inputvol * (1.0 - panning); + efxoutl[i] = smp.l[i] * inputvol * panning; + efxoutr[i] = smp.r[i] * inputvol * (1.0 - panning); } } else { for(i = 0; i < SOUND_BUFFER_SIZE; i++) efxoutl[i] = - (smpsl[i] * panning + smpsr[i] * (1.0 - panning)) * inputvol; + (smp.l[i] * panning + smp.r[i] * (1.0 - panning)) * inputvol; ; } @@ -315,7 +315,7 @@ void Distorsion::out(REALTYPE *smpsl, REALTYPE *smpsr) /* * Parameter control */ -void Distorsion::setvolume(const unsigned char &Pvolume) +void Distorsion::setvolume(unsigned char Pvolume) { this->Pvolume = Pvolume; @@ -330,20 +330,20 @@ void Distorsion::setvolume(const unsigned char &Pvolume) cleanup(); } -void Distorsion::setpanning(const unsigned char &Ppanning) +void Distorsion::setpanning(unsigned char Ppanning) { this->Ppanning = Ppanning; panning = (Ppanning + 0.5) / 127.0; } -void Distorsion::setlrcross(const unsigned char &Plrcross) +void Distorsion::setlrcross(unsigned char Plrcross) { this->Plrcross = Plrcross; lrcross = Plrcross / 127.0 * 1.0; } -void Distorsion::setlpf(const unsigned char &Plpf) +void Distorsion::setlpf(unsigned char Plpf) { this->Plpf = Plpf; REALTYPE fr = exp(pow(Plpf / 127.0, 0.5) * log(25000.0)) + 40; @@ -351,7 +351,7 @@ void Distorsion::setlpf(const unsigned char &Plpf) lpfr->setfreq(fr); } -void Distorsion::sethpf(const unsigned char &Phpf) +void Distorsion::sethpf(unsigned char Phpf) { this->Phpf = Phpf; REALTYPE fr = exp(pow(Phpf / 127.0, 0.5) * log(25000.0)) + 20.0; @@ -391,7 +391,7 @@ void Distorsion::setpreset(unsigned char npreset) } -void Distorsion::changepar(const int &npar, const unsigned char &value) +void Distorsion::changepar(int npar, unsigned char value) { switch(npar) { case 0: @@ -439,7 +439,7 @@ void Distorsion::changepar(const int &npar, const unsigned char &value) } } -unsigned char Distorsion::getpar(const int &npar) const +unsigned char Distorsion::getpar(int npar) const { switch(npar) { case 0: diff --git a/plugins/zynaddsubfx/src/Effects/Distorsion.h b/plugins/zynaddsubfx/src/Effects/Distorsion.h index 8c082f13f..472af3ffd 100644 --- a/plugins/zynaddsubfx/src/Effects/Distorsion.h +++ b/plugins/zynaddsubfx/src/Effects/Distorsion.h @@ -38,32 +38,32 @@ class Distorsion:public Effect public: Distorsion(const int &insertion, REALTYPE *efxoutl_, REALTYPE *efxoutr_); ~Distorsion(); - void out(REALTYPE *smpsl, REALTYPE *smpr); + void out(const Stereo &smp); void setpreset(unsigned char npreset); - void changepar(const int &npar, const unsigned char &value); - unsigned char getpar(const int &npar) const; + void changepar(int npar, unsigned char value); + unsigned char getpar(int npar) const; void cleanup(); void applyfilters(REALTYPE *efxoutl, REALTYPE *efxoutr); private: //Parametrii - unsigned char Pvolume; //Volumul or E/R - unsigned char Ppanning; //Panning - unsigned char Plrcross; // L/R Mixing - unsigned char Pdrive; //the input amplification - unsigned char Plevel; //the output amplification - unsigned char Ptype; //Distorsion type - unsigned char Pnegate; //if the input is negated - unsigned char Plpf; //lowpass filter - unsigned char Phpf; //highpass filter - unsigned char Pstereo; //0=mono,1=stereo + unsigned char Pvolume; //Volume or E/R + unsigned char Ppanning; //Panning + unsigned char Plrcross; // L/R Mixing + unsigned char Pdrive; //the input amplification + unsigned char Plevel; //the output amplification + unsigned char Ptype; //Distorsion type + unsigned char Pnegate; //if the input is negated + unsigned char Plpf; //lowpass filter + unsigned char Phpf; //highpass filter + unsigned char Pstereo; //0=mono,1=stereo unsigned char Pprefiltering; //if you want to do the filtering before the distorsion - void setvolume(const unsigned char &Pvolume); - void setpanning(const unsigned char &Ppanning); - void setlrcross(const unsigned char &Plrcross); - void setlpf(const unsigned char &Plpf); - void sethpf(const unsigned char &Phpf); + void setvolume(unsigned char Pvolume); + void setpanning(unsigned char Ppanning); + void setlrcross(unsigned char Plrcross); + void setlpf(unsigned char Plpf); + void sethpf(unsigned char Phpf); //Real Parameters REALTYPE panning, lrcross; diff --git a/plugins/zynaddsubfx/src/Effects/DynamicFilter.cpp b/plugins/zynaddsubfx/src/Effects/DynamicFilter.cpp index 1b2bb1eb0..b60f40142 100644 --- a/plugins/zynaddsubfx/src/Effects/DynamicFilter.cpp +++ b/plugins/zynaddsubfx/src/Effects/DynamicFilter.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - DynamicFilter.C - "WahWah" effect and others + DynamicFilter.cpp - "WahWah" effect and others Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul @@ -46,7 +46,7 @@ DynamicFilter::~DynamicFilter() /* * Apply the effect */ -void DynamicFilter::out(REALTYPE *smpsl, REALTYPE *smpsr) +void DynamicFilter::out(const Stereo &smp) { int i; if(filterpars->changed) { @@ -62,10 +62,10 @@ void DynamicFilter::out(REALTYPE *smpsl, REALTYPE *smpsr) REALTYPE q = filterpars->getq(); for(i = 0; i < SOUND_BUFFER_SIZE; i++) { - efxoutl[i] = smpsl[i]; - efxoutr[i] = smpsr[i]; + efxoutl[i] = smp.l[i]; + efxoutr[i] = smp.r[i]; - REALTYPE x = (fabs(smpsl[i]) + fabs(smpsr[i])) * 0.5; + REALTYPE x = (fabs(smp.l[i]) + fabs(smp.l[i])) * 0.5; ms1 = ms1 * (1.0 - ampsmooth) + x * ampsmooth + 1e-10; } @@ -110,14 +110,14 @@ void DynamicFilter::cleanup() * Parameter control */ -void DynamicFilter::setdepth(const unsigned char &Pdepth) +void DynamicFilter::setdepth(unsigned char Pdepth) { this->Pdepth = Pdepth; depth = pow((Pdepth / 127.0), 2.0); } -void DynamicFilter::setvolume(const unsigned char &Pvolume) +void DynamicFilter::setvolume(unsigned char Pvolume) { this->Pvolume = Pvolume; outvolume = Pvolume / 127.0; @@ -127,14 +127,14 @@ void DynamicFilter::setvolume(const unsigned char &Pvolume) volume = outvolume; } -void DynamicFilter::setpanning(const unsigned char &Ppanning) +void DynamicFilter::setpanning(unsigned char Ppanning) { this->Ppanning = Ppanning; panning = Ppanning / 127.0; } -void DynamicFilter::setampsns(const unsigned char &Pampsns) +void DynamicFilter::setampsns(unsigned char Pampsns) { ampsns = pow(Pampsns / 127.0, 2.5) * 10.0; if(Pampsnsinv != 0) @@ -270,7 +270,7 @@ void DynamicFilter::setpreset(unsigned char npreset) } -void DynamicFilter::changepar(const int &npar, const unsigned char &value) +void DynamicFilter::changepar(int npar, unsigned char value) { switch(npar) { case 0: @@ -312,7 +312,7 @@ void DynamicFilter::changepar(const int &npar, const unsigned char &value) } } -unsigned char DynamicFilter::getpar(const int &npar) const +unsigned char DynamicFilter::getpar(int npar) const { switch(npar) { case 0: diff --git a/plugins/zynaddsubfx/src/Effects/DynamicFilter.h b/plugins/zynaddsubfx/src/Effects/DynamicFilter.h index 2bb5fcd9b..6ce10f5ee 100644 --- a/plugins/zynaddsubfx/src/Effects/DynamicFilter.h +++ b/plugins/zynaddsubfx/src/Effects/DynamicFilter.h @@ -33,11 +33,11 @@ class DynamicFilter:public Effect public: DynamicFilter(int insetion_, REALTYPE *efxoutl_, REALTYPE *efxoutr_); ~DynamicFilter(); - void out(REALTYPE *smpsl, REALTYPE *smpsr); + void out(const Stereo &smp); void setpreset(unsigned char npreset); - void changepar(const int &npar, const unsigned char &value); - unsigned char getpar(const int &npar) const; + void changepar(int npar, unsigned char value); + unsigned char getpar(int npar) const; void cleanup(); // void setdryonly(); @@ -53,10 +53,10 @@ class DynamicFilter:public Effect unsigned char Pampsmooth; //how smooth the input amplitude changes the filter //Parameter Control - void setvolume(const unsigned char &Pvolume); - void setpanning(const unsigned char &Ppanning); - void setdepth(const unsigned char &Pdepth); - void setampsns(const unsigned char &Pampsns); + void setvolume(unsigned char Pvolume); + void setpanning(unsigned char Ppanning); + void setdepth(unsigned char Pdepth); + void setampsns(unsigned char Pampsns); void reinitfilter(); diff --git a/plugins/zynaddsubfx/src/Effects/EQ.cpp b/plugins/zynaddsubfx/src/Effects/EQ.cpp index 8ff71918d..59aa9f155 100644 --- a/plugins/zynaddsubfx/src/Effects/EQ.cpp +++ b/plugins/zynaddsubfx/src/Effects/EQ.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - EQ.C - EQ effect + EQ.cpp - EQ effect Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul @@ -45,9 +45,6 @@ EQ::EQ(const int &insertion_, REALTYPE *efxoutl_, REALTYPE *efxoutr_) EQ::~EQ() {} -/* - * Cleanup the effect - */ void EQ::cleanup() { for(int i = 0; i < MAX_EQ_BANDS; i++) { @@ -56,17 +53,12 @@ void EQ::cleanup() } } - - -/* - * Effect output - */ -void EQ::out(REALTYPE *smpsl, REALTYPE *smpsr) +void EQ::out(const Stereo &smp) { int i; for(i = 0; i < SOUND_BUFFER_SIZE; i++) { - efxoutl[i] = smpsl[i] * volume; - efxoutr[i] = smpsr[i] * volume; + efxoutl[i] = smp.l[i] * volume; + efxoutr[i] = smp.r[i] * volume; } for(i = 0; i < MAX_EQ_BANDS; i++) { @@ -81,7 +73,7 @@ void EQ::out(REALTYPE *smpsl, REALTYPE *smpsr) /* * Parameter control */ -void EQ::setvolume(const unsigned char &Pvolume) +void EQ::setvolume(unsigned char Pvolume) { this->Pvolume = Pvolume; @@ -113,7 +105,7 @@ void EQ::setpreset(unsigned char npreset) } -void EQ::changepar(const int &npar, const unsigned char &value) +void EQ::changepar(int npar, unsigned char value) { switch(npar) { case 0: @@ -167,7 +159,7 @@ void EQ::changepar(const int &npar, const unsigned char &value) } } -unsigned char EQ::getpar(const int &npar) const +unsigned char EQ::getpar(int npar) const { switch(npar) { case 0: diff --git a/plugins/zynaddsubfx/src/Effects/EQ.h b/plugins/zynaddsubfx/src/Effects/EQ.h index 6f4130cd1..7ac328404 100644 --- a/plugins/zynaddsubfx/src/Effects/EQ.h +++ b/plugins/zynaddsubfx/src/Effects/EQ.h @@ -33,17 +33,17 @@ class EQ:public Effect public: EQ(const int &insertion_, REALTYPE *efxoutl_, REALTYPE *efxoutr_); ~EQ(); - void out(REALTYPE *smpsl, REALTYPE *smpr); + void out(const Stereo &smp); void setpreset(unsigned char npreset); - void changepar(const int &npar, const unsigned char &value); - unsigned char getpar(const int &npar) const; + void changepar(int npar, unsigned char value); + unsigned char getpar(int npar) const; void cleanup(); REALTYPE getfreqresponse(REALTYPE freq); private: //Parameters unsigned char Pvolume; /** -#include #include "Echo.h" +#define MAX_DELAY 2 + Echo::Echo(const int &insertion_, REALTYPE *const efxoutl_, REALTYPE *const efxoutr_) :Effect(insertion_, efxoutl_, efxoutr_, NULL, 0), - Pvolume(50), Ppanning(64), //Pdelay(60), + Pvolume(50), Ppanning(64), Pdelay(60), Plrdelay(100), Plrcross(100), Pfb(40), Phidamp(60), - lrdelay(0), delaySample(1), old(0.0) + delayTime(1), lrdelay(0), avgDelay(0), + delay(new REALTYPE[(int)(MAX_DELAY * SAMPLE_RATE)], + new REALTYPE[(int)(MAX_DELAY * SAMPLE_RATE)]), + old(0.0), pos(0), delta(1), ndelta(1) { + initdelays(); setpreset(Ppreset); } -Echo::~Echo() {} +Echo::~Echo() +{ + delete[] delay.l; + delete[] delay.r; +} /* * Cleanup the effect */ void Echo::cleanup() { - delaySample.l().clear(); - delaySample.r().clear(); + memset(delay.l,0,MAX_DELAY*SAMPLE_RATE*sizeof(REALTYPE)); + memset(delay.r,0,MAX_DELAY*SAMPLE_RATE*sizeof(REALTYPE)); old = Stereo(0.0); } +inline int max(int a, int b) +{ + return a > b ? a : b; +} /* * Initialize the delays */ void Echo::initdelays() { - /**\todo make this adjust insted of destroy old delays*/ - kl = 0; - kr = 0; - dl = (int)(1 + delay.getiVal() * SAMPLE_RATE - lrdelay); - if(dl < 1) - dl = 1; - dr = (int)(1 + delay.getiVal() * SAMPLE_RATE + lrdelay); - if(dr < 1) - dr = 1; + cleanup(); + //number of seconds to delay left chan + float dl = avgDelay - lrdelay; - delaySample.l() = AuSample(dl); - delaySample.r() = AuSample(dr); + //number of seconds to delay right chan + float dr = avgDelay + lrdelay; - old = Stereo(0.0); + ndelta.l = max(1,(int) (dl * SAMPLE_RATE)); + ndelta.r = max(1,(int) (dr * SAMPLE_RATE)); } -/* - * Effect output - */ -void Echo::out(REALTYPE *const smpsl, REALTYPE *const smpsr) +void Echo::out(const Stereo &input) { - Stereo input(AuSample(SOUND_BUFFER_SIZE, smpsl), AuSample( - SOUND_BUFFER_SIZE, - smpsr)); - out(input); -} + REALTYPE ldl, rdl; -void Echo::out(const Stereo &input) -{ -//void Echo::out(const Stereo & input){ //ideal - REALTYPE l, r, ldl, rdl; /**\todo move l+r->? ldl+rdl->?*/ - - for(int i = 0; i < input.l().size(); i++) { - ldl = delaySample.l()[kl]; - rdl = delaySample.r()[kr]; - l = ldl * (1.0 - lrcross) + rdl * lrcross; - r = rdl * (1.0 - lrcross) + ldl * lrcross; - ldl = l; - rdl = r; + for(int i = 0; i < SOUND_BUFFER_SIZE; ++i) { + ldl = delay.l[pos.l]; + rdl = delay.r[pos.r]; + ldl = ldl * (1.0 - lrcross) + rdl * lrcross; + rdl = rdl * (1.0 - lrcross) + ldl * lrcross; efxoutl[i] = ldl * 2.0; efxoutr[i] = rdl * 2.0; - - ldl = input.l()[i] * panning - ldl * fb; - rdl = input.r()[i] * (1.0 - panning) - rdl * fb; + ldl = input.l[i] * panning - ldl * fb; + rdl = input.r[i] * (1.0 - panning) - rdl * fb; //LowPass Filter - delaySample.l()[kl] = ldl = ldl * hidamp + old.l() * (1.0 - hidamp); - delaySample.r()[kr] = rdl = rdl * hidamp + old.r() * (1.0 - hidamp); - old.l() = ldl; - old.r() = rdl; + old.l = delay.l[(pos.l+delta.l)%(MAX_DELAY * SAMPLE_RATE)] = ldl * hidamp + old.l * (1.0 - hidamp); + old.r = delay.r[(pos.r+delta.r)%(MAX_DELAY * SAMPLE_RATE)] = rdl * hidamp + old.r * (1.0 - hidamp); - if(++kl >= dl) - kl = 0; - if(++kr >= dr) - kr = 0; + //increment + ++pos.l;// += delta.l; + ++pos.r;// += delta.r; + + //ensure that pos is still in bounds + pos.l %= MAX_DELAY * SAMPLE_RATE; + pos.r %= MAX_DELAY * SAMPLE_RATE; + + //adjust delay if needed + delta.l = (15*delta.l + ndelta.l)/16; + delta.r = (15*delta.r + ndelta.r)/16; } } @@ -117,7 +117,7 @@ void Echo::out(const Stereo &input) /* * Parameter control */ -void Echo::setvolume(const unsigned char &Pvolume) +void Echo::setvolume(unsigned char Pvolume) { this->Pvolume = Pvolume; @@ -132,45 +132,44 @@ void Echo::setvolume(const unsigned char &Pvolume) cleanup(); } -void Echo::setpanning(const unsigned char &Ppanning) +void Echo::setpanning(unsigned char Ppanning) { this->Ppanning = Ppanning; panning = (Ppanning + 0.5) / 127.0; } -void Echo::setdelay(const unsigned char &Pdelay) +void Echo::setdelay(unsigned char Pdelay) { - delay.setmVal(Pdelay); - //this->Pdelay=Pdelay; - //delay=1+(int)(Pdelay/127.0*SAMPLE_RATE*1.5);//0 .. 1.5 sec + this->Pdelay=Pdelay; + avgDelay=(Pdelay/127.0*1.5);//0 .. 1.5 sec initdelays(); } -void Echo::setlrdelay(const unsigned char &Plrdelay) +void Echo::setlrdelay(unsigned char Plrdelay) { REALTYPE tmp; this->Plrdelay = Plrdelay; tmp = - (pow(2, fabs(Plrdelay - 64.0) / 64.0 * 9) - 1.0) / 1000.0 * SAMPLE_RATE; + (pow(2, fabs(Plrdelay - 64.0) / 64.0 * 9) - 1.0) / 1000.0; if(Plrdelay < 64.0) tmp = -tmp; - lrdelay = (int) tmp; + lrdelay = tmp; initdelays(); } -void Echo::setlrcross(const unsigned char &Plrcross) +void Echo::setlrcross(unsigned char Plrcross) { this->Plrcross = Plrcross; lrcross = Plrcross / 127.0 * 1.0; } -void Echo::setfb(const unsigned char &Pfb) +void Echo::setfb(unsigned char Pfb) { this->Pfb = Pfb; fb = Pfb / 128.0; } -void Echo::sethidamp(const unsigned char &Phidamp) +void Echo::sethidamp(unsigned char Phidamp) { this->Phidamp = Phidamp; hidamp = 1.0 - Phidamp / 127.0; @@ -213,7 +212,7 @@ void Echo::setpreset(unsigned char npreset) } -void Echo::changepar(const int &npar, const unsigned char &value) +void Echo::changepar(int npar, unsigned char value) { switch(npar) { case 0: @@ -240,7 +239,7 @@ void Echo::changepar(const int &npar, const unsigned char &value) } } -unsigned char Echo::getpar(const int &npar) const +unsigned char Echo::getpar(int npar) const { switch(npar) { case 0: @@ -250,7 +249,7 @@ unsigned char Echo::getpar(const int &npar) const return Ppanning; break; case 2: - return delay.getmVal(); + return Pdelay; break; case 3: return Plrdelay; diff --git a/plugins/zynaddsubfx/src/Effects/Echo.h b/plugins/zynaddsubfx/src/Effects/Echo.h index 4dbe40925..8842bd85d 100644 --- a/plugins/zynaddsubfx/src/Effects/Echo.h +++ b/plugins/zynaddsubfx/src/Effects/Echo.h @@ -25,9 +25,8 @@ #include "../globals.h" #include "Effect.h" -#include "../Samples/AuSample.h" #include "../Misc/Stereo.h" -#include "../Controls/DelayCtl.h" +#include "../Samples/Sample.h" /**Echo Effect*/ class Echo:public Effect @@ -51,15 +50,7 @@ class Echo:public Effect */ ~Echo(); - /** - * Outputs the echo to efxoutl and efxoutr - * @param smpsl Sample from Left channel - * @param smpsr Sample from Right channel - * \todo try to figure out if smpsl should be const *const - * or not (It should be) - */ - void out(REALTYPE *const smpsl, REALTYPE *const smpr); - void out(const Stereo &input); + void out(const Stereo &input); /** * Sets the state of Echo to the specified preset @@ -81,7 +72,7 @@ class Echo:public Effect * @param npar number of chosen parameter * @param value the new value */ - void changepar(const int &npar, const unsigned char &value); + void changepar(int npar, unsigned char value); /** * Gets the specified parameter @@ -97,7 +88,7 @@ class Echo:public Effect * @param npar number of chosen parameter * @return value of parameter */ - unsigned char getpar(const int &npar) const; + unsigned char getpar(int npar) const; int getnumparams(); @@ -108,31 +99,39 @@ class Echo:public Effect void setdryonly(); private: //Parameters - char Pvolume; /**<#1 Volume or Dry/Wetness*/ + char Pvolume; /**<#1 Volume or Dry/Wetness*/ char Ppanning; /**<#2 Panning*/ - DelayCtl delay; /**<#3 Delay of the Echo*/ + char Pdelay; /**<#3 Delay of the Echo*/ char Plrdelay; /**<#4 L/R delay difference*/ char Plrcross; /**<#5 L/R Mixing*/ - char Pfb; /**<#6Feedback*/ - char Phidamp; /**<#7Dampening of the Echo*/ + char Pfb; /**<#6Feedback*/ + char Phidamp; /**<#7Dampening of the Echo*/ - void setvolume(const unsigned char &Pvolume); - void setpanning(const unsigned char &Ppanning); - void setdelay(const unsigned char &Pdelay); - void setlrdelay(const unsigned char &Plrdelay); - void setlrcross(const unsigned char &Plrcross); - void setfb(const unsigned char &Pfb); - void sethidamp(const unsigned char &Phidamp); + void setvolume(unsigned char Pvolume); + void setpanning(unsigned char Ppanning); + void setdelay(unsigned char Pdelay); + void setlrdelay(unsigned char Plrdelay); + void setlrcross(unsigned char Plrcross); + void setfb(unsigned char Pfb); + void sethidamp(unsigned char Phidamp); //Real Parameters - REALTYPE panning, lrcross, fb, hidamp; //needs better names - int dl, dr, lrdelay; //needs better names + REALTYPE panning, lrcross, fb, hidamp; + //Left/Right delay lengths + Stereo delayTime; + REALTYPE lrdelay; + REALTYPE avgDelay; void initdelays(); - Stereo delaySample; + //2 channel ring buffer + Stereo delay; Stereo old; - int kl, kr; + //position of reading/writing from delaysample + Stereo pos; + //step size for delay buffer + Stereo delta; + Stereo ndelta; }; #endif diff --git a/plugins/zynaddsubfx/src/Effects/Effect.cpp b/plugins/zynaddsubfx/src/Effects/Effect.cpp index 0a17ebdc4..ab44312ed 100644 --- a/plugins/zynaddsubfx/src/Effects/Effect.cpp +++ b/plugins/zynaddsubfx/src/Effects/Effect.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - Effect.C - this class is inherited by the all effects(Reverb, Echo, ..) + Effect.cpp - this class is inherited by the all effects(Reverb, Echo, ..) Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul @@ -22,10 +22,15 @@ #include "Effect.h" - Effect::Effect(bool insertion_, REALTYPE *const efxoutl_, REALTYPE *const efxoutr_, FilterParams *filterpars_, const unsigned char &Ppreset_) :Ppreset(Ppreset_), efxoutl(efxoutl_), efxoutr(efxoutr_), - filterpars(filterpars_), insertion(insertion_) {} + filterpars(filterpars_), insertion(insertion_) +{} + +void Effect::out(REALTYPE *const smpsl, REALTYPE *const smpsr) +{ + out(Stereo(smpsl,smpsr)); +}; diff --git a/plugins/zynaddsubfx/src/Effects/Effect.h b/plugins/zynaddsubfx/src/Effects/Effect.h index 7f769ead8..eddbbba5c 100644 --- a/plugins/zynaddsubfx/src/Effects/Effect.h +++ b/plugins/zynaddsubfx/src/Effects/Effect.h @@ -26,6 +26,7 @@ #include "../Misc/Util.h" #include "../globals.h" #include "../Params/FilterParams.h" +#include "../Misc/Stereo.h" /**this class is inherited by the all effects(Reverb, Echo, ..)*/ @@ -56,12 +57,12 @@ class Effect /**Change parameter npar to value * @param npar chosen parameter * @param value chosen new value*/ - virtual void changepar(const int &npar, const unsigned char &value) = 0; + virtual void changepar(int npar, unsigned char value) = 0; /**Get the value of parameter npar * @param npar chosen parameter * @return the value of the parameter in an unsigned char or 0 if it * does not exist*/ - virtual unsigned char getpar(const int &npar) const = 0; + virtual unsigned char getpar(int npar) const = 0; /**Output result of effect based on the given buffers * * This method should result in the effect generating its results @@ -71,18 +72,19 @@ class Effect * @param smpsl Input buffer for the Left channel * @param smpsr Input buffer for the Right channel */ - virtual void out(REALTYPE *const smpsl, REALTYPE *const smpsr) = 0; + void out(REALTYPE *const smpsl, REALTYPE *const smpsr); + virtual void out(const Stereo &smp) = 0; /**Reset the state of the effect*/ virtual void cleanup() {} /**This is only used for EQ (for user interface)*/ virtual REALTYPE getfreqresponse(REALTYPE freq) { - return 0; + return freq; } unsigned char Ppreset; /***/ REALTYPE outvolume;/** +using namespace std; EffectMgr::EffectMgr(int insertion_, pthread_mutex_t *mutex_) :insertion(insertion_), diff --git a/plugins/zynaddsubfx/src/Effects/EffectMgr.h b/plugins/zynaddsubfx/src/Effects/EffectMgr.h index 2a1257707..29d6a7a71 100644 --- a/plugins/zynaddsubfx/src/Effects/EffectMgr.h +++ b/plugins/zynaddsubfx/src/Effects/EffectMgr.h @@ -37,7 +37,6 @@ #include "../Params/FilterParams.h" #include "../Params/Presets.h" - /**Effect manager, an interface betwen the program and effects*/ class EffectMgr:public Presets { diff --git a/plugins/zynaddsubfx/src/Effects/Phaser.cpp b/plugins/zynaddsubfx/src/Effects/Phaser.cpp index b3402b9af..39c514f44 100644 --- a/plugins/zynaddsubfx/src/Effects/Phaser.cpp +++ b/plugins/zynaddsubfx/src/Effects/Phaser.cpp @@ -1,9 +1,18 @@ /* + + Phaser.cpp - Phasing and Approximate digital model of an analog JFET phaser. + Analog modeling implemented by Ryan Billing aka Transmogrifox. ZynAddSubFX - a software synthesizer - Phaser.C - Phaser effect + Phaser.cpp - Phaser effect Copyright (C) 2002-2005 Nasca Octavian Paul + Copyright (C) 2009-2010 Ryan Billing + Copyright (C) 2010-2010 Mark McCurry Author: Nasca Octavian Paul + Ryan Billing + Mark McCurry + + DSP analog modeling theory & practice largely influenced by various CCRMA publications, particularly works by Julius O. Smith. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License @@ -21,89 +30,212 @@ */ #include +#include #include "Phaser.h" + +using namespace std; + #define PHASER_LFO_SHAPE 2 +#define ONE_ 0.99999f // To prevent LFO ever reaching 1.0 for filter stability purposes +#define ZERO_ 0.00001f // Same idea as above. Phaser::Phaser(const int &insertion_, REALTYPE *efxoutl_, REALTYPE *efxoutr_) - :Effect(insertion_, efxoutl_, efxoutr_, NULL, 0), old(1), oldgain(0.0) + :Effect(insertion_, efxoutl_, efxoutr_, NULL, 0), xn1(NULL), yn1(NULL), diff(0.0), old(NULL), oldgain(0.0), + fb(0.0) { + analog_setup(); setpreset(Ppreset); cleanup(); } -Phaser::~Phaser() -{} +void Phaser::analog_setup() +{ + //model mismatch between JFET devices + offset[0] = -0.2509303f; + offset[1] = 0.9408924f; + offset[2] = 0.998f; + offset[3] = -0.3486182f; + offset[4] = -0.2762545f; + offset[5] = -0.5215785f; + offset[6] = 0.2509303f; + offset[7] = -0.9408924f; + offset[8] = -0.998f; + offset[9] = 0.3486182f; + offset[10] = 0.2762545f; + offset[11] = 0.5215785f; + barber = 0; //Deactivate barber pole phasing by default + + mis = 1.0f; + Rmin = 625.0f;// 2N5457 typical on resistance at Vgs = 0 + Rmax = 22000.0f;// Resistor parallel to FET + Rmx = Rmin/Rmax; + Rconst = 1.0f + Rmx; // Handle parallel resistor relationship + C = 0.00000005f; // 50 nF + CFs = (float) 2.0f*(float)SAMPLE_RATE*C; + invperiod = 1.0f / ((float) SOUND_BUFFER_SIZE); +} + +Phaser::~Phaser() +{ + if(xn1.l) + delete[] xn1.l; + if(yn1.l) + delete[] yn1.l; + if(xn1.r) + delete[] xn1.r; + if(yn1.r) + delete[] yn1.r; +} /* * Effect output */ -void Phaser::out(REALTYPE *smpsl, REALTYPE *smpsr) +void Phaser::out(const Stereo &input) { - int i, j; - REALTYPE lfol, lfor, lgain, rgain, tmp; - - lfo.effectlfoout(&lfol, &lfor); - lgain = lfol; - rgain = lfor; - lgain = (exp(lgain * PHASER_LFO_SHAPE) - 1) / (exp(PHASER_LFO_SHAPE) - 1.0); - rgain = (exp(rgain * PHASER_LFO_SHAPE) - 1) / (exp(PHASER_LFO_SHAPE) - 1.0); - - - lgain = 1.0 - phase * (1.0 - depth) - (1.0 - phase) * lgain * depth; - rgain = 1.0 - phase * (1.0 - depth) - (1.0 - phase) * rgain * depth; - - if(lgain > 1.0) - lgain = 1.0; + if(Panalog) + AnalogPhase(input); else - if(lgain < 0.0) - lgain = 0.0; - if(rgain > 1.0) - rgain = 1.0; - else - if(rgain < 0.0) - rgain = 0.0; + normalPhase(input); +} - for(i = 0; i < SOUND_BUFFER_SIZE; i++) { - REALTYPE x = (REALTYPE) i / SOUND_BUFFER_SIZE; - REALTYPE x1 = 1.0 - x; - REALTYPE gl = lgain * x + oldgain.left() * x1; - REALTYPE gr = rgain * x + oldgain.right() * x1; - REALTYPE inl = smpsl[i] * panning + fbl; - REALTYPE inr = smpsr[i] * (1.0 - panning) + fbr; +void Phaser::AnalogPhase(const Stereo &input) +{ + Stereo gain(0.0), lfoVal(0.0), mod(0.0), g(0.0), b(0.0), hpf(0.0); - //Left channel - for(j = 0; j < Pstages * 2; j++) { //Phasing routine - tmp = old.left()[j]; - old.left()[j] = gl * tmp + inl; - inl = tmp - gl *old.left()[j]; - } - //Right channel - for(j = 0; j < Pstages * 2; j++) { //Phasing routine - tmp = old.right()[j]; - old.right()[j] = gr * tmp + inr; - inr = tmp - gr *old.right()[j]; - } - //Left/Right crossing - REALTYPE l = inl; - REALTYPE r = inr; - inl = l * (1.0 - lrcross) + r * lrcross; - inr = r * (1.0 - lrcross) + l * lrcross; + lfo.effectlfoout(&lfoVal.l, &lfoVal.r); + mod.l = lfoVal.l*width + (depth - 0.5f); + mod.r = lfoVal.r*width + (depth - 0.5f); - fbl = inl * fb; - fbr = inr * fb; - efxoutl[i] = inl; - efxoutr[i] = inr; + mod.l = limit(mod.l, ZERO_, ONE_); + mod.r = limit(mod.r, ZERO_, ONE_); + + if(Phyper) { + //Triangle wave squared is approximately sin on bottom, tri on top + //Result is exponential sweep more akin to filter in synth with + //exponential generator circuitry. + mod.l *= mod.l; + mod.r *= mod.r; } - oldgain = Stereo(lgain, rgain); + //g.l,g.r is Vp - Vgs. Typical FET drain-source resistance follows constant/[1-sqrt(Vp - Vgs)] + mod.l = sqrtf(1.0f - mod.l); + mod.r = sqrtf(1.0f - mod.r); - if(Poutsub != 0) - for(i = 0; i < SOUND_BUFFER_SIZE; i++) { - efxoutl[i] *= -1.0; - efxoutr[i] *= -1.0; + diff.r = (mod.r - oldgain.r) * invperiod; + diff.l = (mod.l - oldgain.l) * invperiod; + + g = oldgain; + oldgain = mod; + + for (int i = 0; i < SOUND_BUFFER_SIZE; i++) { + g.l += diff.l;// Linear interpolation between LFO samples + g.r += diff.r; + + Stereo xn(input.l[i] * panning, + input.r[i] * (1.0f - panning)); + + if (barber) { + g.l = fmodf((g.l + 0.25f), ONE_); + g.r = fmodf((g.r + 0.25f), ONE_); } - ; + + xn.l = applyPhase(xn.l, g.l, fb.l, hpf.l, yn1.l, xn1.l); + xn.r = applyPhase(xn.r, g.r, fb.r, hpf.r, yn1.r, xn1.r); + + + fb.l = xn.l * feedback; + fb.r = xn.r * feedback; + efxoutl[i] = xn.l; + efxoutr[i] = xn.r; + } + + if(Poutsub) { + invSignal(efxoutl, SOUND_BUFFER_SIZE); + invSignal(efxoutr, SOUND_BUFFER_SIZE); + } +} + +REALTYPE Phaser::applyPhase(REALTYPE x, REALTYPE g, REALTYPE fb, + REALTYPE &hpf, REALTYPE *yn1, REALTYPE *xn1) +{ + for(int j = 0; j < Pstages; j++) { //Phasing routine + mis = 1.0f + offsetpct*offset[j]; + + //This is symmetrical. + //FET is not, so this deviates slightly, however sym dist. is + //better sounding than a real FET. + float d = (1.0f + 2.0f*(0.25f + g)*hpf*hpf*distortion) * mis; + Rconst = 1.0f + mis*Rmx; + + // This is 1/R. R is being modulated to control filter fc. + float b = (Rconst - g)/ (d*Rmin); + float gain = (CFs - b)/(CFs + b); + yn1[j] = gain * (x + yn1[j]) - xn1[j]; + + //high pass filter: + //Distortion depends on the high-pass part of the AP stage. + hpf = yn1[j] + (1.0f-gain)*xn1[j]; + + xn1[j] = x; + x = yn1[j]; + if (j==1) + x += fb; //Insert feedback after first phase stage + } + return x; +} +void Phaser::normalPhase(const Stereo &input) +{ + Stereo gain(0.0), lfoVal(0.0); + + lfo.effectlfoout(&lfoVal.l, &lfoVal.r); + gain.l = (exp(lfoVal.l * PHASER_LFO_SHAPE) - 1) / (exp(PHASER_LFO_SHAPE) - 1.0); + gain.r = (exp(lfoVal.r * PHASER_LFO_SHAPE) - 1) / (exp(PHASER_LFO_SHAPE) - 1.0); + + gain.l = 1.0 - phase * (1.0 - depth) - (1.0 - phase) * gain.l * depth; + gain.r = 1.0 - phase * (1.0 - depth) - (1.0 - phase) * gain.r * depth; + + gain.l = limit(gain.l, ZERO_, ONE_); + gain.r = limit(gain.r, ZERO_, ONE_); + + for(int i = 0; i < SOUND_BUFFER_SIZE; i++) { + REALTYPE x = (REALTYPE) i / SOUND_BUFFER_SIZE; + REALTYPE x1 = 1.0 - x; + //TODO think about making panning an external feature + Stereo xn(input.l[i] * panning + fb.l, + input.r[i] * (1.0 - panning) + fb.r); + + Stereo g(gain.l * x + oldgain.l * x1, + gain.r * x + oldgain.r * x1); + + xn.l = applyPhase(xn.l, g.l, old.l); + xn.r = applyPhase(xn.r, g.r, old.r); + + //Left/Right crossing + crossover(xn.l, xn.r, lrcross); + + fb.l = xn.l * feedback; + fb.r = xn.r * feedback; + efxoutl[i] = xn.l; + efxoutr[i] = xn.r; + } + + oldgain = gain; + + if(Poutsub) { + invSignal(efxoutl, SOUND_BUFFER_SIZE); + invSignal(efxoutr, SOUND_BUFFER_SIZE); + } +} + +REALTYPE Phaser::applyPhase(REALTYPE x, REALTYPE g, REALTYPE *old) +{ + for(int j = 0; j < Pstages * 2; j++) { //Phasing routine + REALTYPE tmp = old[j]; + old[j] = g * tmp + x; + x = tmp - g *old[j]; + } + return x; } /* @@ -111,30 +243,35 @@ void Phaser::out(REALTYPE *smpsl, REALTYPE *smpsr) */ void Phaser::cleanup() { - fbl = 0.0; - fbr = 0.0; - oldgain = Stereo(0.0); - old.l().clear(); - old.r().clear(); + fb = oldgain = Stereo(0.0); + for(int i = 0; i < Pstages * 2; i++) { + old.l[i] = 0.0; + old.r[i] = 0.0; + } + for(int i = 0; i < Pstages; i++) { + xn1.l[i] = 0.0; + yn1.l[i] = 0.0; + xn1.r[i] = 0.0; + yn1.r[i] = 0.0; + } } /* * Parameter control */ -void Phaser::setdepth(const unsigned char &Pdepth) +void Phaser::setwidth(unsigned char Pwidth) { - this->Pdepth = Pdepth; - depth = (Pdepth / 127.0); + this->Pwidth = Pwidth; + width = ((float)Pwidth / 127.0f); } - -void Phaser::setfb(const unsigned char &Pfb) +void Phaser::setfb(unsigned char Pfb) { this->Pfb = Pfb; - fb = (Pfb - 64.0) / 64.1; + feedback = (float) (Pfb - 64) / 64.2f; } -void Phaser::setvolume(const unsigned char &Pvolume) +void Phaser::setvolume(unsigned char Pvolume) { this->Pvolume = Pvolume; outvolume = Pvolume / 127.0; @@ -144,52 +281,90 @@ void Phaser::setvolume(const unsigned char &Pvolume) volume = outvolume; } -void Phaser::setpanning(const unsigned char &Ppanning) +void Phaser::setpanning(unsigned char Ppanning) { this->Ppanning = Ppanning; - panning = Ppanning / 127.0; + panning = (float)Ppanning / 127.0; } -void Phaser::setlrcross(const unsigned char &Plrcross) +void Phaser::setlrcross(unsigned char Plrcross) { this->Plrcross = Plrcross; lrcross = Plrcross / 127.0; } -void Phaser::setstages(const unsigned char &Pstages) +void Phaser::setdistortion(unsigned char Pdistortion) { - if(Pstages >= MAX_PHASER_STAGES) - this->Pstages = MAX_PHASER_STAGES - 1; - else - this->Pstages = Pstages; - old = Stereo(Pstages * 2); + this->Pdistortion = Pdistortion; + distortion = (float)Pdistortion / 127.0f; +} + +void Phaser::setoffset(unsigned char Poffset) +{ + this->Poffset = Poffset; + offsetpct = (float)Poffset / 127.0f; +} + +void Phaser::setstages(unsigned char Pstages) +{ + if(xn1.l) + delete[] xn1.l; + if(yn1.l) + delete[] yn1.l; + if(xn1.r) + delete[] xn1.r; + if(yn1.r) + delete[] yn1.r; + + + this->Pstages = min(MAX_PHASER_STAGES, (int)Pstages); + + old = Stereo(new REALTYPE[Pstages * 2], + new REALTYPE[Pstages * 2]); + + xn1 = Stereo(new REALTYPE[Pstages], + new REALTYPE[Pstages]); + + yn1 = Stereo(new REALTYPE[Pstages], + new REALTYPE[Pstages]); + cleanup(); } -void Phaser::setphase(const unsigned char &Pphase) +void Phaser::setphase(unsigned char Pphase) { this->Pphase = Pphase; phase = (Pphase / 127.0); } +void Phaser::setdepth(unsigned char Pdepth) +{ + this->Pdepth = Pdepth; + depth = (float)(Pdepth) / 127.0f; +} + void Phaser::setpreset(unsigned char npreset) { - const int PRESET_SIZE = 12; - const int NUM_PRESETS = 6; + const int PRESET_SIZE = 15; + const int NUM_PRESETS = 12; unsigned char presets[NUM_PRESETS][PRESET_SIZE] = { - //Phaser1 - {64, 64, 36, 0, 0, 64, 110, 64, 1, 0, 0, 20}, - //Phaser2 - {64, 64, 35, 0, 0, 88, 40, 64, 3, 0, 0, 20}, - //Phaser3 - {64, 64, 31, 0, 0, 66, 68, 107, 2, 0, 0, 20}, - //Phaser4 - {39, 64, 22, 0, 0, 66, 67, 10, 5, 0, 1, 20}, - //Phaser5 - {64, 64, 20, 0, 1, 110, 67, 78, 10, 0, 0, 20}, - //Phaser6 - {64, 64, 53, 100, 0, 58, 37, 78, 3, 0, 0, 20} + //Phaser + //0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 + {64, 64, 36, 0, 0, 64, 110, 64, 1, 0, 0, 20, 0, 0, 0}, + {64, 64, 35, 0, 0, 88, 40, 64, 3, 0, 0, 20, 0, 0, 0}, + {64, 64, 31, 0, 0, 66, 68, 107, 2, 0, 0, 20, 0, 0, 0}, + {39, 64, 22, 0, 0, 66, 67, 10, 5, 0, 1, 20, 0, 0, 0}, + {64, 64, 20, 0, 1, 110, 67, 78, 10, 0, 0, 20, 0, 0, 0}, + {64, 64, 53, 100, 0, 58, 37, 78, 3, 0, 0, 20, 0, 0, 0}, + //APhaser + //0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 + {64, 64, 14, 0, 1, 64, 64, 40, 4, 10, 0, 110, 1, 20, 1}, + {64, 64, 14, 5, 1, 64, 70, 40, 6, 10, 0, 110, 1, 20, 1}, + {64, 64, 9, 0, 0, 64, 60, 40, 8, 10, 0, 40, 0, 20, 1}, + {64, 64, 14, 10, 0, 64, 45, 80, 7, 10, 1, 110, 1, 20, 1}, + {25, 64, 127, 10, 0, 64, 25, 16, 8, 100, 0, 25, 0, 20, 1}, + {64, 64, 1, 10, 1, 64, 70, 40, 12, 10, 0, 110, 1, 20, 1} }; if(npreset >= NUM_PRESETS) npreset = NUM_PRESETS - 1; @@ -199,96 +374,100 @@ void Phaser::setpreset(unsigned char npreset) } -void Phaser::changepar(const int &npar, const unsigned char &value) +void Phaser::changepar(int npar, unsigned char value) { switch(npar) { - case 0: - setvolume(value); - break; - case 1: - setpanning(value); - break; - case 2: - lfo.Pfreq = value; - lfo.updateparams(); - break; - case 3: - lfo.Prandomness = value; - lfo.updateparams(); - break; - case 4: - lfo.PLFOtype = value; - lfo.updateparams(); - break; - case 5: - lfo.Pstereo = value; - lfo.updateparams(); - break; - case 6: - setdepth(value); - break; - case 7: - setfb(value); - break; - case 8: - setstages(value); - break; - case 9: - setlrcross(value); - break; - case 10: - if(value > 1) - Poutsub = 1; - else - Poutsub = value; - break; - case 11: - setphase(value); - break; + case 0: + setvolume(value); + break; + case 1: + setpanning(value); + break; + case 2: + lfo.Pfreq = value; + lfo.updateparams(); + break; + case 3: + lfo.Prandomness = value; + lfo.updateparams(); + break; + case 4: + lfo.PLFOtype = value; + lfo.updateparams(); + barber = (2 == value); + break; + case 5: + lfo.Pstereo = value; + lfo.updateparams(); + break; + case 6: + setdepth(value); + break; + case 7: + setfb(value); + break; + case 8: + setstages(value); + break; + case 9: + setlrcross(value); + setoffset(value); + break; + case 10: + Poutsub = min((int)value,1); + break; + case 11: + setphase(value); + setwidth(value); + break; + case 12: + Phyper = min((int)value, 1); + break; + case 13: + setdistortion(value); + break; + case 14: + Panalog = value; + break; } } -unsigned char Phaser::getpar(const int &npar) const +unsigned char Phaser::getpar(int npar) const { switch(npar) { - case 0: - return Pvolume; - break; - case 1: - return Ppanning; - break; - case 2: - return lfo.Pfreq; - break; - case 3: - return lfo.Prandomness; - break; - case 4: - return lfo.PLFOtype; - break; - case 5: - return lfo.Pstereo; - break; - case 6: - return Pdepth; - break; - case 7: - return Pfb; - break; - case 8: - return Pstages; - break; - case 9: - return Plrcross; - break; - case 10: - return Poutsub; - break; - case 11: - return Pphase; - break; - default: - return 0; + case 0: + return Pvolume; + case 1: + return Ppanning; + case 2: + return lfo.Pfreq; + case 3: + return lfo.Prandomness; + case 4: + return lfo.PLFOtype; + case 5: + return lfo.Pstereo; + case 6: + return Pdepth; + case 7: + return Pfb; + case 8: + return Pstages; + case 9: + return Plrcross; + return Poffset; + case 10: + return Poutsub; + case 11: + return Pphase; + return Pwidth; + case 12: + return Phyper; + case 13: + return Pdistortion; + case 14: + return Panalog; + default: + return 0; } } - diff --git a/plugins/zynaddsubfx/src/Effects/Phaser.h b/plugins/zynaddsubfx/src/Effects/Phaser.h index 30370a8c6..f5ee1b03f 100644 --- a/plugins/zynaddsubfx/src/Effects/Phaser.h +++ b/plugins/zynaddsubfx/src/Effects/Phaser.h @@ -3,7 +3,11 @@ Phaser.h - Phaser effect Copyright (C) 2002-2005 Nasca Octavian Paul + Copyright (C) 2009-2010 Ryan Billing + Copyright (C) 2010-2010 Mark McCurry Author: Nasca Octavian Paul + Ryan Billing + Mark McCurry This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License @@ -23,53 +27,77 @@ #ifndef PHASER_H #define PHASER_H #include "../globals.h" -#include "../Misc/Stereo.h" -#include "../Samples/AuSample.h" #include "Effect.h" #include "EffectLFO.h" #define MAX_PHASER_STAGES 12 -/**Phaser Effect*/ + class Phaser:public Effect { public: - Phaser(const int &insetion_, REALTYPE *efxoutl_, REALTYPE *efxoutr_); + Phaser(const int &insertion_, REALTYPE *efxoutl_, REALTYPE *efxoutr_); ~Phaser(); - void out(REALTYPE *smpsl, REALTYPE *smpsr); + void out(const Stereo &input); void setpreset(unsigned char npreset); - void changepar(const int &npar, const unsigned char &value); - unsigned char getpar(const int &npar) const; + void changepar(int npar, unsigned char value); + unsigned char getpar(int npar) const; void cleanup(); - void setdryonly(); private: - //Parametrii Phaser - EffectLFO lfo; /** old; - //REALTYPE oldlgain,oldrgain; - Stereo oldgain; + //Internal Variables + bool barber; //Barber pole phasing flag + REALTYPE distortion, width, offsetpct; + REALTYPE panning, feedback, depth, lrcross, phase; + Stereo old, xn1, yn1; + Stereo diff, oldgain, fb; + REALTYPE invperiod; + REALTYPE offset[12]; + + float mis; + float Rmin; // 3N5457 typical on resistance at Vgs = 0 + float Rmax; // Resistor parallel to FET + float Rmx; // Rmin/Rmax to avoid division in loop + float Rconst; // Handle parallel resistor relationship + float C; // Capacitor + float CFs; // A constant derived from capacitor and resistor relationships + + void analog_setup(); + void AnalogPhase(const Stereo &input); + //analog case + REALTYPE applyPhase(REALTYPE x, REALTYPE g, REALTYPE fb, + REALTYPE &hpf, REALTYPE *yn1, REALTYPE *xn1); + + void normalPhase(const Stereo &input); + REALTYPE applyPhase(REALTYPE x, REALTYPE g, REALTYPE *old); }; #endif diff --git a/plugins/zynaddsubfx/src/Effects/Reverb.cpp b/plugins/zynaddsubfx/src/Effects/Reverb.cpp index 27b0a554b..419cee4a6 100644 --- a/plugins/zynaddsubfx/src/Effects/Reverb.cpp +++ b/plugins/zynaddsubfx/src/Effects/Reverb.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - Reverb.C - Reverberation effect + Reverb.cpp - Reverberation effect Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul @@ -165,15 +165,14 @@ void Reverb::processmono(int ch, REALTYPE *output) /* * Effect output */ -void Reverb::out(REALTYPE *smps_l, REALTYPE *smps_r) +void Reverb::out(const Stereo &smp) { int i; if((Pvolume == 0) && (insertion != 0)) return; for(i = 0; i < SOUND_BUFFER_SIZE; i++) - inputbuf[i] = (smps_l[i] + smps_r[i]) / 2.0; - ; + inputbuf[i] = (smp.l[i] + smp.r[i]) / 2.0; if(idelay != NULL) { for(i = 0; i < SOUND_BUFFER_SIZE; i++) { @@ -184,7 +183,6 @@ void Reverb::out(REALTYPE *smps_l, REALTYPE *smps_r) idelayk++; if(idelayk >= idelaylen) idelayk = 0; - ; } } @@ -215,7 +213,7 @@ void Reverb::out(REALTYPE *smps_l, REALTYPE *smps_r) /* * Parameter control */ -void Reverb::setvolume(const unsigned char &Pvolume) +void Reverb::setvolume(unsigned char Pvolume) { this->Pvolume = Pvolume; if(insertion == 0) { @@ -229,13 +227,13 @@ void Reverb::setvolume(const unsigned char &Pvolume) } } -void Reverb::setpan(const unsigned char &Ppan) +void Reverb::setpan(unsigned char Ppan) { this->Ppan = Ppan; pan = (REALTYPE)Ppan / 127.0; } -void Reverb::settime(const unsigned char &Ptime) +void Reverb::settime(unsigned char Ptime) { int i; REALTYPE t; @@ -246,7 +244,6 @@ void Reverb::settime(const unsigned char &Ptime) combfb[i] = -exp((REALTYPE)comblen[i] / (REALTYPE)SAMPLE_RATE * log(0.001) / t); //the feedback is negative because it removes the DC - ; } void Reverb::setlohidamp(unsigned char Plohidamp) @@ -271,7 +268,7 @@ void Reverb::setlohidamp(unsigned char Plohidamp) } } -void Reverb::setidelay(const unsigned char &Pidelay) +void Reverb::setidelay(unsigned char Pidelay) { REALTYPE delay; this->Pidelay = Pidelay; @@ -290,13 +287,13 @@ void Reverb::setidelay(const unsigned char &Pidelay) } } -void Reverb::setidelayfb(const unsigned char &Pidelayfb) +void Reverb::setidelayfb(unsigned char Pidelayfb) { this->Pidelayfb = Pidelayfb; idelayfb = Pidelayfb / 128.0; } -void Reverb::sethpf(const unsigned char &Phpf) +void Reverb::sethpf(unsigned char Phpf) { this->Phpf = Phpf; if(Phpf == 0) { //No HighPass @@ -313,7 +310,7 @@ void Reverb::sethpf(const unsigned char &Phpf) } } -void Reverb::setlpf(const unsigned char &Plpf) +void Reverb::setlpf(unsigned char Plpf) { this->Plpf = Plpf; if(Plpf == 127) { //No LowPass @@ -405,7 +402,7 @@ void Reverb::settype(unsigned char Ptype) } } -void Reverb::setroomsize(const unsigned char &Proomsize) +void Reverb::setroomsize(unsigned char Proomsize) { this->Proomsize = Proomsize; if(Proomsize == 0) @@ -418,7 +415,7 @@ void Reverb::setroomsize(const unsigned char &Proomsize) settype(Ptype); } -void Reverb::setbandwidth(const unsigned char &Pbandwidth) { +void Reverb::setbandwidth(unsigned char Pbandwidth) { this->Pbandwidth = Pbandwidth; REALTYPE v = Pbandwidth / 127.0; if(bandwidth) @@ -468,7 +465,7 @@ void Reverb::setpreset(unsigned char npreset) } -void Reverb::changepar(const int &npar, const unsigned char &value) +void Reverb::changepar(int npar, unsigned char value) { switch(npar) { case 0: @@ -511,7 +508,7 @@ void Reverb::changepar(const int &npar, const unsigned char &value) } } -unsigned char Reverb::getpar(const int &npar) const +unsigned char Reverb::getpar(int npar) const { switch(npar) { case 0: diff --git a/plugins/zynaddsubfx/src/Effects/Reverb.h b/plugins/zynaddsubfx/src/Effects/Reverb.h index d94f0bcef..e84c56d88 100644 --- a/plugins/zynaddsubfx/src/Effects/Reverb.h +++ b/plugins/zynaddsubfx/src/Effects/Reverb.h @@ -40,12 +40,12 @@ class Reverb:public Effect public: Reverb(const int &insertion_, REALTYPE *efxoutl_, REALTYPE *efxoutr_); ~Reverb(); - void out(REALTYPE *smps_l, REALTYPE *smps_r); + void out(const Stereo &smp); void cleanup(); void setpreset(unsigned char npreset); - void changepar(const int &npar, const unsigned char &value); - unsigned char getpar(const int &npar) const; + void changepar(int npar, unsigned char value); + unsigned char getpar(int npar) const; private: //Parametrii @@ -90,17 +90,17 @@ class Reverb:public Effect unsigned char Pbandwidth; //parameter control - void setvolume(const unsigned char &Pvolume); - void setpan(const unsigned char &Ppan); - void settime(const unsigned char &Ptime); + void setvolume(unsigned char Pvolume); + void setpan(unsigned char Ppan); + void settime(unsigned char Ptime); void setlohidamp(unsigned char Plohidamp); - void setidelay(const unsigned char &Pidelay); - void setidelayfb(const unsigned char &Pidelayfb); - void sethpf(const unsigned char &Phpf); - void setlpf(const unsigned char &Plpf); + void setidelay(unsigned char Pidelay); + void setidelayfb(unsigned char Pidelayfb); + void sethpf(unsigned char Phpf); + void setlpf(unsigned char Plpf); void settype(unsigned char Ptype); - void setroomsize(const unsigned char &Proomsize); - void setbandwidth(const unsigned char &Pbandwidth); + void setroomsize(unsigned char Proomsize); + void setbandwidth(unsigned char Pbandwidth); REALTYPE pan, erbalance; //Parameters diff --git a/plugins/zynaddsubfx/src/Input/ALSAMidiIn.cpp b/plugins/zynaddsubfx/src/Input/ALSAMidiIn.cpp index 10f8e2811..d50795dad 100644 --- a/plugins/zynaddsubfx/src/Input/ALSAMidiIn.cpp +++ b/plugins/zynaddsubfx/src/Input/ALSAMidiIn.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - ALSAMidiIn.C - Midi input for ALSA (this creates an ALSA virtual port) + ALSAMidiIn.cpp - Midi input for ALSA (this creates an ALSA virtual port) Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul diff --git a/plugins/zynaddsubfx/src/Input/MidiIn.cpp b/plugins/zynaddsubfx/src/Input/MidiIn.cpp index 90df75d95..3d7c5b230 100644 --- a/plugins/zynaddsubfx/src/Input/MidiIn.cpp +++ b/plugins/zynaddsubfx/src/Input/MidiIn.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - MidiIn.C - This class is inherited by all the Midi input classes + MidiIn.cpp - This class is inherited by all the Midi input classes Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul diff --git a/plugins/zynaddsubfx/src/Input/NULLMidiIn.cpp b/plugins/zynaddsubfx/src/Input/NULLMidiIn.cpp index 22ee76d75..a9c13acb3 100644 --- a/plugins/zynaddsubfx/src/Input/NULLMidiIn.cpp +++ b/plugins/zynaddsubfx/src/Input/NULLMidiIn.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - NULLMidiIn.C - a dummy Midi port + NULLMidiIn.cpp - a dummy Midi port Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul diff --git a/plugins/zynaddsubfx/src/Input/OSSMidiIn.cpp b/plugins/zynaddsubfx/src/Input/OSSMidiIn.cpp index b278ae6bf..5a20fb930 100644 --- a/plugins/zynaddsubfx/src/Input/OSSMidiIn.cpp +++ b/plugins/zynaddsubfx/src/Input/OSSMidiIn.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - OSSMidiIn.C - Midi input for Open Sound System + OSSMidiIn.cpp - Midi input for Open Sound System Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul diff --git a/plugins/zynaddsubfx/src/Input/WINMidiIn.cpp b/plugins/zynaddsubfx/src/Input/WINMidiIn.cpp index e8462457d..65974eec1 100644 --- a/plugins/zynaddsubfx/src/Input/WINMidiIn.cpp +++ b/plugins/zynaddsubfx/src/Input/WINMidiIn.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - WINMidiIn.C - Midi input for Windows + WINMidiIn.cpp - Midi input for Windows Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul diff --git a/plugins/zynaddsubfx/src/Misc/Bank.h b/plugins/zynaddsubfx/src/Misc/Bank.h index 81acc3dec..aa3594648 100644 --- a/plugins/zynaddsubfx/src/Misc/Bank.h +++ b/plugins/zynaddsubfx/src/Misc/Bank.h @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - Bank.C - Instrument Bank + Bank.h - Instrument Bank Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul diff --git a/plugins/zynaddsubfx/src/Misc/CMakeLists.txt b/plugins/zynaddsubfx/src/Misc/CMakeLists.txt index e051af4df..8b883f379 100644 --- a/plugins/zynaddsubfx/src/Misc/CMakeLists.txt +++ b/plugins/zynaddsubfx/src/Misc/CMakeLists.txt @@ -11,6 +11,10 @@ set(zynaddsubfx_misc_SRCS QtXmlWrapper.cpp ) +if (LASH_FOUND) + set(zynaddsubfx_misc_SRCS ${zynaddsubfx_misc_SRCS} LASHClient.cpp) +endif() + add_library(zynaddsubfx_misc STATIC ${zynaddsubfx_misc_SRCS} ) diff --git a/plugins/zynaddsubfx/src/Misc/Config.cpp b/plugins/zynaddsubfx/src/Misc/Config.cpp index 94966e4af..0921d3df1 100644 --- a/plugins/zynaddsubfx/src/Misc/Config.cpp +++ b/plugins/zynaddsubfx/src/Misc/Config.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - Config.C - Configuration file functions + Config.cpp - Configuration file functions Copyright (C) 2003-2005 Nasca Octavian Paul Author: Nasca Octavian Paul diff --git a/plugins/zynaddsubfx/src/Misc/Dump.cpp b/plugins/zynaddsubfx/src/Misc/Dump.cpp index 4c13c9464..492cf57ed 100644 --- a/plugins/zynaddsubfx/src/Misc/Dump.cpp +++ b/plugins/zynaddsubfx/src/Misc/Dump.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - Dump.C - It dumps the notes to a text file + Dump.cpp - It dumps the notes to a text file Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul diff --git a/plugins/zynaddsubfx/src/Misc/LASHClient.cpp b/plugins/zynaddsubfx/src/Misc/LASHClient.cpp index a21461f29..292037791 100644 --- a/plugins/zynaddsubfx/src/Misc/LASHClient.cpp +++ b/plugins/zynaddsubfx/src/Misc/LASHClient.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - LASHClient.C - LASH support + LASHClient.cpp - LASH support Copyright (C) 2006-2009 Lars Luthman Author: Lars Luthman diff --git a/plugins/zynaddsubfx/src/Misc/Master.cpp b/plugins/zynaddsubfx/src/Misc/Master.cpp index d0c7648c6..fa5e1b003 100644 --- a/plugins/zynaddsubfx/src/Misc/Master.cpp +++ b/plugins/zynaddsubfx/src/Misc/Master.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - Master.C - It sends Midi Messages to Parts, receives samples from parts, + Master.cpp - It sends Midi Messages to Parts, receives samples from parts, process them with system/insertion effects and mix them Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul diff --git a/plugins/zynaddsubfx/src/Misc/Microtonal.cpp b/plugins/zynaddsubfx/src/Misc/Microtonal.cpp index e84ee8e64..1d327d209 100644 --- a/plugins/zynaddsubfx/src/Misc/Microtonal.cpp +++ b/plugins/zynaddsubfx/src/Misc/Microtonal.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - Microtonal.C - Tuning settings and microtonal capabilities + Microtonal.cpp - Tuning settings and microtonal capabilities Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul diff --git a/plugins/zynaddsubfx/src/Misc/Part.cpp b/plugins/zynaddsubfx/src/Misc/Part.cpp index 2f8dfe7ba..3830fc630 100644 --- a/plugins/zynaddsubfx/src/Misc/Part.cpp +++ b/plugins/zynaddsubfx/src/Misc/Part.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - Part.C - Part implementation + Part.cpp - Part implementation Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul @@ -249,7 +249,7 @@ void Part::NoteOn(unsigned char note, if(Ppolymode != 0) { fprintf( stderr, - "ZynAddSubFX WARNING: Poly and Legato modes are both On, that should not happen ! ... Disabling Legato mode ! - (Part.C::NoteOn(..))\n"); + "ZynAddSubFX WARNING: Poly and Legato modes are both On, that should not happen ! ... Disabling Legato mode ! - (Part.cpp::NoteOn(..))\n"); Plegatomode = 0; } else { @@ -293,7 +293,7 @@ void Part::NoteOn(unsigned char note, //test fprintf(stderr, "%s", - "NOTES TOO MANY (> POLIPHONY) - (Part.C::NoteOn(..))\n"); + "NOTES TOO MANY (> POLIPHONY) - (Part.cpp::NoteOn(..))\n"); else { //start the note partnote[pos].status = KEY_PLAYING; diff --git a/plugins/zynaddsubfx/src/Misc/Stereo.cpp b/plugins/zynaddsubfx/src/Misc/Stereo.cpp index 928be6e29..be53e5114 100644 --- a/plugins/zynaddsubfx/src/Misc/Stereo.cpp +++ b/plugins/zynaddsubfx/src/Misc/Stereo.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - Stereo.C - Object for storing a pair of objects + Stereo.cpp - Object for storing a pair of objects Copyright (C) 2009-2009 Mark McCurry Author: Mark McCurry @@ -21,18 +21,19 @@ template Stereo::Stereo(const T &left, const T &right) - :leftChannel(left), rightChannel(right) + :l(left), r(right) {} template Stereo::Stereo(const T &val) - :leftChannel(val), rightChannel(val) + :l(val), r(val) {} template -void Stereo::operator=(const Stereo &nstr) +Stereo &Stereo::operator=(const Stereo &nstr) { - leftChannel = nstr.leftChannel; - rightChannel = nstr.rightChannel; + l = nstr.l; + r = nstr.r; + return *this; } diff --git a/plugins/zynaddsubfx/src/Misc/Stereo.h b/plugins/zynaddsubfx/src/Misc/Stereo.h index 8bdf43017..06ee63c80 100644 --- a/plugins/zynaddsubfx/src/Misc/Stereo.h +++ b/plugins/zynaddsubfx/src/Misc/Stereo.h @@ -22,7 +22,7 @@ #define STEREO_H template -class Stereo +struct Stereo { public: Stereo(const T &left, const T &right); @@ -32,34 +32,10 @@ class Stereo Stereo(const T &val); ~Stereo() {} - void operator=(const Stereo &smp); - T &left() { - return leftChannel; - } - T &right() { - return rightChannel; - } - T &l() { - return leftChannel; - } - T &r() { - return rightChannel; - } - const T &left() const { - return leftChannel; - } - const T &right() const { - return rightChannel; - } - const T &l() const { - return leftChannel; - } - const T &r() const { - return rightChannel; - } - private: - T leftChannel; - T rightChannel; + Stereo &operator=(const Stereo &smp); + + //data + T l, r; }; #include "Stereo.cpp" #endif diff --git a/plugins/zynaddsubfx/src/Misc/Util.cpp b/plugins/zynaddsubfx/src/Misc/Util.cpp index 0f862c602..ae3d2af34 100644 --- a/plugins/zynaddsubfx/src/Misc/Util.cpp +++ b/plugins/zynaddsubfx/src/Misc/Util.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - Util.C - Miscellaneous functions + Util.cpp - Miscellaneous functions Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul @@ -113,3 +113,18 @@ bool fileexists(const char *filename) return false; } +void invSignal(REALTYPE *sig, size_t len) +{ + for(int i = 0; i < len; i++) + sig[i] *= -1.0f; +} + +void crossover(REALTYPE &a, REALTYPE &b, REALTYPE crossover) +{ + REALTYPE tmpa = a; + REALTYPE tmpb = b; + a = tmpa * (1.0 - crossover) + tmpb * crossover; + b = tmpb * (1.0 - crossover) + tmpa * crossover; +} + + diff --git a/plugins/zynaddsubfx/src/Misc/Util.h b/plugins/zynaddsubfx/src/Misc/Util.h index ccdac4dea..c0dc73ee2 100644 --- a/plugins/zynaddsubfx/src/Misc/Util.h +++ b/plugins/zynaddsubfx/src/Misc/Util.h @@ -42,6 +42,10 @@ extern REALTYPE *denormalkillbuf; /** std::string stringFrom(T x) { @@ -60,5 +64,11 @@ T stringTo(const char *x) return ans; } +template +T limit(T val, T min, T max) +{ + return (val < min ? min : (val > max ? max : val)); +} + #endif diff --git a/plugins/zynaddsubfx/src/Misc/XMLwrapper.cpp b/plugins/zynaddsubfx/src/Misc/XMLwrapper.cpp index b9ee3d6e6..d3750c47e 100644 --- a/plugins/zynaddsubfx/src/Misc/XMLwrapper.cpp +++ b/plugins/zynaddsubfx/src/Misc/XMLwrapper.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - XMLwrapper.C - XML wrapper + XMLwrapper.cpp - XML wrapper Copyright (C) 2003-2005 Nasca Octavian Paul Copyright (C) 2009-2009 Mark McCurry Author: Nasca Octavian Paul diff --git a/plugins/zynaddsubfx/src/Output/DSSIaudiooutput.cpp b/plugins/zynaddsubfx/src/Output/DSSIaudiooutput.cpp index 41e5ddc13..a7fdd0803 100644 --- a/plugins/zynaddsubfx/src/Output/DSSIaudiooutput.cpp +++ b/plugins/zynaddsubfx/src/Output/DSSIaudiooutput.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - DSSIaudiooutput.C - Audio functions for DSSI + DSSIaudiooutput.cpp - Audio functions for DSSI Copyright (C) 2002 Nasca Octavian Paul Author: Nasca Octavian Paul @@ -20,268 +20,666 @@ */ +/* + * Inital working DSSI output code contributed by Stephen G. Parry + */ + //this file contains code used from trivial_synth.c from -//the DSSI (published by Steve Harris under public domain) as a template -//the code is incomplete +//the DSSI (published by Steve Harris under public domain) as a template. + #include #include "DSSIaudiooutput.h" +#include "../Misc/Config.h" +#include "../Misc/Bank.h" +#include -static LADSPA_Descriptor *tsLDescriptor = NULL; -static DSSI_Descriptor *tsDDescriptor = NULL; - -typedef struct { - LADSPA_Data *outl; - LADSPA_Data *outr; -// note_data data[MIDI_NOTES]; -// float omega[MIDI_NOTES]; -} TS; - - -static void cleanupTS(LADSPA_Handle instance) +// +// Static stubs for LADSPA member functions +// +// LADSPA is essentially a C handle based API; This plug-in implementation is +// a C++ OO one so we need stub functions to map from C API calls to C++ object +// method calls. +void DSSIaudiooutput::stub_connectPort(LADSPA_Handle instance, unsigned long port, LADSPA_Data * data) { - free(instance); + getInstance(instance)->connectPort(port, data); } -static void connectPortTS(LADSPA_Handle instance, unsigned long port, - LADSPA_Data *data) + +void DSSIaudiooutput::stub_activate(LADSPA_Handle instance) { - TS *plugin; - plugin = (TS *) instance; - switch(port) { - case 0: - plugin->outl = data; - break; - case 1: - plugin->outr = data; - break; - } + getInstance(instance)->activate(); } +void DSSIaudiooutput::stub_run(LADSPA_Handle instance, unsigned long sample_count) +{ + getInstance(instance)->run(sample_count); +} + +void DSSIaudiooutput::stub_deactivate(LADSPA_Handle instance) +{ + getInstance(instance)->deactivate(); +} + + +void DSSIaudiooutput::stub_cleanup(LADSPA_Handle instance) +{ + DSSIaudiooutput* plugin_instance = getInstance(instance); + plugin_instance->cleanup(); + delete plugin_instance; +} + + const LADSPA_Descriptor *ladspa_descriptor(unsigned long index) { - switch(index) { - case 0: - return tsLDescriptor; - default: - return NULL; - } + return DSSIaudiooutput::getLadspaDescriptor(index); +} + +// +// Static stubs for DSSI member functions +// +// DSSI is essentially a C handle based API; This plug-in implementation is +// a C++ OO one so we need stub functions to map from C API calls to C++ object +// method calls. +const DSSI_Program_Descriptor* DSSIaudiooutput::stub_getProgram (LADSPA_Handle instance, unsigned long index) +{ + return getInstance(instance)->getProgram(index); +} + +void DSSIaudiooutput::stub_selectProgram(LADSPA_Handle instance, unsigned long bank, unsigned long program) +{ + getInstance(instance)->selectProgram(bank, program); +} + +int DSSIaudiooutput::stub_getMidiControllerForPort(LADSPA_Handle instance, unsigned long port) +{ + return getInstance(instance)->getMidiControllerForPort(port); +} + +void DSSIaudiooutput::stub_runSynth(LADSPA_Handle instance, unsigned long sample_count, + snd_seq_event_t *events, unsigned long event_count) +{ + getInstance(instance)->runSynth(sample_count, events, event_count); } const DSSI_Descriptor *dssi_descriptor(unsigned long index) { -// FILE *a=fopen("/tmp/zzzzz11z","w"); -// fprintf(a,"aaaaaaaaaaa TEST\n"); -// fclose(a); - switch(index) { - case 0: - return tsDDescriptor; - default: + return DSSIaudiooutput::getDssiDescriptor(index); +} + +// +// LADSPA member functions +// + +/** + * Instantiates a plug-in. + * + * This LADSPA member function instantiates a plug-in. + * Note that instance initialisation should generally occur in + * activate() rather than here. + * + * Zyn Implementation + * ------------------ + * This implementation creates a C++ class object and hides its pointer + * in the handle by type casting. + * + * @param descriptor [in] the descriptor for this plug-in + * @param s_rate [in] the sample rate + * @return the plug-in instance handle if successful else NULL + */ +LADSPA_Handle DSSIaudiooutput::instantiate(const LADSPA_Descriptor * descriptor, unsigned long s_rate) +{ + if(descriptor->UniqueID == dssiDescriptor->LADSPA_Plugin->UniqueID) + { + return (LADSPA_Handle)(new DSSIaudiooutput(s_rate)); + } + else + { return NULL; } } -static LADSPA_Handle instantiateTS(const LADSPA_Descriptor *descriptor, - unsigned long s_rate) +/** + * Connects a port on an instantiated plug-in. + * + * This LADSPA member function connects a port on an instantiated plug-in to a + * memory location at which a block of data for the port will be read/written. + * The data location is expected to be an array of LADSPA_Data for audio ports + * or a single LADSPA_Data value for control ports. Memory issues will be + * managed by the host. The plug-in must read/write the data at these locations + * every time run() or run_adding() is called and the data present at the time + * of this connection call should not be considered meaningful. + * + * Zyn Implementation + * ------------------ + * The buffer pointers are stored as member variables + * + * @param port [in] the port to be connected + * @param data [in] the data buffer to write to / read from + */ +void DSSIaudiooutput::connectPort(unsigned long port, LADSPA_Data * data) { - TS *plugin_data = (TS *) malloc(sizeof(TS)); - /* for (i=0; iomega[i] = M_PI * 2.0 / (double)s_rate * - pow(2.0, (i-69.0) / 12.0); - } - */ - return (LADSPA_Handle) plugin_data; -} - -static void activateTS(LADSPA_Handle instance) -{ - TS *plugin_data = (TS *) instance; - -// for (i=0; idata[i].active = 0; -// } -} - - -static void runTS(LADSPA_Handle instance, unsigned long sample_count, - snd_seq_event_t *events, unsigned long event_count) -{ - TS *plugin_data = (TS *) instance; -// LADSPA_Data *const output = plugin_data->output; -// LADSPA_Data freq = *(plugin_data->freq); -// LADSPA_Data vol = *(plugin_data->vol); -// note_data *data = plugin_data->data; - unsigned long pos; - unsigned long event_pos; - unsigned long note; - - /* if (freq < 1.0) { - freq = 440.0f; - } - if (vol < 0.000001) { - vol = 1.0f; - } - - if (event_count > 0) { - printf("trivial_synth: have %ld events\n", event_count); - } - - for (pos = 0, event_pos = 0; pos < sample_count; pos++) { - - while (event_pos < event_count - && pos == events[event_pos].time.tick) { - - printf("trivial_synth: event type %d\n", events[event_pos].type); - - if (events[event_pos].type == SND_SEQ_EVENT_NOTEON) { - data[events[event_pos].data.note.note].amp = - events[event_pos].data.note.velocity / 512.0f; - data[events[event_pos].data.note.note]. - active = events[event_pos].data.note.velocity > 0; - data[events[event_pos].data.note.note]. - phase = 0.0; - } else if (events[event_pos].type == SND_SEQ_EVENT_NOTEOFF) { - data[events[event_pos].data.note.note]. - active = 0; - } - event_pos++; - } - - output[pos] = 0.0f; - for (note = 0; note < MIDI_NOTES; note++) { - if (data[note].active) { - output[pos] += sin(data[note].phase) * data[note].amp * vol; - data[note].phase += plugin_data->omega[note] * freq; - if (data[note].phase > M_PI * 2.0) { - data[note].phase -= M_PI * 2.0; - } - } - } - } - */ -} - - -static void runTSWrapper(LADSPA_Handle instance, - unsigned long sample_count) -{ - runTS(instance, sample_count, NULL, 0); -} - -int getControllerTS(LADSPA_Handle instance, unsigned long port) -{ - return -1; -} - -void _init() -{ - char **port_names; - LADSPA_PortDescriptor *port_descriptors; - LADSPA_PortRangeHint *port_range_hints; - - FILE *a = fopen("/tmp/zzzzzz", "w"); - fprintf(a, "aaaaaaaaaaa TEST\n"); - fclose(a); - - - tsLDescriptor = (LADSPA_Descriptor *) malloc(sizeof(LADSPA_Descriptor)); - if(tsLDescriptor) { - tsLDescriptor->UniqueID = 100; - tsLDescriptor->Label = "ZASF"; - tsLDescriptor->Properties = 0; - tsLDescriptor->Name = "ZynAddSubFX"; - tsLDescriptor->Maker = - "Nasca Octavian Paul "; - tsLDescriptor->Copyright = "GNU General Public License v.2"; - tsLDescriptor->PortCount = 2; - - port_descriptors = (LADSPA_PortDescriptor *) - calloc(tsLDescriptor->PortCount, sizeof - (LADSPA_PortDescriptor)); - tsLDescriptor->PortDescriptors = - (const LADSPA_PortDescriptor *) port_descriptors; - - port_range_hints = (LADSPA_PortRangeHint *) - calloc(tsLDescriptor->PortCount, sizeof - (LADSPA_PortRangeHint)); - tsLDescriptor->PortRangeHints = - (const LADSPA_PortRangeHint *) port_range_hints; - - port_names = (char **) calloc(tsLDescriptor->PortCount, sizeof(char *)); - tsLDescriptor->PortNames = (const char **) port_names; - - port_descriptors[0] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; - port_names[0] = "Output L"; - port_range_hints[0].HintDescriptor = 0; - port_descriptors[1] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; - port_names[1] = "Output R"; - port_range_hints[1].HintDescriptor = 0; - - tsLDescriptor->activate = activateTS; - tsLDescriptor->cleanup = cleanupTS; - tsLDescriptor->connect_port = connectPortTS; - tsLDescriptor->deactivate = NULL; - tsLDescriptor->instantiate = instantiateTS; - tsLDescriptor->run = runTSWrapper; - tsLDescriptor->run_adding = NULL; - tsLDescriptor->set_run_adding_gain = NULL; - } - - tsDDescriptor = (DSSI_Descriptor *) malloc(sizeof(DSSI_Descriptor)); - if(tsDDescriptor) { - tsDDescriptor->DSSI_API_Version = 1; - tsDDescriptor->LADSPA_Plugin = tsLDescriptor; - tsDDescriptor->configure = NULL; - tsDDescriptor->get_program = NULL; - tsDDescriptor->get_midi_controller_for_port = getControllerTS; - tsDDescriptor->select_program = NULL; - tsDDescriptor->run_synth = runTS; - tsDDescriptor->run_synth_adding = NULL; - tsDDescriptor->run_multiple_synths = NULL; - tsDDescriptor->run_multiple_synths_adding = NULL; + switch (port) { + case 0: + outl = data; + break; + case 1: + outr = data; + break; } } -void _fini() -{} - - - - - - - -//the constructor and the destructor are defined in main.C -/* -void VSTSynth::process (float **inputs, float **outputs, long sampleframes){ - float *outl=outputs[0]; - float *outr=outputs[1]; - pthread_mutex_lock(&vmaster->mutex); - vmaster->GetAudioOutSamples(sampleframes,(int) getSampleRate(),outl,outr); - pthread_mutex_unlock(&vmaster->mutex); -}; - -void VSTSynth::processReplacing (float **inputs, float **outputs, long sampleframes){ - process(inputs,outputs,sampleframes); -}; - -long int VSTSynth::canDo(char *txt){ - if (strcmp(txt,"receiveVstEvents")==0) return (1); - if (strcmp(txt,"receiveVstMidiEvent")==0) return (1); - return(-1); -}; - -bool VSTSynth::getVendorString(char *txt){ - strcpy(txt,"Nasca O. Paul"); - return(true); -}; - -bool VSTSynth::getProductString(char *txt){ - strcpy(txt,"ZynAddSubFX"); - return(true); -}; - -void VSTSynth::resume(){ - wantEvents(); -}; - +/** + * Initialises a plug-in instance and activates it for use. + * + * This LADSPA member function initialises a plug-in instance and activates it + * for use. This is separated from instantiate() to aid real-time support and + * so that hosts can reinitialise a plug-in instance by calling deactivate() and + * then activate(). In this case the plug-in instance must reset all state + * information dependent on the history of the plug-in instance except for any + * data locations provided by connect_port() and any gain set by + * set_run_adding_gain(). + * + * Zyn Implementation + * ------------------ + * Currently this does nothing; Care must be taken as to code placed here as + * too much code here seems to cause time-out problems in jack-dssi-host. */ +void DSSIaudiooutput::activate() +{ +} +/** + * Runs an instance of a plug-in for a block. + * + * This LADSPA member function runs an instance of a plug-in for a block. + * Note that if an activate() function exists then it must be called before + * run() or run_adding(). If deactivate() is called for a plug-in instance then + * the plug-in instance may not be reused until activate() has been called again. + * + * Zyn Implementation + * ------------------ + * This is a LADSPA function that does not process any MIDI events; it is hence + * implemented by simply calling runSynth() with an empty event list. + * + * @param sample_count [in] the block size (in samples) for which the plug-in instance may run + */ +void DSSIaudiooutput::run(unsigned long sample_count) +{ + runSynth(sample_count,NULL,(unsigned long)0); +} + +/** + * Counterpart to activate(). + * + * This LADSPA member function is the counterpart to activate() (see above). + * Deactivation is not similar to pausing as the plug-in instance will be + * reinitialised when activate() is called to reuse it. + * + * Zyn Implementation + * ------------------ + * Currently this function does nothing. + */ +void DSSIaudiooutput::deactivate() +{ + +} + +/** + * Deletes a plug-in instance that is no longer required. + * + * LADSPA member function; once an instance of a plug-in has been finished with + * it can be deleted using this function. The instance handle ceases to be + * valid after this call. + * + * If activate() was called for a plug-in instance then a corresponding call to + * deactivate() must be made before cleanup() is called. + * + * Zyn Implementation + * ------------------ + * Currently cleanup is deferred to the destructor that is invoked after cleanup() + */ +void DSSIaudiooutput::cleanup() +{ +} + +/** + * Initial entry point for the LADSPA plug-in library. + * + * This LADSPA function is the initial entry point for the plug-in library. + * The LADSPA host looks for this entry point in each shared library object it + * finds and then calls the function to enumerate the plug-ins within the + * library. + * + * Zyn Implementation + * ------------------ + * As the Zyn plug-in is a DSSI plug-in, the LADSPA descriptor is embedded inside + * the DSSI descriptor, which is created by DSSIaudiooutput::initDssiDescriptor() + * statically when the library is loaded. This function then merely returns a pointer + * to that embedded descriptor. + * + * @param index [in] the index number of the plug-in within the library. + * @return if index is in range, a pointer to the plug-in descriptor is returned, else NULL + */ +const LADSPA_Descriptor* DSSIaudiooutput::getLadspaDescriptor(unsigned long index) +{ + if(index > 0 || dssiDescriptor == NULL) + return NULL; + else + return dssiDescriptor->LADSPA_Plugin; +} + +// +// DSSI member functions +// + +/** + * Provides a description of a program available on this synth. + * + * This DSSI member function pointer provides a description of a program (named + * preset sound) available on this synth. + * + * Zyn Implementation + * ------------------ + * The instruments in all Zyn's bank directories, as shown by the `instrument + * -> show instrument bank` command, are enumerated to the host by this + * function, allowing access to all those instruments. + * The first time an instrument is requested, the bank it is in and any + * unmapped ones preceding that are mapped; all the instruments names and + * filenames from those banks are stored in the programMap member variable for + * later use. This is done on demand in this way, rather than up front in one + * go because loading all the instrument names in one go can lead to timeouts + * and zombies. + * + * @param index [in] index into the plug-in's list of + * programs, not a program number as represented by the Program + * field of the DSSI_Program_Descriptor. (This distinction is + * needed to support synths that use non-contiguous program or + * bank numbers.) + * @return a DSSI_Program_Descriptor pointer that is + * guaranteed to be valid only until the next call to get_program, + * deactivate, or configure, on the same plug-in instance, or NULL if index is out of range. + */ +const DSSI_Program_Descriptor* DSSIaudiooutput::getProgram (unsigned long index) +{ + static DSSI_Program_Descriptor retVal; + + /* Make sure we have the list of banks loaded */ + initBanks(); + + /* Make sure that the bank containing the instrument has been mapped */ + while (index >= programMap.size() && mapNextBank()) + /* DO NOTHING MORE */; + + if(index >= programMap.size()) + { + /* No more instruments */ + return NULL; + } + else + { + /* OK, return the instrument */ + retVal.Name = programMap[index].name.c_str(); + retVal.Program = programMap[index].program; + retVal.Bank = programMap[index].bank; + return &retVal; + } +} + +/** + * Selects a new program for this synth. + * + * This DSSI member function selects a new program for this synth. The program + * change will take effect immediately at the start of the next run_synth() + * call. An invalid bank / instrument combination is ignored. + * + * Zyn Implementation + * ------------------ + * the banks and instruments are as shown in the `instrument -> show instrument + * bank` command in Zyn. The bank no is a 1-based index into the list of banks + * Zyn loads and shows in the drop down and the program number is the + * instrument within that bank. + * + * @param bank [in] the bank number to select + * @param program [in] the program number within the bank to select + */ +void DSSIaudiooutput::selectProgram(unsigned long bank, unsigned long program) +{ + initBanks(); +// cerr << "selectProgram(" << (bank & 0x7F) << ':' << ((bank >> 7) & 0x7F) << "," << program << ")" << '\n'; + if(bank < MAX_NUM_BANKS && program < BANK_SIZE) + { + char* bankdir = master->bank.banks[ bank ].dir; + if(bankdir != NULL) + { + pthread_mutex_lock(&master->mutex); + + /* We have to turn off the CheckPADsynth functionality, else + * the program change takes way too long and we get timeouts + * and hence zombies (!) */ + int save = config.cfg.CheckPADsynth; + config.cfg.CheckPADsynth = 0; + + /* Load the bank... */ + master->bank.loadbank(bankdir); + + /* restore the CheckPADsynth flag */ + config.cfg.CheckPADsynth = save; + + /* Now load the instrument... */ + master->bank.loadfromslot((unsigned int)program, master->part[0]); + + pthread_mutex_unlock(&master->mutex); + } + } +} + +/** + * Returns the MIDI controller number or NRPN for a input control port + * + * This DSSI member function returns the MIDI controller number or NRPN that + * should be mapped to the given input control port. If the given port should + * not have any MIDI controller mapped to it, the function will return DSSI_NONE. + * The behaviour of this function is undefined if the given port + * number does not correspond to an input control port. + * + * Zyn Implementation + * ------------------ + * Currently Zyn does not define any controller ports, but may do in the future. + * + * @param port [in] the input controller port + * @return the CC and NRPN values shifted and ORed together. + */ +int DSSIaudiooutput::getMidiControllerForPort(unsigned long port) +{ + return DSSI_NONE; +} + +/** + * Runs the synth for a block. + * + * This DSSI member function runs the synth for a block. This is identical in + * function to the LADSPA run() function, except that it also supplies events + * to the synth. + * + * Zyn Implementation + * ------------------ + * Zyn implements synthesis in Master::GetAudioOutSamples; runSynth calls this + * function in chunks delimited by the sample_count and the frame indexes in + * the events block, calling the appropriate NoteOn, NoteOff and SetController + * members of Master to process the events supplied between each chunk. + * + * @param sample_count [in] the block size (in samples) for which the synth + * instance may run. + * @param events [in] The Events pointer points to a block of ALSA + * sequencer events, used to communicate MIDI and related events to the synth. + * Each event must be timestamped relative to the start of the block, + * (mis)using the ALSA "tick time" field as a frame count. The host is + * responsible for ensuring that events with differing timestamps are already + * ordered by time. Must not include NOTE (only NOTE_ON / NOTE_OFF), LSB or MSB + * events. + * @param event_count [in] the number of entries in the `events` block + */ +void DSSIaudiooutput::runSynth(unsigned long sample_count, snd_seq_event_t *events, unsigned long event_count) +{ + unsigned long from_frame = 0; + unsigned long event_index = 0; + unsigned long next_event_frame = 0; + unsigned long to_frame = 0; + pthread_mutex_lock(&master->mutex); + + do { + /* Find the time of the next event, if any */ + if(events == NULL || event_index >= event_count) + next_event_frame = ULONG_MAX; + else + next_event_frame = events[event_index].time.tick; + + /* find the end of the sub-sample to be processed this time round... */ + /* if the next event falls within the desired sample interval... */ + if(next_event_frame < sample_count && next_event_frame >= to_frame) + /* set the end to be at that event */ + to_frame = next_event_frame; + else + /* ...else go for the whole remaining sample */ + to_frame = sample_count; + if(from_frameGetAudioOutSamples(to_frame - from_frame, (int)sampleRate, &(outl[from_frame]), &(outr[from_frame])); + // next sub-sample please... + from_frame = to_frame; + } + + // Now process any event(s) at the current timing point + while(events != NULL && event_index < event_count && events[event_index].time.tick == to_frame) + { + if(events[event_index].type == SND_SEQ_EVENT_NOTEON) + { + master->NoteOn(events[event_index].data.note.channel, events[event_index].data.note.note, events[event_index].data.note.velocity); + } + else if(events[event_index].type == SND_SEQ_EVENT_NOTEOFF) + { + master->NoteOff(events[event_index].data.note.channel, events[event_index].data.note.note); + } + else if(events[event_index].type == SND_SEQ_EVENT_CONTROLLER) + { + master->SetController(events[event_index].data.control.channel, events[event_index].data.control.param, events[event_index].data.control.value); + } + else + { + } + event_index++; + } + + // Keep going until we have the desired total length of sample... + } while(to_frame < sample_count); + + pthread_mutex_unlock(&master->mutex); +} + +/** + * Initial entry point for the DSSI plug-in library. + * + * This DSSI function is the initial entry point for the plug-in library. + * The DSSI host looks for this entry point in each shared library object it + * finds and then calls the function to enumerate the plug-ins within the + * library. + * + * Zyn Implementation + * ------------------ + * The descriptor is created statically by DSSIaudiooutput::initDssiDescriptor() + * when the plug-in library is loaded. This function merely returns a pointer to + * that descriptor. + * + * @param index [in] the index number of the plug-in within the library. + * @return if index is in range, a pointer to the plug-in descriptor is returned, else NULL + */ +const DSSI_Descriptor* DSSIaudiooutput::getDssiDescriptor(unsigned long index) +{ + if(index > 0 || dssiDescriptor == NULL) + return NULL; + else + return dssiDescriptor; +} + +// +// Internal member functions +// + +// Initialise the DSSI descriptor, statically: +DSSI_Descriptor* DSSIaudiooutput::dssiDescriptor = DSSIaudiooutput::initDssiDescriptor(); + +/** + * Initializes the DSSI (and LADSPA) descriptor, returning it is an object. + */ +DSSI_Descriptor* DSSIaudiooutput::initDssiDescriptor() +{ + DSSI_Descriptor* newDssiDescriptor = new DSSI_Descriptor; + + LADSPA_PortDescriptor* newPortDescriptors; + char** newPortNames; + LADSPA_PortRangeHint* newPortRangeHints; + + if (newDssiDescriptor) + { + LADSPA_Descriptor* newLadspaDescriptor = new LADSPA_Descriptor; + if (newLadspaDescriptor) + { + newLadspaDescriptor->UniqueID = 100; + newLadspaDescriptor->Label = "ZASF"; + newLadspaDescriptor->Properties = 0; + newLadspaDescriptor->Name = "ZynAddSubFX"; + newLadspaDescriptor->Maker = "Nasca Octavian Paul "; + newLadspaDescriptor->Copyright = "GNU General Public License v.2"; + newLadspaDescriptor->PortCount = 2; + + newPortNames = new char *[newLadspaDescriptor->PortCount]; + newPortNames[0] = "Output L"; + newPortNames[1] = "Output R"; + newLadspaDescriptor->PortNames = newPortNames; + + newPortDescriptors = new LADSPA_PortDescriptor[newLadspaDescriptor->PortCount]; + newPortDescriptors[0] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; + newPortDescriptors[1] = LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO; + newLadspaDescriptor->PortDescriptors = newPortDescriptors; + + newPortRangeHints = new LADSPA_PortRangeHint[newLadspaDescriptor->PortCount]; + newPortRangeHints[0].HintDescriptor = 0; + newPortRangeHints[1].HintDescriptor = 0; + newLadspaDescriptor->PortRangeHints = newPortRangeHints; + + newLadspaDescriptor->activate = stub_activate; + newLadspaDescriptor->cleanup = stub_cleanup; + newLadspaDescriptor->connect_port = stub_connectPort; + newLadspaDescriptor->deactivate = stub_deactivate; + newLadspaDescriptor->instantiate = instantiate; + newLadspaDescriptor->run = stub_run; + newLadspaDescriptor->run_adding = NULL; + newLadspaDescriptor->set_run_adding_gain = NULL; + } + newDssiDescriptor->LADSPA_Plugin = newLadspaDescriptor; + newDssiDescriptor->DSSI_API_Version = 1; + newDssiDescriptor->configure = NULL; + newDssiDescriptor->get_program = stub_getProgram; + newDssiDescriptor->get_midi_controller_for_port = stub_getMidiControllerForPort; + newDssiDescriptor->select_program = stub_selectProgram; + newDssiDescriptor->run_synth = stub_runSynth; + newDssiDescriptor->run_synth_adding = NULL; + newDssiDescriptor->run_multiple_synths = NULL; + newDssiDescriptor->run_multiple_synths_adding = NULL; + } + + dssiDescriptor = newDssiDescriptor; + + return dssiDescriptor; +} + +/** + * Converts a LADSPA / DSSI handle into a DSSIaudiooutput instance. + * + * @param instance [in] + * @return the instance + */ +DSSIaudiooutput* DSSIaudiooutput::getInstance(LADSPA_Handle instance) +{ + return (DSSIaudiooutput*)(instance); +} + +/** + * The private sole constructor for the DSSIaudiooutput class. + * + * Only ever called via instantiate(). + * @param sampleRate [in] the sample rate to be used by the synth. + * @return + */ +DSSIaudiooutput::DSSIaudiooutput(unsigned long sampleRate) +{ + this->sampleRate = sampleRate; + this->banksInited = false; + + config.init(); + + srand(time(NULL)); + denormalkillbuf=new REALTYPE [SOUND_BUFFER_SIZE]; + for (int i=0;imaster = new Master(); +} + +/** + * The destructor for the DSSIaudiooutput class + * @return + */ +DSSIaudiooutput::~DSSIaudiooutput() +{ +} + +/** + * Ensures the list of bank (directories) has been initialised. + */ +void DSSIaudiooutput::initBanks(void) +{ + if(!banksInited) + { + pthread_mutex_lock(&master->mutex); + master->bank.rescanforbanks(); + banksInited = true; + pthread_mutex_unlock(&master->mutex); + } +} + +/** + * constructor for the internally used ProgramDescriptor class + * + * @param _bank [in] bank number + * @param _program [in] program number + * @param _name [in] instrument / sample name + * @return + */ +DSSIaudiooutput::ProgramDescriptor::ProgramDescriptor(unsigned long _bank, unsigned long _program, char* _name) : + bank(_bank), program(_program), name(_name) +{ +} + +/** + * The map of programs available; held as a single shared statically allocated object. + */ +vector DSSIaudiooutput::programMap = vector(); + +/** + * Index controlling the map of banks + */ +long DSSIaudiooutput::bankNoToMap = 1; + +/** + * Queries and maps the next available bank of instruments. + * + * If the program index requested to getProgram() lies beyond the banks mapped to date, + * this member function is called to map the next one. + * @return true if a new bank has been found and mapped, else false. + */ +bool DSSIaudiooutput::mapNextBank() +{ + pthread_mutex_lock(&master->mutex); + Bank& bank = master->bank; + bool retval; + if(bankNoToMap >= MAX_NUM_BANKS || bank.banks[bankNoToMap].dir == NULL) + { + retval = false; + } + else + { + bank.loadbank(bank.banks[bankNoToMap].dir); + for(unsigned long instrument = 0; instrument < BANK_SIZE; instrument++) + { + char* insName = bank.getname(instrument); + if(insName != NULL && insName[0] != '\0' && insName[0] != ' ') + { + programMap.push_back(ProgramDescriptor(bankNoToMap,instrument,insName)); + } + } + bankNoToMap ++; + retval = true; + } + pthread_mutex_unlock(&master->mutex); + return retval; +} diff --git a/plugins/zynaddsubfx/src/Output/DSSIaudiooutput.h b/plugins/zynaddsubfx/src/Output/DSSIaudiooutput.h index a2ecf3c55..076367a72 100644 --- a/plugins/zynaddsubfx/src/Output/DSSIaudiooutput.h +++ b/plugins/zynaddsubfx/src/Output/DSSIaudiooutput.h @@ -26,34 +26,86 @@ #include "../globals.h" #include "../Misc/Master.h" -#include "../UI/MasterUI.h" #include #include +#include -/* -class VSTSynth:public AudioEffectX{ - public: - VSTSynth (audioMasterCallback audioMaster); - ~VSTSynth(); +class DSSIaudiooutput +{ +public: + // + // Static stubs for LADSPA member functions + // + static void stub_connectPort(LADSPA_Handle instance, unsigned long port, LADSPA_Data * data); + static void stub_activate(LADSPA_Handle instance); + static void stub_run(LADSPA_Handle instance, unsigned long sample_count); + static void stub_deactivate(LADSPA_Handle Instance); + static void stub_cleanup(LADSPA_Handle instance); - virtual void process (float **inputs, float **outputs, long sampleframes); - virtual void processReplacing (float **inputs, float **outputs, long sampleframes); - virtual long processEvents(VstEvents *events);//this is used for Midi input - virtual long int canDo(char *txt); - virtual bool getVendorString(char *txt); - virtual bool getProductString(char *txt); - virtual void resume(); + // + // Static stubs for DSSI member functions + // + static const DSSI_Program_Descriptor* stub_getProgram (LADSPA_Handle instance, unsigned long Index); + static void stub_selectProgram(LADSPA_Handle instance, unsigned long bank, unsigned long program); + static int stub_getMidiControllerForPort(LADSPA_Handle instance, unsigned long port); + static void stub_runSynth(LADSPA_Handle instance, unsigned long sample_count, + snd_seq_event_t *events, unsigned long event_count); - virtual long getChunk(void** data,bool isPreset=false); - virtual void setChunk(void *data,long size,bool isPreset=false); + /* + * LADSPA member functions + */ + static LADSPA_Handle instantiate(const LADSPA_Descriptor * descriptor, unsigned long s_rate); + void connectPort(unsigned long port, LADSPA_Data * data); + void activate(); + void run(unsigned long sample_count); + void deactivate(); + void cleanup(); + static const LADSPA_Descriptor* getLadspaDescriptor(unsigned long index); - MasterUI *ui; - int Pexitprogram; + /* + * DSSI member functions + */ + const DSSI_Program_Descriptor* getProgram (unsigned long Index); + void selectProgram(unsigned long bank, unsigned long program); + int getMidiControllerForPort(unsigned long port); + void runSynth(unsigned long sample_count, snd_seq_event_t *events, unsigned long event_count); + static const DSSI_Descriptor* getDssiDescriptor(unsigned long index); - Master *vmaster; - pthread_t thr; + struct ProgramDescriptor + { + unsigned long bank; + unsigned long program; + string name; + ProgramDescriptor(unsigned long _bank, unsigned long _program, char* _name); + }; + +private: + + DSSIaudiooutput(unsigned long sampleRate); + ~DSSIaudiooutput(); + static DSSI_Descriptor* initDssiDescriptor(); + static DSSIaudiooutput* getInstance(LADSPA_Handle instance); + void initBanks(); + bool mapNextBank(); + + LADSPA_Data *outl; + LADSPA_Data *outr; + long sampleRate; + Master* master; + static DSSI_Descriptor* dssiDescriptor; + static string bankDirNames[]; + static + vector programMap; + + /** + * Flag controlling the list of bank directories + */ + bool banksInited; + + static + long bankNoToMap; }; -*/ + #endif diff --git a/plugins/zynaddsubfx/src/Output/JACK_RTaudiooutput.cpp b/plugins/zynaddsubfx/src/Output/JACK_RTaudiooutput.cpp index 2ee019d1c..2e63e659b 100644 --- a/plugins/zynaddsubfx/src/Output/JACK_RTaudiooutput.cpp +++ b/plugins/zynaddsubfx/src/Output/JACK_RTaudiooutput.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - JACKaudiooutput.C - Audio output for JACK + JACKaudiooutput.cpp - Audio output for JACK Copyright (C) 2002 Nasca Octavian Paul Author: Nasca Octavian Paul diff --git a/plugins/zynaddsubfx/src/Output/JACKaudiooutput.cpp b/plugins/zynaddsubfx/src/Output/JACKaudiooutput.cpp index 15f249246..d3c25fdd9 100644 --- a/plugins/zynaddsubfx/src/Output/JACKaudiooutput.cpp +++ b/plugins/zynaddsubfx/src/Output/JACKaudiooutput.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - JACKaudiooutput.C - Audio output for JACK + JACKaudiooutput.cpp - Audio output for JACK Copyright (C) 2002 Nasca Octavian Paul Author: Nasca Octavian Paul diff --git a/plugins/zynaddsubfx/src/Output/OSSaudiooutput.cpp b/plugins/zynaddsubfx/src/Output/OSSaudiooutput.cpp index ad77573af..f6c6b3f0f 100644 --- a/plugins/zynaddsubfx/src/Output/OSSaudiooutput.cpp +++ b/plugins/zynaddsubfx/src/Output/OSSaudiooutput.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - OSSaudiooutput.C - Audio output for Open Sound System + OSSaudiooutput.cpp - Audio output for Open Sound System Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul diff --git a/plugins/zynaddsubfx/src/Output/PAaudiooutput.cpp b/plugins/zynaddsubfx/src/Output/PAaudiooutput.cpp index 73b346827..bfd84cca9 100644 --- a/plugins/zynaddsubfx/src/Output/PAaudiooutput.cpp +++ b/plugins/zynaddsubfx/src/Output/PAaudiooutput.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - PAaudiooutput.C - Audio output for PortAudio + PAaudiooutput.cpp - Audio output for PortAudio Copyright (C) 2002 Nasca Octavian Paul Author: Nasca Octavian Paul diff --git a/plugins/zynaddsubfx/src/Output/Recorder.cpp b/plugins/zynaddsubfx/src/Output/Recorder.cpp index 43a44630e..244047ce8 100644 --- a/plugins/zynaddsubfx/src/Output/Recorder.cpp +++ b/plugins/zynaddsubfx/src/Output/Recorder.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - Recorder.C - Records sound to a file + Recorder.cpp - Records sound to a file Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul diff --git a/plugins/zynaddsubfx/src/Output/VSTaudiooutput.cpp b/plugins/zynaddsubfx/src/Output/VSTaudiooutput.cpp index 183a3bb55..494a127c0 100644 --- a/plugins/zynaddsubfx/src/Output/VSTaudiooutput.cpp +++ b/plugins/zynaddsubfx/src/Output/VSTaudiooutput.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - VSTaudiooutput.C - Audio output for VST + VSTaudiooutput.cpp - Audio output for VST Copyright (C) 2002 Nasca Octavian Paul Author: Nasca Octavian Paul @@ -22,7 +22,7 @@ #include #include "VSTaudiooutput.h" -//the constructor and the destructor are defined in main.C +//the constructor and the destructor are defined in main.cpp void VSTSynth::process(float **inputs, float **outputs, long sampleframes) { diff --git a/plugins/zynaddsubfx/src/Params/ADnoteParameters.cpp b/plugins/zynaddsubfx/src/Params/ADnoteParameters.cpp index 5bd974978..91f3449f1 100644 --- a/plugins/zynaddsubfx/src/Params/ADnoteParameters.cpp +++ b/plugins/zynaddsubfx/src/Params/ADnoteParameters.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - ADnoteParameters.C - Parameters for ADnote (ADsynth) + ADnoteParameters.cpp - Parameters for ADnote (ADsynth) Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul diff --git a/plugins/zynaddsubfx/src/Params/Controller.cpp b/plugins/zynaddsubfx/src/Params/Controller.cpp index 61a0793e0..9bfa6b47d 100644 --- a/plugins/zynaddsubfx/src/Params/Controller.cpp +++ b/plugins/zynaddsubfx/src/Params/Controller.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - Controller.C - (Midi) Controllers implementation + Controller.cpp - (Midi) Controllers implementation Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul diff --git a/plugins/zynaddsubfx/src/Params/EnvelopeParams.cpp b/plugins/zynaddsubfx/src/Params/EnvelopeParams.cpp index bb8207ba6..c13039f0f 100644 --- a/plugins/zynaddsubfx/src/Params/EnvelopeParams.cpp +++ b/plugins/zynaddsubfx/src/Params/EnvelopeParams.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - EnvelopeParams.C - Parameters for Envelope + EnvelopeParams.cpp - Parameters for Envelope Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul diff --git a/plugins/zynaddsubfx/src/Params/FilterParams.cpp b/plugins/zynaddsubfx/src/Params/FilterParams.cpp index 5f5747332..6f87bc1a3 100644 --- a/plugins/zynaddsubfx/src/Params/FilterParams.cpp +++ b/plugins/zynaddsubfx/src/Params/FilterParams.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - FilterParams.C - Parameters for filter + FilterParams.cpp - Parameters for filter Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul diff --git a/plugins/zynaddsubfx/src/Params/LFOParams.cpp b/plugins/zynaddsubfx/src/Params/LFOParams.cpp index fe993ed93..33028defc 100644 --- a/plugins/zynaddsubfx/src/Params/LFOParams.cpp +++ b/plugins/zynaddsubfx/src/Params/LFOParams.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - LFOParams.C - Parameters for LFO + LFOParams.cpp - Parameters for LFO Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul @@ -33,7 +33,7 @@ LFOParams::LFOParams(char Pfreq_, char PLFOtype_, char Prandomness_, char Pdelay_, - char Pcontinuous_, + char Pcontinous_, char fel_):Presets() { switch(fel_) { @@ -53,7 +53,7 @@ LFOParams::LFOParams(char Pfreq_, DLFOtype = PLFOtype_; Drandomness = Prandomness_; Ddelay = Pdelay_; - Dcontinuous = Pcontinuous_; + Dcontinous = Pcontinous_; fel = fel_; time = 0; @@ -71,7 +71,7 @@ void LFOParams::defaults() PLFOtype = DLFOtype; Prandomness = Drandomness; Pdelay = Ddelay; - Pcontinuous = Dcontinuous; + Pcontinous = Dcontinous; Pfreqrand = 0; Pstretch = 64; } @@ -87,7 +87,7 @@ void LFOParams::add2XML(XMLwrapper *xml) xml->addpar("randomness_frequency", Pfreqrand); xml->addpar("delay", Pdelay); xml->addpar("stretch", Pstretch); - xml->addparbool("continuous", Pcontinuous); + xml->addparbool("continous", Pcontinous); } void LFOParams::getfromXML(XMLwrapper *xml) @@ -100,6 +100,6 @@ void LFOParams::getfromXML(XMLwrapper *xml) Pfreqrand = xml->getpar127("randomness_frequency", Pfreqrand); Pdelay = xml->getpar127("delay", Pdelay); Pstretch = xml->getpar127("stretch", Pstretch); - Pcontinuous = xml->getparbool("continuous", Pcontinuous); + Pcontinous = xml->getparbool("continous", Pcontinous); } diff --git a/plugins/zynaddsubfx/src/Params/LFOParams.h b/plugins/zynaddsubfx/src/Params/LFOParams.h index b1b99eecd..6a7dcd915 100644 --- a/plugins/zynaddsubfx/src/Params/LFOParams.h +++ b/plugins/zynaddsubfx/src/Params/LFOParams.h @@ -35,7 +35,7 @@ class LFOParams:public Presets char PLFOtype_, char Prandomness_, char Pdelay_, - char Pcontinuous, + char Pcontinous, char fel_); ~LFOParams(); @@ -52,11 +52,11 @@ class LFOParams:public Presets unsigned char Prandomness; /**type); - strcat(type, "n"); + //strcat(type, "n"); if(name == NULL) if(strstr(type, "Plfo") != NULL) strcpy(type, "Plfo"); - ; xml->beginbranch(type); add2XML(xml); @@ -69,12 +68,11 @@ void Presets::paste(int npreset) { char type[MAX_PRESETTYPE_SIZE]; strcpy(type, this->type); - strcat(type, "n"); + //strcat(type, "n"); if(npreset == 0) if(strstr(type, "Plfo") != NULL) strcpy(type, "Plfo"); - ; XMLwrapper *xml = new XMLwrapper(); if(npreset == 0) { @@ -108,10 +106,6 @@ void Presets::paste(int npreset) bool Presets::checkclipboardtype() { - char type[MAX_PRESETTYPE_SIZE]; - strcpy(type, this->type); - strcat(type, "n"); - return presetsstore.checkclipboardtype(type); } diff --git a/plugins/zynaddsubfx/src/Params/PresetsArray.cpp b/plugins/zynaddsubfx/src/Params/PresetsArray.cpp index 08e7cea45..b1c9a2e0d 100644 --- a/plugins/zynaddsubfx/src/Params/PresetsArray.cpp +++ b/plugins/zynaddsubfx/src/Params/PresetsArray.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - PresetsArray.C - PresetsArray and Clipboard management + PresetsArray.cpp - PresetsArray and Clipboard management Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul diff --git a/plugins/zynaddsubfx/src/Params/PresetsStore.cpp b/plugins/zynaddsubfx/src/Params/PresetsStore.cpp index 83c179299..46a8bd682 100644 --- a/plugins/zynaddsubfx/src/Params/PresetsStore.cpp +++ b/plugins/zynaddsubfx/src/Params/PresetsStore.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - PresetsStore.C - Presets and Clipboard store + PresetsStore.cpp - Presets and Clipboard store Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul @@ -19,6 +19,9 @@ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include +#include +#include #include #include #include @@ -27,17 +30,14 @@ #include "PresetsStore.h" #include "../Misc/Util.h" +using namespace std; + PresetsStore presetsstore; PresetsStore::PresetsStore() { clipboard.data = NULL; clipboard.type[0] = 0; - - for(int i = 0; i < MAX_PRESETS; i++) { - presets[i].file = NULL; - presets[i].name = NULL; - } } PresetsStore::~PresetsStore() @@ -66,7 +66,7 @@ bool PresetsStore::pasteclipboard(XMLwrapper *xml) return true; } -bool PresetsStore::checkclipboardtype(char *type) +bool PresetsStore::checkclipboardtype(const char *type) { //makes LFO's compatible if((strstr(type, @@ -78,128 +78,88 @@ bool PresetsStore::checkclipboardtype(char *type) //Presets management void PresetsStore::clearpresets() { - for(int i = 0; i < MAX_PRESETS; i++) { - if(presets[i].file != NULL) { - delete (presets[i].file); - presets[i].file = NULL; - } - if(presets[i].name != NULL) { - delete (presets[i].name); - presets[i].name = NULL; - } - } + presets.clear(); } //a helper function that compares 2 presets[] -int Presets_compar(const void *a, const void *b) +bool PresetsStore::presetstruct::operator<(const presetstruct &b) const { - struct PresetsStore::presetstruct *p1 = (PresetsStore::presetstruct *)a; - struct PresetsStore::presetstruct *p2 = (PresetsStore::presetstruct *)b; - if(((p1->name) == NULL) || ((p2->name) == NULL)) - return 0; - - return strcasecmp(p1->name, p2->name) < 0; + return name < b.name; } -void PresetsStore::rescanforpresets(char *type) +void PresetsStore::rescanforpresets(string type) { + //std::cout << "Scanning For Presets" << std::endl; + //std::cout << "Of Type: " << type << std::endl; + clearpresets(); - int presetk = 0; - char ftype[MAX_STRING_SIZE]; - snprintf(ftype, MAX_STRING_SIZE, ".%s.xpz", type); + string ftype = "." + type + ".xpz"; for(int i = 0; i < MAX_BANK_ROOT_DIRS; i++) { if(config.cfg.presetsDirList[i] == NULL) continue; - char *dirname = config.cfg.presetsDirList[i]; - DIR *dir = opendir(dirname); + + //open directory + string dirname = config.cfg.presetsDirList[i]; + DIR *dir = opendir(dirname.c_str()); if(dir == NULL) continue; struct dirent *fn; + + //check all files in directory while((fn = readdir(dir))) { - const char *filename = fn->d_name; - if(strstr(filename, ftype) == NULL) + string filename = fn->d_name; + if(filename.find(ftype) == string::npos) continue; - - presets[presetk].file = new char [MAX_STRING_SIZE]; - presets[presetk].name = new char [MAX_STRING_SIZE]; - char tmpc = dirname[strlen(dirname) - 1]; + //ensure proper path is formed + char tmpc = dirname[dirname.size() - 1]; const char *tmps; if((tmpc == '/') || (tmpc == '\\')) tmps = ""; else tmps = "/"; - snprintf(presets[presetk].file, - MAX_STRING_SIZE, - "%s%s%s", - dirname, - tmps, - filename); - snprintf(presets[presetk].name, MAX_STRING_SIZE, "%s", filename); - char *tmp = strstr(presets[presetk].name, ftype); - if(tmp != NULL) - tmp[0] = '\0'; - presetk++; - if(presetk >= MAX_PRESETS) - return; + string location = "" + dirname + tmps + filename; + + //trim file type off of name + string name = filename.substr(0, filename.find(ftype)); + + //put on list + presets.push_back(presetstruct(location, name)); } closedir(dir); } //sort the presets - for(int j = 0; j < MAX_PRESETS - 1; j++) { - for(int i = j + 1; i < MAX_PRESETS; i++) { - if(Presets_compar(&presets[i], &presets[j])) { - presetstruct tmp = presets[i]; - presets[i] = presets[j]; - presets[j] = tmp; - } - } - } + sort(presets.begin(), presets.end()); } -void PresetsStore::copypreset(XMLwrapper *xml, char *type, const char *name) -{ - char filename[MAX_STRING_SIZE], tmpfilename[MAX_STRING_SIZE]; +void PresetsStore::copypreset(XMLwrapper *xml, char *type, string name) +{ if(config.cfg.presetsDirList[0] == NULL) return; - snprintf(tmpfilename, MAX_STRING_SIZE, "%s", name); - //make the filenames legal - for(int i = 0; i < (int) strlen(tmpfilename); i++) { - char c = tmpfilename[i]; - if((c >= '0') && (c <= '9')) - continue; - if((c >= 'A') && (c <= 'Z')) - continue; - if((c >= 'a') && (c <= 'z')) - continue; - if((c == '-') || (c == ' ')) - continue; - tmpfilename[i] = '_'; + for(int i = 0; i < (int) name.size(); i++) { + char c = name[i]; + if(!(isdigit(c) || isalpha(c) || (c == '-') || (c == ' '))) + name[i] = '_'; } - const char *dirname = config.cfg.presetsDirList[0]; - char tmpc = dirname[strlen(dirname) - 1]; + //make path legal + const string dirname = config.cfg.presetsDirList[0]; + char tmpc = dirname[dirname.size() - 1]; const char *tmps; if((tmpc == '/') || (tmpc == '\\')) tmps = ""; else tmps = "/"; - snprintf(filename, - MAX_STRING_SIZE, - "%s%s%s.%s.xpz", - dirname, - tmps, - name, - type); + string filename("" + dirname + tmps + name + type); xml->saveXMLfile(filename); } @@ -207,10 +167,10 @@ void PresetsStore::copypreset(XMLwrapper *xml, char *type, const char *name) bool PresetsStore::pastepreset(XMLwrapper *xml, int npreset) { npreset--; - if(npreset >= MAX_PRESETS) + if(npreset >= presets.size()) return false; - char *filename = presets[npreset].file; - if(filename == NULL) + string filename = presets[npreset].file; + if(filename.empty()) return false; bool result = (xml->loadXMLfile(filename) >= 0); return result; @@ -219,11 +179,11 @@ bool PresetsStore::pastepreset(XMLwrapper *xml, int npreset) void PresetsStore::deletepreset(int npreset) { npreset--; - if(npreset >= MAX_PRESETS) + if(npreset >= presets.size()) return; - char *filename = presets[npreset].file; - if(filename == NULL) + string filename = presets[npreset].file; + if(filename.empty()) return; - remove(filename); + remove(filename.c_str()); } diff --git a/plugins/zynaddsubfx/src/Params/PresetsStore.h b/plugins/zynaddsubfx/src/Params/PresetsStore.h index c81498231..f498e7829 100644 --- a/plugins/zynaddsubfx/src/Params/PresetsStore.h +++ b/plugins/zynaddsubfx/src/Params/PresetsStore.h @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - PresetsStore.C - Presets and Clipboard store + PresetsStore.cpp - Presets and Clipboard store Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul @@ -20,11 +20,12 @@ */ +#include +#include #include "../Misc/XMLwrapper.h" #include "../Misc/Config.h" #define MAX_PRESETTYPE_SIZE 30 -#define MAX_PRESETS 1000 class PresetsStore { @@ -35,20 +36,23 @@ class PresetsStore //Clipboard stuff void copyclipboard(XMLwrapper *xml, char *type); bool pasteclipboard(XMLwrapper *xml); - bool checkclipboardtype(char *type); + bool checkclipboardtype(const char *type); //presets stuff - void copypreset(XMLwrapper *xml, char *type, const char *name); + void copypreset(XMLwrapper *xml, char *type, std::string name); bool pastepreset(XMLwrapper *xml, int npreset); void deletepreset(int npreset); struct presetstruct { - char *file; - char *name; + presetstruct(std::string _file, std::string _name) + :file(_file),name(_name){}; + bool operator<(const presetstruct &b) const; + std::string file; + std::string name; }; - presetstruct presets[MAX_PRESETS]; + std::vector presets; - void rescanforpresets(char *type); + void rescanforpresets(const std::string type); private: struct { diff --git a/plugins/zynaddsubfx/src/Params/SUBnoteParameters.cpp b/plugins/zynaddsubfx/src/Params/SUBnoteParameters.cpp index 27fdb46d0..425ddad75 100644 --- a/plugins/zynaddsubfx/src/Params/SUBnoteParameters.cpp +++ b/plugins/zynaddsubfx/src/Params/SUBnoteParameters.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - SUBnoteParameters.C - Parameters for SUBnote (SUBsynth) + SUBnoteParameters.cpp - Parameters for SUBnote (SUBsynth) Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul diff --git a/plugins/zynaddsubfx/src/Samples/AuSample.cpp b/plugins/zynaddsubfx/src/Samples/AuSample.cpp deleted file mode 100644 index 49f3a2887..000000000 --- a/plugins/zynaddsubfx/src/Samples/AuSample.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - ZynAddSubFX - a software synthesizer - - AuSample.h - Object for storing information on audio samples (for one channel) - Copyright (C) 2009-2009 Mark McCurry - Author: Mark McCurry - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License - as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License (version 2 or later) for more details. - - You should have received a copy of the GNU General Public License (version 2) - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -#include "AuSample.h" - -AuSample::AuSample(int length, REALTYPE fill) - :Sample(length, fill) {} - -AuSample::AuSample(int length, const REALTYPE *input) - :Sample(length, input) {} - diff --git a/plugins/zynaddsubfx/src/Samples/AuSample.h b/plugins/zynaddsubfx/src/Samples/AuSample.h deleted file mode 100644 index cad4a786c..000000000 --- a/plugins/zynaddsubfx/src/Samples/AuSample.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - ZynAddSubFX - a software synthesizer - - AuSample.h - Object for storing information on audio samples (for one channel) - Copyright (C) 2009-2009 Mark McCurry - Author: Mark McCurry - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License - as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License (version 2 or later) for more details. - - You should have received a copy of the GNU General Public License (version 2) - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -#ifndef AUSAMPLE_H -#define AUSAMPLE_H - -#include "Sample.h" -#include "FqSample.h" - -class AuSample:public Sample -{ - public: - AuSample(int length, REALTYPE fill = 0); - AuSample(int length, const REALTYPE *input); - FqSample getFqSample(); /**\todo implement this*/ -}; -#endif - diff --git a/plugins/zynaddsubfx/src/Samples/CMakeLists.txt b/plugins/zynaddsubfx/src/Samples/CMakeLists.txt index 2efd9e924..a6ef7b2a0 100644 --- a/plugins/zynaddsubfx/src/Samples/CMakeLists.txt +++ b/plugins/zynaddsubfx/src/Samples/CMakeLists.txt @@ -1,6 +1,4 @@ set(zynaddsubfx_samples_SRCS - AuSample.cpp - FqSample.cpp Sample.cpp ) diff --git a/plugins/zynaddsubfx/src/Samples/FqSample.cpp b/plugins/zynaddsubfx/src/Samples/FqSample.cpp deleted file mode 100644 index 94774047a..000000000 --- a/plugins/zynaddsubfx/src/Samples/FqSample.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/* - ZynAddSubFX - a software synthesizer - - FqSample.C - Object for storing information on samples - Copyright (C) 2009-2009 Mark McCurry - Author: Mark McCurry - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License - as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License (version 2 or later) for more details. - - You should have received a copy of the GNU General Public License (version 2) - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -#include "FqSample.h" - -FqSample::FqSample(int length, REALTYPE fill) - :Sample(length, fill) -{} - -FqSample::FqSample(int length, const REALTYPE *input) - :Sample(length, input) -{} - -FqSample::~FqSample() -{} - diff --git a/plugins/zynaddsubfx/src/Samples/FqSample.h b/plugins/zynaddsubfx/src/Samples/FqSample.h deleted file mode 100644 index fd31535cb..000000000 --- a/plugins/zynaddsubfx/src/Samples/FqSample.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - ZynAddSubFX - a software synthesizer - - FqSample.h - Object for storing information on samples - Copyright (C) 2009-2009 Mark McCurry - Author: Mark McCurry - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License - as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License (version 2 or later) for more details. - - You should have received a copy of the GNU General Public License (version 2) - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -#ifndef MONOSAMPLE_H -#define MONOSAMPLE_H - -#include "FqSample.h" -#include "Sample.h" - -class FqSample:public Sample -{ - public: - FqSample(int length, REALTYPE fill = 0); - FqSample(int length, const REALTYPE *input); - ~FqSample(); - //FqSample &operator=(const FqSample &smp); - //float *dontuse(){return buffer;}; -}; -#endif - diff --git a/plugins/zynaddsubfx/src/Samples/Sample.cpp b/plugins/zynaddsubfx/src/Samples/Sample.cpp index ca5bdc128..8fe022b65 100644 --- a/plugins/zynaddsubfx/src/Samples/Sample.cpp +++ b/plugins/zynaddsubfx/src/Samples/Sample.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - Sample.C - Object for storing information on samples + Sample.cpp - Object for storing information on samples Copyright (C) 2009-2009 Mark McCurry Author: Mark McCurry @@ -19,8 +19,13 @@ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include +#include //for memcpy/memset +#include #include "Sample.h" +using namespace std; + +#warning TODO Think about renaming Sample to Frame /**\TODO start using pointer math here as these will be Frequency called * functions throughout the code*/ Sample::Sample(const Sample &smp) @@ -92,6 +97,74 @@ bool Sample::operator==(const Sample &smp) const return true; } +/** + * Linear point estimation + * @param ya Y of point a + * @param yb Y of point b + * @param xt X of test point + * @param xa X of point a + * @param xb X of point b + * @return estimated Y of test point + */ +inline float linearEstimate(float ya, float yb, float xt, int xa = 0, int xb = 1) +{ + if(xa == xb) + return ya; + + return (yb-ya) * (xt-xa)/(xb-xa) + ya; +} + +void Sample::resize(unsigned int nsize) +{ + if(bufferSize == nsize) + return; + else {//resampling occurs here + float ratio = (nsize * 1.0) / (bufferSize * 1.0); + + int nBufferSize = nsize; + float *nBuffer = new float[nBufferSize]; + + //take care of edge cases + *nBuffer = *buffer; + *(nBuffer+nBufferSize-1) = *(buffer+bufferSize-1); + + //addition is done to avoid 0 edge case + for(int i = 1; i < nBufferSize - 1; ++i) + { + float left = floor(i/ratio); + float right = ceil((i+1)/ratio); + float test = i/ratio; + if(left > bufferSize - 1) + left = bufferSize - 1; + if(right > bufferSize - 1) + right = bufferSize - 1; + if(left > test) + test = left; + nBuffer[i] = linearEstimate(buffer[(int)left], + buffer[(int)right], + test, (int)left, (int)right); + } + + //put the new data in + delete[] buffer; + buffer = nBuffer; + bufferSize = nBufferSize; + } +} + +void Sample::append(const Sample &smp) +{ + int nbufferSize = bufferSize + smp.bufferSize; + float *nbuffer = new float[nbufferSize]; + + memcpy(nbuffer, buffer, bufferSize * sizeof(float)); + memcpy(nbuffer + bufferSize, smp.buffer, smp.bufferSize * sizeof(float)); + delete buffer; + + buffer = nbuffer; + bufferSize = nbufferSize; +} + REALTYPE Sample::max() const { REALTYPE max = -1500; //a good low considering that samples should store values -1.0 to 1.0 diff --git a/plugins/zynaddsubfx/src/Samples/Sample.h b/plugins/zynaddsubfx/src/Samples/Sample.h index ebdae66e5..5aa7c6860 100644 --- a/plugins/zynaddsubfx/src/Samples/Sample.h +++ b/plugins/zynaddsubfx/src/Samples/Sample.h @@ -50,13 +50,19 @@ class Sample void operator=(const Sample &smp); /**Provides the == operator*/ bool operator==(const Sample &smp) const; + /**Provides direct access to the buffer to allow for transition * * This method is like c_str() from the string class and should be used * sparingly*/ - const REALTYPE *c_buf() { - return buffer; - } + const REALTYPE *c_buf() const {return buffer;} + + /**Change the size of the sample*/ + void resize(unsigned int nsize); + + /**Appends another Sample to this Sample*/ + void append(const Sample &smp); + REALTYPE max() const; REALTYPE min() const; REALTYPE absMax() const; diff --git a/plugins/zynaddsubfx/src/Seq/MIDIEvents.cpp b/plugins/zynaddsubfx/src/Seq/MIDIEvents.cpp index 3bbab6c48..22d9a0565 100644 --- a/plugins/zynaddsubfx/src/Seq/MIDIEvents.cpp +++ b/plugins/zynaddsubfx/src/Seq/MIDIEvents.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - MIDIEvents.C - It stores the midi events from midi file or sequencer + MIDIEvents.cpp - It stores the midi events from midi file or sequencer Copyright (C) 2003-2005 Nasca Octavian Paul Author: Nasca Octavian Paul diff --git a/plugins/zynaddsubfx/src/Seq/MIDIFile.cpp b/plugins/zynaddsubfx/src/Seq/MIDIFile.cpp index f9dc64444..b732f49f7 100644 --- a/plugins/zynaddsubfx/src/Seq/MIDIFile.cpp +++ b/plugins/zynaddsubfx/src/Seq/MIDIFile.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - MIDIFile.C - MIDI file loader + MIDIFile.cpp - MIDI file loader Copyright (C) 2003-2005 Nasca Octavian Paul Author: Nasca Octavian Paul @@ -101,7 +101,7 @@ int MIDIFile::parsemidifile(MIDIEvents *me_) } else //SMPTE (frames/second and ticks/frame) printf( - "ERROR:in MIDIFile.C::parsemidifile() - SMPTE not implemented yet."); + "ERROR:in MIDIFile.cpp::parsemidifile() - SMPTE not implemented yet."); ; if(ntracks >= NUM_MIDI_TRACKS) @@ -115,7 +115,7 @@ int MIDIFile::parsemidifile(MIDIEvents *me_) } printf("\n\nCURRENT File position is = 0x%x\n", midifilek); - printf("\nMIDI file successfully parsed.\n"); + printf("\nMIDI file succesfully parsed.\n"); // printf("\n0x%x\n",getbyte()); this->me = NULL; diff --git a/plugins/zynaddsubfx/src/Seq/Sequencer.cpp b/plugins/zynaddsubfx/src/Seq/Sequencer.cpp index cedc9249e..6dfde4679 100644 --- a/plugins/zynaddsubfx/src/Seq/Sequencer.cpp +++ b/plugins/zynaddsubfx/src/Seq/Sequencer.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - Sequencer.C - The Sequencer + Sequencer.cpp - The Sequencer Copyright (C) 2003-2005 Nasca Octavian Paul Author: Nasca Octavian Paul diff --git a/plugins/zynaddsubfx/src/Synth/ADnote.cpp b/plugins/zynaddsubfx/src/Synth/ADnote.cpp index a70f3feef..c259fb4f4 100644 --- a/plugins/zynaddsubfx/src/Synth/ADnote.cpp +++ b/plugins/zynaddsubfx/src/Synth/ADnote.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - ADnote.C - The "additive" synthesizer + ADnote.cpp - The "additive" synthesizer Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul @@ -408,8 +408,7 @@ ADnote::ADnote(ADnoteParameters *pars, tmpwave_unison = new REALTYPE *[max_unison]; for(int k = 0; k < max_unison; k++) { tmpwave_unison[k] = new REALTYPE[SOUND_BUFFER_SIZE]; - for(int i = 0; i < SOUND_BUFFER_SIZE; i++) - tmpwave_unison[k][i] = 0.0; + memset(tmpwave_unison[k], 0, SOUND_BUFFER_SIZE * sizeof(REALTYPE)); } initparameters(); @@ -775,7 +774,7 @@ void ADnote::KillVoice(int nvoice) if(NoteVoicePar[nvoice].VoiceOut != NULL) memset(NoteVoicePar[nvoice].VoiceOut, 0, SOUND_BUFFER_SIZE - * sizeof(REALTYPE)); //do not delete, yet: perhaps is used by another voice + * sizeof(REALTYPE));//do not delete, yet: perhaps is used by another voice NoteVoicePar[nvoice].Enabled = OFF; } @@ -1010,8 +1009,7 @@ void ADnote::initparameters() } ; if(NoteVoicePar[nvoice].VoiceOut != NULL) - for(i = 0; i < SOUND_BUFFER_SIZE; i++) - NoteVoicePar[nvoice].VoiceOut[i] = 0.0; + memset(NoteVoicePar[nvoice].VoiceOut, 0, SOUND_BUFFER_SIZE * sizeof(REALTYPE)); } } @@ -1469,8 +1467,8 @@ inline void ADnote::ComputeVoiceOscillatorFrequencyModulation(int nvoice, //if I use VoiceOut[] as modulator for(int k = 0; k < unison_size[nvoice]; k++) { REALTYPE *tw = tmpwave_unison[k]; - for(i = 0; i < SOUND_BUFFER_SIZE; i++) - tw[i] = NoteVoicePar[NoteVoicePar[nvoice].FMVoice].VoiceOut[i]; + memcpy(tw, NoteVoicePar[NoteVoicePar[nvoice].FMVoice].VoiceOut, + SOUND_BUFFER_SIZE * sizeof(REALTYPE)); } } else { @@ -1654,11 +1652,9 @@ int ADnote::noteout(REALTYPE *outl, REALTYPE *outr) //mix subvoices into voice - for(i = 0; i < SOUND_BUFFER_SIZE; i++) - tmpwavel[i] = 0.0; + memset(tmpwavel, 0, SOUND_BUFFER_SIZE * sizeof(REALTYPE)); if(stereo) - for(i = 0; i < SOUND_BUFFER_SIZE; i++) - tmpwaver[i] = 0.0; + memset(tmpwaver, 0, SOUND_BUFFER_SIZE * sizeof(REALTYPE)); for(int k = 0; k < unison_size[nvoice]; k++) { REALTYPE *tw = tmpwave_unison[k]; if(stereo) { @@ -1825,11 +1821,10 @@ int ADnote::noteout(REALTYPE *outl, REALTYPE *outr) //Processing Global parameters NoteGlobalPar.GlobalFilterL->filterout(&outl[0]); - if(stereo == 0) - for(i = 0; i < SOUND_BUFFER_SIZE; i++) { //set the right channel=left channel - outr[i] = outl[i]; - bypassr[i] = bypassl[i]; - } + if(stereo == 0) { //set the right channel=left channel + memcpy(outr, outl, SOUND_BUFFER_SIZE * sizeof(REALTYPE)); + memcpy(bypassr, bypassl, SOUND_BUFFER_SIZE * sizeof(REALTYPE)); + } else NoteGlobalPar.GlobalFilterR->filterout(&outr[0]); @@ -1876,7 +1871,7 @@ int ADnote::noteout(REALTYPE *outl, REALTYPE *outr) if(Legato.silent) // Silencer if(Legato.msg != LM_FadeIn) { memset(outl, 0, SOUND_BUFFER_SIZE * sizeof(REALTYPE)); - memset(outl, 0, SOUND_BUFFER_SIZE * sizeof(REALTYPE)); + memset(outr, 0, SOUND_BUFFER_SIZE * sizeof(REALTYPE)); } switch(Legato.msg) { case LM_CatchUp: // Continue the catch-up... diff --git a/plugins/zynaddsubfx/src/Synth/ADnote.cxx b/plugins/zynaddsubfx/src/Synth/ADnote.cxx deleted file mode 100644 index 66c7f4d66..000000000 --- a/plugins/zynaddsubfx/src/Synth/ADnote.cxx +++ /dev/null @@ -1,136 +0,0 @@ -#include -#include -#include -#include "../Misc/Master.h" -#include "../Misc/Util.h" -#include "../Synth/ADnote.h" -#include "../Params/Presets.h" -#include "../globals.h" - -class AdNoteTest : public CxxTest::TestSuite -{ -public: - - ADnote *note; - Master *master; - Controller *controller; - unsigned char testnote; - - - float *outR,*outL; - - void setUp() { - - //First the sensible settings and variables that have to be set: - SOUND_BUFFER_SIZE = 256; - - outL=new float[SOUND_BUFFER_SIZE]; - for (int i=0;iloadXMLfile("src/Tests/guitar-adnote.xmz"); - TS_ASSERT(wrap->enterbranch("MASTER")); - TS_ASSERT(wrap->enterbranch("PART", 0)); - TS_ASSERT(wrap->enterbranch("INSTRUMENT")); - TS_ASSERT(wrap->enterbranch("INSTRUMENT_KIT")); - TS_ASSERT(wrap->enterbranch("INSTRUMENT_KIT_ITEM", 0)); - TS_ASSERT(wrap->enterbranch("ADD_SYNTH_PARAMETERS")); - defaultPreset->getfromXML(wrap); - //defaultPreset->defaults(); - - - - controller = new Controller(); - - //lets go with.... 50! as a nice note - testnote = 50; - REALTYPE freq = 440.0*pow(2.0,(testnote-69.0)/12.0); - - note = new ADnote(defaultPreset, controller, freq, 120, 0, testnote, false); - - } - - void willNoteBeRunButIsHereForLinkingReasonsHowsThisForCamelCaseEh() - { - master = new Master(); - } - - void tearDown() { - delete note; - deleteFFTFREQS(&OscilGen::outoscilFFTfreqs); - } - - void testDefaults() { - - TS_ASSERT(note->ready); - int sampleCount = 0; - -//#define WRITE_OUTPUT - -#ifdef WRITE_OUTPUT - ofstream file("adnoteout", ios::out); -#endif - note->noteout(outL, outR); -#ifdef WRITE_OUTPUT - for (int i = 0; i < SOUND_BUFFER_SIZE; ++i) { - file << outL[i] << std::endl; - } -#endif - sampleCount += SOUND_BUFFER_SIZE; - - TS_ASSERT_DELTA(outL[255], 0.1724, 0.0001); - - note->relasekey(); - - - note->noteout(outL, outR); - sampleCount += SOUND_BUFFER_SIZE; - TS_ASSERT_DELTA(outL[255], -0.1284, 0.0001); - - note->noteout(outL, outR); - sampleCount += SOUND_BUFFER_SIZE; - TS_ASSERT_DELTA(outL[255], -0.0206, 0.0001); - - note->noteout(outL, outR); - sampleCount += SOUND_BUFFER_SIZE; - TS_ASSERT_DELTA(outL[255], -0.1122, 0.0001); - - note->noteout(outL, outR); - sampleCount += SOUND_BUFFER_SIZE; - TS_ASSERT_DELTA(outL[255], 0.1707, 0.0001); - - while (!note->finished()) { - note->noteout(outL, outR); -#ifdef WRITE_OUTPUT - for (int i = 0; i < SOUND_BUFFER_SIZE; ++i) { - file << outL[i] << std::endl; - } -#endif - sampleCount += SOUND_BUFFER_SIZE; - } -#ifdef WRITE_OUTPUT - file.close(); -#endif - - TS_ASSERT_EQUALS(sampleCount, 9472); - - } -}; - diff --git a/plugins/zynaddsubfx/src/Synth/CMakeLists.txt b/plugins/zynaddsubfx/src/Synth/CMakeLists.txt index 19fa17aad..486554b9f 100644 --- a/plugins/zynaddsubfx/src/Synth/CMakeLists.txt +++ b/plugins/zynaddsubfx/src/Synth/CMakeLists.txt @@ -14,5 +14,3 @@ add_library(zynaddsubfx_synth STATIC target_link_libraries(zynaddsubfx_synth) -unit_test(adnote_test ADnote.cxx "") - diff --git a/plugins/zynaddsubfx/src/Synth/Envelope.cpp b/plugins/zynaddsubfx/src/Synth/Envelope.cpp index ce8456481..a8f2ac662 100644 --- a/plugins/zynaddsubfx/src/Synth/Envelope.cpp +++ b/plugins/zynaddsubfx/src/Synth/Envelope.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - Envelope.C - Envelope implementation + Envelope.cpp - Envelope implementation Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul diff --git a/plugins/zynaddsubfx/src/Synth/LFO.cpp b/plugins/zynaddsubfx/src/Synth/LFO.cpp index 7b665852f..6dcf47f9f 100644 --- a/plugins/zynaddsubfx/src/Synth/LFO.cpp +++ b/plugins/zynaddsubfx/src/Synth/LFO.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - LFO.C - LFO implementation + LFO.cpp - LFO implementation Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul @@ -38,7 +38,7 @@ LFO::LFO(LFOParams *lfopars, REALTYPE basefreq) (pow(2, lfopars->Pfreq * 10.0) - 1.0) / 12.0 * lfostretch; incx = fabs(lfofreq) * (REALTYPE)SOUND_BUFFER_SIZE / (REALTYPE)SAMPLE_RATE; - if(lfopars->Pcontinuous == 0) { + if(lfopars->Pcontinous == 0) { if(lfopars->Pstartphase == 0) x = RND; else diff --git a/plugins/zynaddsubfx/src/Synth/OscilGen.cpp b/plugins/zynaddsubfx/src/Synth/OscilGen.cpp index bbd62f3bb..97eb74659 100644 --- a/plugins/zynaddsubfx/src/Synth/OscilGen.cpp +++ b/plugins/zynaddsubfx/src/Synth/OscilGen.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - OscilGen.C - Waveform generator for ADnote + OscilGen.cpp - Waveform generator for ADnote Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul diff --git a/plugins/zynaddsubfx/src/Synth/PADnote.cpp b/plugins/zynaddsubfx/src/Synth/PADnote.cpp index 4c25ad904..699085f8c 100644 --- a/plugins/zynaddsubfx/src/Synth/PADnote.cpp +++ b/plugins/zynaddsubfx/src/Synth/PADnote.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - PADnote.C - The "pad" synthesizer + PADnote.cpp - The "pad" synthesizer Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul diff --git a/plugins/zynaddsubfx/src/Synth/Resonance.cpp b/plugins/zynaddsubfx/src/Synth/Resonance.cpp index 4e12572a3..2bf8c633c 100644 --- a/plugins/zynaddsubfx/src/Synth/Resonance.cpp +++ b/plugins/zynaddsubfx/src/Synth/Resonance.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - Resonance.C - Resonance + Resonance.cpp - Resonance Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul diff --git a/plugins/zynaddsubfx/src/Synth/SUBnote.cpp b/plugins/zynaddsubfx/src/Synth/SUBnote.cpp index 0a3affba5..0ef075701 100644 --- a/plugins/zynaddsubfx/src/Synth/SUBnote.cpp +++ b/plugins/zynaddsubfx/src/Synth/SUBnote.cpp @@ -1,7 +1,7 @@ /* ZynAddSubFX - a software synthesizer - SUBnote.C - The "subtractive" synthesizer + SUBnote.cpp - The "subtractive" synthesizer Copyright (C) 2002-2005 Nasca Octavian Paul Author: Nasca Octavian Paul diff --git a/plugins/zynaddsubfx/src/UI/ADnoteUI.cc b/plugins/zynaddsubfx/src/UI/ADnoteUI.cc index 854a88f1b..9d3ca6caf 100644 --- a/plugins/zynaddsubfx/src/UI/ADnoteUI.cc +++ b/plugins/zynaddsubfx/src/UI/ADnoteUI.cc @@ -1050,7 +1050,7 @@ Fl_Group* ADvoiceUI::make_window() { o->value(pars->VoicePar[nvoice].Pfixedfreq); } // Fl_Check_Button* o { WidgetPDial* o = fixedfreqetdial = new WidgetPDial(405, 255, 15, 15, "Eq.T."); - fixedfreqetdial->tooltip("How the frequency varies according to the keyboard (leftmost for fixed frequen\ + fixedfreqetdial->tooltip("How the frequency varies acording to the keyboard (leftmost for fixed frequen\ cy)"); fixedfreqetdial->box(FL_ROUND_UP_BOX); fixedfreqetdial->color(FL_BACKGROUND_COLOR); diff --git a/plugins/zynaddsubfx/src/UI/ADnoteUI.fl b/plugins/zynaddsubfx/src/UI/ADnoteUI.fl index dc5e6adc6..748156c74 100644 --- a/plugins/zynaddsubfx/src/UI/ADnoteUI.fl +++ b/plugins/zynaddsubfx/src/UI/ADnoteUI.fl @@ -481,7 +481,7 @@ if (x==0) fixedfreqetdial->deactivate(); Fl_Dial fixedfreqetdial { label {Eq.T.} callback {pars->VoicePar[nvoice].PfixedfreqET=(int) o->value();} - tooltip {How the frequency varies according to the keyboard (leftmost for fixed frequency)} xywh {405 255 15 15} box ROUND_UP_BOX labelsize 10 align 8 maximum 127 step 1 + tooltip {How the frequency varies acording to the keyboard (leftmost for fixed frequency)} xywh {405 255 15 15} box ROUND_UP_BOX labelsize 10 align 8 maximum 127 step 1 code0 {o->value(pars->VoicePar[nvoice].PfixedfreqET);} code1 {if (pars->VoicePar[nvoice].Pfixedfreq==0) o->deactivate();} class WidgetPDial diff --git a/plugins/zynaddsubfx/src/UI/CMakeLists.txt b/plugins/zynaddsubfx/src/UI/CMakeLists.txt new file mode 100644 index 000000000..49336b2dc --- /dev/null +++ b/plugins/zynaddsubfx/src/UI/CMakeLists.txt @@ -0,0 +1,32 @@ +set(UI_fl_files + ADnoteUI.fl + BankUI.fl + ConfigUI.fl + EffUI.fl + EnvelopeUI.fl + FilterUI.fl + LFOUI.fl + MasterUI.fl + MicrotonalUI.fl + OscilGenUI.fl + PADnoteUI.fl + PartUI.fl + PresetsUI.fl + ResonanceUI.fl + SeqUI.fl + SUBnoteUI.fl + VirKeyboard.fl + WidgetPDial.fl +) + +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +set_source_files_properties(UI/MasterUI.h PROPERTIES GENERATED 1) +fltk_wrap_ui(zynaddsubfx_gui ${UI_fl_files}) + +add_library(zynaddsubfx_gui STATIC + ${UI_objs} + ${zynaddsubfx_gui_FLTK_UI_SRCS} + ) + +target_link_libraries(zynaddsubfx_gui ${FLTK_LIBRARIES} ${MYFLTK_LIBRARIES}) diff --git a/plugins/zynaddsubfx/src/UI/EffUI.cc b/plugins/zynaddsubfx/src/UI/EffUI.cc index 7c21f0000..cf7a3be53 100644 --- a/plugins/zynaddsubfx/src/UI/EffUI.cc +++ b/plugins/zynaddsubfx/src/UI/EffUI.cc @@ -437,6 +437,12 @@ Fl_Menu_Item EffUI::menu_phaserp[] = { {"Phaser 4", 0, 0, 0, 0, FL_NORMAL_LABEL, 1, 10, 7}, {"Phaser 5", 0, 0, 0, 0, FL_NORMAL_LABEL, 1, 10, 7}, {"Phaser 6", 0, 0, 0, 0, FL_NORMAL_LABEL, 1, 10, 7}, + {"APhaser 1", 0, 0, 0, 0, FL_NORMAL_LABEL, 1, 10, 7}, + {"APhaser 2", 0, 0, 0, 0, FL_NORMAL_LABEL, 1, 10, 7}, + {"APhaser 3", 0, 0, 0, 0, FL_NORMAL_LABEL, 1, 10, 7}, + {"APhaser 4", 0, 0, 0, 0, FL_NORMAL_LABEL, 1, 10, 7}, + {"APhaser 5", 0, 0, 0, 0, FL_NORMAL_LABEL, 1, 10, 7}, + {"APhaser 6", 0, 0, 0, 0, FL_NORMAL_LABEL, 1, 10, 7}, {0,0,0,0,0,0,0,0,0} }; @@ -468,6 +474,19 @@ void EffUI::cb_phaserp3(WidgetPDial* o, void* v) { ((EffUI*)(o->parent()->user_data()))->cb_phaserp3_i(o,v); } +void EffUI::cb_phaserp4_i(Fl_Choice* o, void*) { + eff->seteffectpar(4,(int) o->value()); +} +void EffUI::cb_phaserp4(Fl_Choice* o, void* v) { + ((EffUI*)(o->parent()->user_data()))->cb_phaserp4_i(o,v); +} + +Fl_Menu_Item EffUI::menu_phaserp4[] = { + {"SIN", 0, 0, 0, 0, FL_NORMAL_LABEL, 1, 10, 0}, + {"TRI", 0, 0, 0, 0, FL_NORMAL_LABEL, 1, 10, 0}, + {0,0,0,0,0,0,0,0,0} +}; + void EffUI::cb_phaserp5_i(WidgetPDial* o, void*) { eff->seteffectpar(5,(int) o->value()); } @@ -489,6 +508,13 @@ void EffUI::cb_phaserp7(WidgetPDial* o, void* v) { ((EffUI*)(o->parent()->user_data()))->cb_phaserp7_i(o,v); } +void EffUI::cb_phaserp8_i(Fl_Counter* o, void*) { + eff->seteffectpar(8,(int) o->value()); +} +void EffUI::cb_phaserp8(Fl_Counter* o, void* v) { + ((EffUI*)(o->parent()->user_data()))->cb_phaserp8_i(o,v); +} + void EffUI::cb_phaserp9_i(WidgetPDial* o, void*) { eff->seteffectpar(9,(int) o->value()); } @@ -503,26 +529,6 @@ void EffUI::cb_phaserp10(Fl_Check_Button* o, void* v) { ((EffUI*)(o->parent()->user_data()))->cb_phaserp10_i(o,v); } -void EffUI::cb_phaserp4_i(Fl_Choice* o, void*) { - eff->seteffectpar(4,(int) o->value()); -} -void EffUI::cb_phaserp4(Fl_Choice* o, void* v) { - ((EffUI*)(o->parent()->user_data()))->cb_phaserp4_i(o,v); -} - -Fl_Menu_Item EffUI::menu_phaserp4[] = { - {"SINE", 0, 0, 0, 0, FL_NORMAL_LABEL, 1, 10, 0}, - {"TRI", 0, 0, 0, 0, FL_NORMAL_LABEL, 1, 10, 0}, - {0,0,0,0,0,0,0,0,0} -}; - -void EffUI::cb_phaserp8_i(Fl_Counter* o, void*) { - eff->seteffectpar(8,(int) o->value()); -} -void EffUI::cb_phaserp8(Fl_Counter* o, void* v) { - ((EffUI*)(o->parent()->user_data()))->cb_phaserp8_i(o,v); -} - void EffUI::cb_phaserp11_i(WidgetPDial* o, void*) { eff->seteffectpar(11,(int) o->value()); } @@ -530,6 +536,27 @@ void EffUI::cb_phaserp11(WidgetPDial* o, void* v) { ((EffUI*)(o->parent()->user_data()))->cb_phaserp11_i(o,v); } +void EffUI::cb_phaserp12_i(Fl_Check_Button* o, void*) { + eff->seteffectpar(12,(int) o->value()); +} +void EffUI::cb_phaserp12(Fl_Check_Button* o, void* v) { + ((EffUI*)(o->parent()->user_data()))->cb_phaserp12_i(o,v); +} + +void EffUI::cb_phaserp13_i(WidgetPDial* o, void*) { + eff->seteffectpar(13,(int) o->value()); +} +void EffUI::cb_phaserp13(WidgetPDial* o, void* v) { + ((EffUI*)(o->parent()->user_data()))->cb_phaserp13_i(o,v); +} + +void EffUI::cb_phaserp14_i(Fl_Check_Button* o, void*) { + eff->seteffectpar(14,(int) o->value()); +} +void EffUI::cb_phaserp14(Fl_Check_Button* o, void* v) { + ((EffUI*)(o->parent()->user_data()))->cb_phaserp14_i(o,v); +} + void EffUI::cb_awp_i(Fl_Choice* o, void*) { eff->changepreset((int)o->value()); refresh(eff); @@ -1535,7 +1562,7 @@ Fl_Group* EffUI::make_phaser_window() { effphaserwindow->user_data((void*)(this)); effphaserwindow->align(Fl_Align(FL_ALIGN_TOP)); effphaserwindow->when(FL_WHEN_RELEASE); - { phaserp = new Fl_Choice(10, 15, 90, 15, "Preset"); + { phaserp = new Fl_Choice(10, 15, 100, 15, "Preset"); phaserp->down_box(FL_BORDER_BOX); phaserp->color((Fl_Color)14); phaserp->selection_color(FL_FOREGROUND_COLOR); @@ -1582,7 +1609,7 @@ Fl_Group* EffUI::make_phaser_window() { phaserp1->align(Fl_Align(FL_ALIGN_BOTTOM)); phaserp1->when(FL_WHEN_CHANGED); } // WidgetPDial* phaserp1 - { phaserp2 = new WidgetPDial(85, 40, 30, 30, "Freq"); + { phaserp2 = new WidgetPDial(85, 45, 25, 25, "Freq"); phaserp2->tooltip("LFO frequency"); phaserp2->box(FL_ROUND_UP_BOX); phaserp2->color(FL_BACKGROUND_COLOR); @@ -1596,7 +1623,7 @@ Fl_Group* EffUI::make_phaser_window() { phaserp2->align(Fl_Align(FL_ALIGN_BOTTOM)); phaserp2->when(FL_WHEN_CHANGED); } // WidgetPDial* phaserp2 - { phaserp3 = new WidgetPDial(120, 40, 30, 30, "Rnd"); + { phaserp3 = new WidgetPDial(120, 45, 25, 25, "Rnd"); phaserp3->tooltip("LFO randomness"); phaserp3->box(FL_ROUND_UP_BOX); phaserp3->color(FL_BACKGROUND_COLOR); @@ -1610,7 +1637,17 @@ Fl_Group* EffUI::make_phaser_window() { phaserp3->align(Fl_Align(FL_ALIGN_BOTTOM)); phaserp3->when(FL_WHEN_RELEASE); } // WidgetPDial* phaserp3 - { phaserp5 = new WidgetPDial(200, 40, 30, 30, "St.df"); + { phaserp4 = new Fl_Choice(245, 55, 40, 15, "LFO"); + phaserp4->tooltip("LFO function"); + phaserp4->down_box(FL_BORDER_BOX); + phaserp4->labelfont(1); + phaserp4->labelsize(10); + phaserp4->textsize(8); + phaserp4->callback((Fl_Callback*)cb_phaserp4); + phaserp4->align(Fl_Align(130)); + phaserp4->menu(menu_phaserp4); + } // Fl_Choice* phaserp4 + { phaserp5 = new WidgetPDial(155, 45, 25, 25, "St.df"); phaserp5->tooltip("Left/Right Channel Phase Shift"); phaserp5->box(FL_ROUND_UP_BOX); phaserp5->color(FL_BACKGROUND_COLOR); @@ -1624,21 +1661,21 @@ Fl_Group* EffUI::make_phaser_window() { phaserp5->align(Fl_Align(FL_ALIGN_BOTTOM)); phaserp5->when(FL_WHEN_CHANGED); } // WidgetPDial* phaserp5 - { phaserp6 = new WidgetPDial(235, 40, 30, 30, "Dpth"); + { phaserp6 = new WidgetPDial(120, 5, 25, 25, "Dpth"); phaserp6->tooltip("LFO Depth"); phaserp6->box(FL_ROUND_UP_BOX); phaserp6->color(FL_BACKGROUND_COLOR); phaserp6->selection_color(FL_INACTIVE_COLOR); phaserp6->labeltype(FL_NORMAL_LABEL); phaserp6->labelfont(1); - phaserp6->labelsize(11); + phaserp6->labelsize(10); phaserp6->labelcolor(FL_FOREGROUND_COLOR); phaserp6->maximum(127); phaserp6->callback((Fl_Callback*)cb_phaserp6); phaserp6->align(Fl_Align(FL_ALIGN_BOTTOM)); phaserp6->when(FL_WHEN_CHANGED); } // WidgetPDial* phaserp6 - { phaserp7 = new WidgetPDial(270, 40, 30, 30, "Fb"); + { phaserp7 = new WidgetPDial(185, 45, 25, 25, "Fb"); phaserp7->tooltip("Feedback"); phaserp7->box(FL_ROUND_UP_BOX); phaserp7->color(FL_BACKGROUND_COLOR); @@ -1652,7 +1689,17 @@ Fl_Group* EffUI::make_phaser_window() { phaserp7->align(Fl_Align(FL_ALIGN_BOTTOM)); phaserp7->when(FL_WHEN_CHANGED); } // WidgetPDial* phaserp7 - { phaserp9 = new WidgetPDial(345, 40, 30, 30, "L/R"); + { Fl_Counter* o = phaserp8 = new Fl_Counter(290, 55, 35, 15, "Stages"); + phaserp8->type(1); + phaserp8->labelfont(1); + phaserp8->labelsize(11); + phaserp8->minimum(0); + phaserp8->maximum(127); + phaserp8->step(1); + phaserp8->callback((Fl_Callback*)cb_phaserp8); + o->range(1,MAX_PHASER_STAGES); + } // Fl_Counter* phaserp8 + { phaserp9 = new WidgetPDial(215, 45, 25, 25, "L/R"); phaserp9->tooltip("Channel Routing"); phaserp9->box(FL_ROUND_UP_BOX); phaserp9->color(FL_BACKGROUND_COLOR); @@ -1666,7 +1713,7 @@ Fl_Group* EffUI::make_phaser_window() { phaserp9->align(Fl_Align(FL_ALIGN_BOTTOM)); phaserp9->when(FL_WHEN_CHANGED); } // WidgetPDial* phaserp9 - { phaserp10 = new Fl_Check_Button(185, 10, 74, 20, "Substract"); + { phaserp10 = new Fl_Check_Button(200, 10, 74, 20, "Substract"); phaserp10->tooltip("inverts output"); phaserp10->box(FL_THIN_UP_BOX); phaserp10->down_box(FL_DOWN_BOX); @@ -1675,27 +1722,7 @@ Fl_Group* EffUI::make_phaser_window() { phaserp10->labelsize(10); phaserp10->callback((Fl_Callback*)cb_phaserp10); } // Fl_Check_Button* phaserp10 - { phaserp4 = new Fl_Choice(155, 50, 40, 15, "LFO type"); - phaserp4->tooltip("LFO function"); - phaserp4->down_box(FL_BORDER_BOX); - phaserp4->labelfont(1); - phaserp4->labelsize(10); - phaserp4->textsize(8); - phaserp4->callback((Fl_Callback*)cb_phaserp4); - phaserp4->align(Fl_Align(130)); - phaserp4->menu(menu_phaserp4); - } // Fl_Choice* phaserp4 - { Fl_Counter* o = phaserp8 = new Fl_Counter(305, 55, 35, 15, "Stages"); - phaserp8->type(1); - phaserp8->labelfont(1); - phaserp8->labelsize(11); - phaserp8->minimum(0); - phaserp8->maximum(127); - phaserp8->step(1); - phaserp8->callback((Fl_Callback*)cb_phaserp8); - o->range(1,MAX_PHASER_STAGES); - } // Fl_Counter* phaserp8 - { phaserp11 = new WidgetPDial(155, 10, 25, 25, "Phase"); + { phaserp11 = new WidgetPDial(155, 5, 25, 25, "Phase"); phaserp11->box(FL_ROUND_UP_BOX); phaserp11->color(FL_BACKGROUND_COLOR); phaserp11->selection_color(FL_INACTIVE_COLOR); @@ -1708,6 +1735,29 @@ Fl_Group* EffUI::make_phaser_window() { phaserp11->align(Fl_Align(FL_ALIGN_BOTTOM)); phaserp11->when(FL_WHEN_CHANGED); } // WidgetPDial* phaserp11 + { phaserp12 = new Fl_Check_Button(245, 35, 55, 15, "hyp."); + phaserp12->tooltip("hyper"); + phaserp12->down_box(FL_DOWN_BOX); + phaserp12->callback((Fl_Callback*)cb_phaserp12); + } // Fl_Check_Button* phaserp12 + { phaserp13 = new WidgetPDial(340, 50, 25, 25, "dist"); + phaserp13->tooltip("Distortion"); + phaserp13->box(FL_ROUND_UP_BOX); + phaserp13->color(FL_BACKGROUND_COLOR); + phaserp13->selection_color(FL_INACTIVE_COLOR); + phaserp13->labeltype(FL_NORMAL_LABEL); + phaserp13->labelfont(1); + phaserp13->labelsize(11); + phaserp13->labelcolor(FL_FOREGROUND_COLOR); + phaserp13->maximum(127); + phaserp13->callback((Fl_Callback*)cb_phaserp13); + phaserp13->align(Fl_Align(FL_ALIGN_BOTTOM)); + phaserp13->when(FL_WHEN_CHANGED); + } // WidgetPDial* phaserp13 + { phaserp14 = new Fl_Check_Button(305, 35, 70, 15, "Analog"); + phaserp14->down_box(FL_DOWN_BOX); + phaserp14->callback((Fl_Callback*)cb_phaserp14); + } // Fl_Check_Button* phaserp14 effphaserwindow->end(); } // Fl_Group* effphaserwindow return effphaserwindow; @@ -2504,6 +2554,9 @@ switch(eff->geteffect()){ phaserp9->value(eff->geteffectpar(9)); phaserp10->value(eff->geteffectpar(10)); phaserp11->value(eff->geteffectpar(11)); + phaserp12->value(eff->geteffectpar(12)); + phaserp13->value(eff->geteffectpar(13)); + phaserp14->value(eff->geteffectpar(14)); effphaserwindow->show(); break; case 5: diff --git a/plugins/zynaddsubfx/src/UI/EffUI.fl b/plugins/zynaddsubfx/src/UI/EffUI.fl index a5830506f..69ebac180 100644 --- a/plugins/zynaddsubfx/src/UI/EffUI.fl +++ b/plugins/zynaddsubfx/src/UI/EffUI.fl @@ -1,5 +1,5 @@ # data file for the Fltk User Interface Designer (fluid) -version 1.0109 +version 1.0107 header_name {.h} code_name {.cc} decl {//Copyright (c) 2002-2005 Nasca Octavian Paul} {} @@ -155,7 +155,7 @@ return(log(freq/20.0)/log(1000.0));} {} decl {int maxdB;} {} } -class EffUI {open : {public Fl_Group,public PresetsUI_} +class EffUI {: {public Fl_Group,public PresetsUI_} } { Function {EffUI(int x,int y, int w, int h, const char *label=0):Fl_Group(x,y,w,h,label)} {} { code {eff=NULL; @@ -179,7 +179,7 @@ if (filterwindow!=NULL){ } Function {make_null_window()} {} { Fl_Window effnullwindow { - xywh {287 379 380 95} type Double box PLASTIC_UP_BOX color 221 labelfont 1 hide + xywh {216 539 380 95} type Double box PLASTIC_UP_BOX color 221 labelfont 1 hide class Fl_Group } { Fl_Text_Display {} { @@ -188,11 +188,10 @@ if (filterwindow!=NULL){ } } } - Function {make_reverb_window()} {open - } { - Fl_Window effreverbwindow {open - xywh {343 337 380 95} type Double box PLASTIC_UP_BOX color 221 labelfont 1 - class Fl_Group visible + Function {make_reverb_window()} {} { + Fl_Window effreverbwindow { + xywh {343 337 380 95} type Double box PLASTIC_UP_BOX color 221 labelfont 1 hide + class Fl_Group } { Fl_Text_Display {} { label {Reverb } @@ -344,7 +343,7 @@ if (eff->geteffectpar(10)==2) revp12->activate(); callback {int x=64; if (Fl::event_button1()) x=(int)o->value(); else o->value(x); -eff->seteffectpar(11,x);} selected +eff->seteffectpar(11,x);} tooltip RoomSize xywh {200 10 25 25} box ROUND_UP_BOX labelfont 1 labelsize 8 align 8 minimum 1 maximum 127 step 1 class WidgetPDial } @@ -585,14 +584,14 @@ refresh(eff);} } Function {make_phaser_window()} {} { Fl_Window effphaserwindow { - xywh {389 213 380 95} type Double box PLASTIC_UP_BOX color 221 labelfont 1 hide + xywh {75 25 380 95} type Double box PLASTIC_UP_BOX color 221 labelfont 1 hide class Fl_Group } { Fl_Choice phaserp { label Preset callback {eff->changepreset((int)o->value()); refresh(eff);} - xywh {10 15 90 15} down_box BORDER_BOX color 14 selection_color 0 labelfont 1 labelsize 10 align 5 textfont 1 textsize 10 textcolor 7 + xywh {10 15 100 15} down_box BORDER_BOX color 14 selection_color 0 labelfont 1 labelsize 10 align 5 textfont 1 textsize 10 textcolor 7 } { MenuItem {} { label {Phaser 1} @@ -618,6 +617,30 @@ refresh(eff);} label {Phaser 6} xywh {80 80 100 20} labelfont 1 labelsize 10 labelcolor 7 } + MenuItem {} { + label {APhaser 1} + xywh {40 40 100 20} labelfont 1 labelsize 10 labelcolor 7 + } + MenuItem {} { + label {APhaser 2} + xywh {50 50 100 20} labelfont 1 labelsize 10 labelcolor 7 + } + MenuItem {} { + label {APhaser 3} + xywh {60 60 100 20} labelfont 1 labelsize 10 labelcolor 7 + } + MenuItem {} { + label {APhaser 4} + xywh {70 70 100 20} labelfont 1 labelsize 10 labelcolor 7 + } + MenuItem {} { + label {APhaser 5} + xywh {80 80 100 20} labelfont 1 labelsize 10 labelcolor 7 + } + MenuItem {} { + label {APhaser 6} selected + xywh {90 90 100 20} labelfont 1 labelsize 10 labelcolor 7 + } } Fl_Text_Display {} { label Phaser @@ -638,51 +661,22 @@ refresh(eff);} Fl_Dial phaserp2 { label Freq callback {eff->seteffectpar(2,(int) o->value());} - tooltip {LFO frequency} xywh {85 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127 + tooltip {LFO frequency} xywh {85 45 25 25} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127 class WidgetPDial } Fl_Dial phaserp3 { label Rnd callback {eff->seteffectpar(3,(int) o->value());} - tooltip {LFO randomness} xywh {120 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 when 4 maximum 127 + tooltip {LFO randomness} xywh {120 45 25 25} box ROUND_UP_BOX labelfont 1 labelsize 11 when 4 maximum 127 class WidgetPDial } - Fl_Dial phaserp5 { - label {St.df} - callback {eff->seteffectpar(5,(int) o->value());} - tooltip {Left/Right Channel Phase Shift} xywh {200 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127 - class WidgetPDial - } - Fl_Dial phaserp6 { - label Dpth - callback {eff->seteffectpar(6,(int) o->value());} - tooltip {LFO Depth} xywh {235 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127 - class WidgetPDial - } - Fl_Dial phaserp7 { - label Fb - callback {eff->seteffectpar(7,(int) o->value());} - tooltip Feedback xywh {270 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127 - class WidgetPDial - } - Fl_Dial phaserp9 { - label {L/R} - callback {eff->seteffectpar(9,(int) o->value());} - tooltip {Channel Routing} xywh {345 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127 - class WidgetPDial - } - Fl_Check_Button phaserp10 { - label Substract - callback {eff->seteffectpar(10,(int) o->value());} - tooltip {inverts output} xywh {185 10 74 20} box THIN_UP_BOX down_box DOWN_BOX color 230 labelfont 1 labelsize 10 - } Fl_Choice phaserp4 { - label {LFO type} + label LFO callback {eff->seteffectpar(4,(int) o->value());} - tooltip {LFO function} xywh {155 50 40 15} down_box BORDER_BOX labelfont 1 labelsize 10 align 130 textsize 8 + tooltip {LFO function} xywh {245 55 40 15} down_box BORDER_BOX labelfont 1 labelsize 10 align 130 textsize 8 } { MenuItem {} { - label SINE + label SIN xywh {15 15 100 20} labelfont 1 labelsize 10 } MenuItem {} { @@ -690,18 +684,63 @@ refresh(eff);} xywh {25 25 100 20} labelfont 1 labelsize 10 } } + Fl_Dial phaserp5 { + label {St.df} + callback {eff->seteffectpar(5,(int) o->value());} + tooltip {Left/Right Channel Phase Shift} xywh {155 45 25 25} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127 + class WidgetPDial + } + Fl_Dial phaserp6 { + label Dpth + callback {eff->seteffectpar(6,(int) o->value());} + tooltip {LFO Depth} xywh {120 5 25 25} box ROUND_UP_BOX labelfont 1 labelsize 10 maximum 127 + class WidgetPDial + } + Fl_Dial phaserp7 { + label Fb + callback {eff->seteffectpar(7,(int) o->value());} + tooltip Feedback xywh {185 45 25 25} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127 + class WidgetPDial + } Fl_Counter phaserp8 { label Stages callback {eff->seteffectpar(8,(int) o->value());} - xywh {305 55 35 15} type Simple labelfont 1 labelsize 11 minimum 0 maximum 127 step 1 + xywh {290 55 35 15} type Simple labelfont 1 labelsize 11 minimum 0 maximum 127 step 1 code0 {o->range(1,MAX_PHASER_STAGES);} } + Fl_Dial phaserp9 { + label {L/R} + callback {eff->seteffectpar(9,(int) o->value());} + tooltip {Channel Routing} xywh {215 45 25 25} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127 + class WidgetPDial + } + Fl_Check_Button phaserp10 { + label Substract + callback {eff->seteffectpar(10,(int) o->value());} + tooltip {inverts output} xywh {200 10 74 20} box THIN_UP_BOX down_box DOWN_BOX color 230 labelfont 1 labelsize 10 + } Fl_Dial phaserp11 { label Phase callback {eff->seteffectpar(11,(int) o->value());} - xywh {155 10 25 25} box ROUND_UP_BOX labelfont 1 labelsize 10 maximum 127 + xywh {155 5 25 25} box ROUND_UP_BOX labelfont 1 labelsize 10 maximum 127 class WidgetPDial } + Fl_Check_Button phaserp12 { + label {hyp.} + callback {eff->seteffectpar(12,(int) o->value());} + tooltip hyper xywh {245 35 55 15} down_box DOWN_BOX + } + Fl_Dial phaserp13 { + label dist + callback {eff->seteffectpar(13,(int) o->value());} + tooltip Distortion xywh {340 50 25 25} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127 + class WidgetPDial + } + Fl_Check_Button phaserp14 { + label Analog + callback {eff->seteffectpar(14,(int) o->value());} + xywh {305 35 70 15} down_box DOWN_BOX + } } } Function {make_alienwah_window()} {} { @@ -1353,6 +1392,9 @@ switch(eff->geteffect()){ phaserp9->value(eff->geteffectpar(9)); phaserp10->value(eff->geteffectpar(10)); phaserp11->value(eff->geteffectpar(11)); + phaserp12->value(eff->geteffectpar(12)); + phaserp13->value(eff->geteffectpar(13)); + phaserp14->value(eff->geteffectpar(14)); effphaserwindow->show(); break; case 5: @@ -1422,7 +1464,8 @@ switch(eff->geteffect()){ this->show();} {} } - Function {refresh()} {} { + Function {refresh()} {open + } { code {refresh(eff);} {} } decl {EffectMgr *eff;} {} diff --git a/plugins/zynaddsubfx/src/UI/EffUI.h b/plugins/zynaddsubfx/src/UI/EffUI.h index 9f8721b51..be2f5f4a8 100644 --- a/plugins/zynaddsubfx/src/UI/EffUI.h +++ b/plugins/zynaddsubfx/src/UI/EffUI.h @@ -250,6 +250,12 @@ public: private: void cb_phaserp3_i(WidgetPDial*, void*); static void cb_phaserp3(WidgetPDial*, void*); +public: + Fl_Choice *phaserp4; +private: + void cb_phaserp4_i(Fl_Choice*, void*); + static void cb_phaserp4(Fl_Choice*, void*); + static Fl_Menu_Item menu_phaserp4[]; public: WidgetPDial *phaserp5; private: @@ -265,6 +271,11 @@ public: private: void cb_phaserp7_i(WidgetPDial*, void*); static void cb_phaserp7(WidgetPDial*, void*); +public: + Fl_Counter *phaserp8; +private: + void cb_phaserp8_i(Fl_Counter*, void*); + static void cb_phaserp8(Fl_Counter*, void*); public: WidgetPDial *phaserp9; private: @@ -275,22 +286,26 @@ public: private: void cb_phaserp10_i(Fl_Check_Button*, void*); static void cb_phaserp10(Fl_Check_Button*, void*); -public: - Fl_Choice *phaserp4; -private: - void cb_phaserp4_i(Fl_Choice*, void*); - static void cb_phaserp4(Fl_Choice*, void*); - static Fl_Menu_Item menu_phaserp4[]; -public: - Fl_Counter *phaserp8; -private: - void cb_phaserp8_i(Fl_Counter*, void*); - static void cb_phaserp8(Fl_Counter*, void*); public: WidgetPDial *phaserp11; private: void cb_phaserp11_i(WidgetPDial*, void*); static void cb_phaserp11(WidgetPDial*, void*); +public: + Fl_Check_Button *phaserp12; +private: + void cb_phaserp12_i(Fl_Check_Button*, void*); + static void cb_phaserp12(Fl_Check_Button*, void*); +public: + WidgetPDial *phaserp13; +private: + void cb_phaserp13_i(WidgetPDial*, void*); + static void cb_phaserp13(WidgetPDial*, void*); +public: + Fl_Check_Button *phaserp14; +private: + void cb_phaserp14_i(Fl_Check_Button*, void*); + static void cb_phaserp14(Fl_Check_Button*, void*); public: Fl_Group* make_alienwah_window(); Fl_Group *effalienwahwindow; diff --git a/plugins/zynaddsubfx/src/UI/LFOUI.cc b/plugins/zynaddsubfx/src/UI/LFOUI.cc index 57cdc956a..af6c1f189 100644 --- a/plugins/zynaddsubfx/src/UI/LFOUI.cc +++ b/plugins/zynaddsubfx/src/UI/LFOUI.cc @@ -57,11 +57,11 @@ Fl_Menu_Item LFOUI::menu_LFOtype[] = { {0,0,0,0,0,0,0,0,0} }; -void LFOUI::cb_continuous_i(Fl_Check_Button* o, void*) { - pars->Pcontinuous=(int)o->value(); +void LFOUI::cb_continous_i(Fl_Check_Button* o, void*) { + pars->Pcontinous=(int)o->value(); } -void LFOUI::cb_continuous(Fl_Check_Button* o, void* v) { - ((LFOUI*)(o->parent()->parent()->user_data()))->cb_continuous_i(o,v); +void LFOUI::cb_continous(Fl_Check_Button* o, void* v) { + ((LFOUI*)(o->parent()->parent()->user_data()))->cb_continous_i(o,v); } void LFOUI::cb_freqrand_i(WidgetPDial* o, void*) { @@ -203,13 +203,13 @@ Fl_Group* LFOUI::make_window() { LFOtype->align(Fl_Align(FL_ALIGN_BOTTOM)); LFOtype->menu(menu_LFOtype); } // Fl_Choice* LFOtype - { continuous = new Fl_Check_Button(165, 35, 15, 15, "C."); - continuous->tooltip("Continuous LFO"); - continuous->down_box(FL_DOWN_BOX); - continuous->labelsize(10); - continuous->callback((Fl_Callback*)cb_continuous); - continuous->align(Fl_Align(FL_ALIGN_BOTTOM)); - } // Fl_Check_Button* continuous + { continous = new Fl_Check_Button(165, 35, 15, 15, "C."); + continous->tooltip("Continous LFO"); + continous->down_box(FL_DOWN_BOX); + continous->labelsize(10); + continous->callback((Fl_Callback*)cb_continous); + continous->align(Fl_Align(FL_ALIGN_BOTTOM)); + } // Fl_Check_Button* continous { freqrand = new WidgetPDial(205, 7, 20, 20, "F.R."); freqrand->tooltip("LFO Frequency Randomness"); freqrand->box(FL_ROUND_UP_BOX); @@ -268,7 +268,7 @@ void LFOUI::refresh() { intensity->value(pars->Pintensity); startphase->value(pars->Pstartphase); delay->value(pars->Pdelay); -continuous->value(pars->Pcontinuous); +continous->value(pars->Pcontinous); stretch->value(pars->Pstretch); randomness->value(pars->Prandomness); freqrand->value(pars->Pfreqrand); diff --git a/plugins/zynaddsubfx/src/UI/LFOUI.fl b/plugins/zynaddsubfx/src/UI/LFOUI.fl index d5fcc2eba..ca0433a2d 100644 --- a/plugins/zynaddsubfx/src/UI/LFOUI.fl +++ b/plugins/zynaddsubfx/src/UI/LFOUI.fl @@ -119,10 +119,10 @@ hide(); xywh {70 70 100 20} labelfont 1 labelsize 10 } } - Fl_Check_Button continuous { + Fl_Check_Button continous { label {C.} - callback {pars->Pcontinuous=(int)o->value();} - tooltip {Continuous LFO} xywh {165 35 15 15} down_box DOWN_BOX labelsize 10 align 2 + callback {pars->Pcontinous=(int)o->value();} + tooltip {Continous LFO} xywh {165 35 15 15} down_box DOWN_BOX labelsize 10 align 2 } Fl_Dial freqrand { label {F.R.} @@ -154,7 +154,7 @@ hide(); intensity->value(pars->Pintensity); startphase->value(pars->Pstartphase); delay->value(pars->Pdelay); -continuous->value(pars->Pcontinuous); +continous->value(pars->Pcontinous); stretch->value(pars->Pstretch); randomness->value(pars->Prandomness); freqrand->value(pars->Pfreqrand); diff --git a/plugins/zynaddsubfx/src/UI/LFOUI.h b/plugins/zynaddsubfx/src/UI/LFOUI.h index f05c0bde2..6959fe3f3 100644 --- a/plugins/zynaddsubfx/src/UI/LFOUI.h +++ b/plugins/zynaddsubfx/src/UI/LFOUI.h @@ -56,10 +56,10 @@ private: static void cb_LFOtype(Fl_Choice*, void*); static Fl_Menu_Item menu_LFOtype[]; public: - Fl_Check_Button *continuous; + Fl_Check_Button *continous; private: - void cb_continuous_i(Fl_Check_Button*, void*); - static void cb_continuous(Fl_Check_Button*, void*); + void cb_continous_i(Fl_Check_Button*, void*); + static void cb_continous(Fl_Check_Button*, void*); public: WidgetPDial *freqrand; private: diff --git a/plugins/zynaddsubfx/src/UI/MasterUI.cc b/plugins/zynaddsubfx/src/UI/MasterUI.cc index bc1b836a9..cc8330473 100644 --- a/plugins/zynaddsubfx/src/UI/MasterUI.cc +++ b/plugins/zynaddsubfx/src/UI/MasterUI.cc @@ -2011,6 +2011,7 @@ General Public License for details."); o->labelfont(1); o->labelsize(12); o->align(Fl_Align(FL_ALIGN_BOTTOM|FL_ALIGN_INSIDE)); + o->hide(); { Fl_Counter* o = simplesyseffnocounter = new Fl_Counter(350, 75, 80, 20, "Sys.Effect No."); simplesyseffnocounter->type(1); simplesyseffnocounter->labelfont(1); @@ -2072,7 +2073,6 @@ General Public License for details."); o->labelfont(1); o->labelsize(12); o->align(Fl_Align(FL_ALIGN_BOTTOM|FL_ALIGN_INSIDE)); - o->hide(); { Fl_Counter* o = simpleinseffnocounter = new Fl_Counter(350, 75, 80, 20, "Ins.Effect No."); simpleinseffnocounter->type(1); simpleinseffnocounter->labelfont(1); diff --git a/plugins/zynaddsubfx/src/UI/MasterUI.fl b/plugins/zynaddsubfx/src/UI/MasterUI.fl index 451c9f422..b97b77326 100644 --- a/plugins/zynaddsubfx/src/UI/MasterUI.fl +++ b/plugins/zynaddsubfx/src/UI/MasterUI.fl @@ -1,5 +1,5 @@ # data file for the Fltk User Interface Designer (fluid) -version 1.0107 +version 1.0110 header_name {.h} code_name {.cc} decl {//Copyright (c) 2002-2009 Nasca Octavian Paul} {} @@ -414,8 +414,7 @@ panellistitemgroup->redraw();} {} } class MasterUI {} { - Function {make_window()} {selected - } { + Function {make_window()} {} { Fl_Window masterwindow { label zynaddsubfx callback {\#ifdef VSTAUDIOOUT @@ -426,7 +425,7 @@ fl_alert("ZynAddSubFX could not be closed this way, because it's a VST plugin. P *exitprogram=1; //}; \#endif} - xywh {31 206 390 465} type Double hide xclass zynaddsubfx + xywh {585 104 390 465} type Double xclass zynaddsubfx visible } { Fl_Menu_Bar mastermenu { xywh {-5 0 690 25} @@ -689,7 +688,7 @@ pthread_mutex_unlock(&master->mutex);} xywh {0 80 390 160} } { Fl_Group {} { - label {System Effects} open + label {System Effects} xywh {0 100 390 140} box ENGRAVED_FRAME labeltype EMBOSSED_LABEL labelsize 15 align 25 } { Fl_Counter syseffnocounter { @@ -1305,7 +1304,7 @@ o->redraw();} } { Fl_Group {} { label {System Effects} - xywh {345 55 245 155} box ENGRAVED_FRAME labelfont 1 labelsize 12 align 18 + xywh {345 55 245 155} box ENGRAVED_FRAME labelfont 1 labelsize 12 align 18 hide } { Fl_Counter simplesyseffnocounter { label {Sys.Effect No.} @@ -1387,7 +1386,7 @@ pthread_mutex_unlock(&master->mutex);} } Fl_Group {} { label {Insertion Effects} - xywh {345 55 245 155} box ENGRAVED_FRAME labelfont 1 labelsize 12 align 18 hide + xywh {345 55 245 155} box ENGRAVED_FRAME labelfont 1 labelsize 12 align 18 } { Fl_Counter simpleinseffnocounter { label {Ins.Effect No.} @@ -1415,7 +1414,7 @@ if (master->Pinsparts[ninseff]!=-1) { master->insefx[ninseff]->changeeffect((int) o->value()); pthread_mutex_unlock(&master->mutex); simpleinseffectui->refresh(master->insefx[ninseff]); -simpleinseffectui->show();} +simpleinseffectui->show();} selected xywh {515 80 70 15} down_box BORDER_BOX labelsize 10 align 5 code0 {o->value(master->insefx[ninseff]->geteffect());} code1 {if (master->Pinsparts[ninseff]== -1) o->deactivate();} diff --git a/plugins/zynaddsubfx/src/UI/PADnoteUI.cc b/plugins/zynaddsubfx/src/UI/PADnoteUI.cc index 86ab5fa78..0478e4cb1 100644 --- a/plugins/zynaddsubfx/src/UI/PADnoteUI.cc +++ b/plugins/zynaddsubfx/src/UI/PADnoteUI.cc @@ -516,7 +516,7 @@ void PADnoteUI::cb_spectrummode(Fl_Choice* o, void* v) { Fl_Menu_Item PADnoteUI::menu_spectrummode[] = { {"Bandwidth", 0, 0, 0, 0, FL_NORMAL_LABEL, 1, 11, 0}, {"Discrete", 0, 0, 0, 0, FL_NORMAL_LABEL, 1, 11, 0}, - {"Continuous", 0, 0, 0, 0, FL_NORMAL_LABEL, 1, 11, 0}, + {"Continous", 0, 0, 0, 0, FL_NORMAL_LABEL, 1, 11, 0}, {0,0,0,0,0,0,0,0,0} }; @@ -1149,7 +1149,7 @@ Fl_Double_Window* PADnoteUI::make_window() { o->value(pars->Pfixedfreq); } // Fl_Check_Button* hz440 { WidgetPDial* o = fixedfreqetdial = new WidgetPDial(420, 295, 15, 15, "Eq.T."); - fixedfreqetdial->tooltip("How the frequency varies according to the keyboard (leftmost for fixed frequen\ + fixedfreqetdial->tooltip("How the frequency varies acording to the keyboard (leftmost for fixed frequen\ cy)"); fixedfreqetdial->box(FL_ROUND_UP_BOX); fixedfreqetdial->color(FL_BACKGROUND_COLOR); diff --git a/plugins/zynaddsubfx/src/UI/PADnoteUI.fl b/plugins/zynaddsubfx/src/UI/PADnoteUI.fl index 3f03dc0ea..74441c199 100644 --- a/plugins/zynaddsubfx/src/UI/PADnoteUI.fl +++ b/plugins/zynaddsubfx/src/UI/PADnoteUI.fl @@ -762,7 +762,7 @@ cbwidget->do_callback();} xywh {125 125 100 20} labelfont 1 labelsize 11 } MenuItem {} { - label Continuous + label Continous xywh {115 115 100 20} labelfont 1 labelsize 11 } } @@ -842,7 +842,7 @@ if (x==0) fixedfreqetdial->deactivate(); Fl_Dial fixedfreqetdial { label {Eq.T.} callback {pars->PfixedfreqET=(int) o->value();} - tooltip {How the frequency varies according to the keyboard (leftmost for fixed frequency)} xywh {420 295 15 15} box ROUND_UP_BOX labelsize 10 align 8 maximum 127 step 1 + tooltip {How the frequency varies acording to the keyboard (leftmost for fixed frequency)} xywh {420 295 15 15} box ROUND_UP_BOX labelsize 10 align 8 maximum 127 step 1 code0 {o->value(pars->PfixedfreqET);} code1 {if (pars->Pfixedfreq==0) o->deactivate();} class WidgetPDial diff --git a/plugins/zynaddsubfx/src/UI/PresetsUI.cc b/plugins/zynaddsubfx/src/UI/PresetsUI.cc index 9c548aa6b..d27285ee5 100644 --- a/plugins/zynaddsubfx/src/UI/PresetsUI.cc +++ b/plugins/zynaddsubfx/src/UI/PresetsUI.cc @@ -261,11 +261,12 @@ void PresetsUI::rescan() { pastebrowse->clear(); p->rescanforpresets(); -for (int i=0;iadd(name); - pastebrowse->add(name); +for (int i=0;iadd(name.c_str()); + pastebrowse->add(name.c_str()); }; } PresetsUI *presetsui; diff --git a/plugins/zynaddsubfx/src/UI/PresetsUI.fl b/plugins/zynaddsubfx/src/UI/PresetsUI.fl index 61e78ce14..dede2dd4d 100644 --- a/plugins/zynaddsubfx/src/UI/PresetsUI.fl +++ b/plugins/zynaddsubfx/src/UI/PresetsUI.fl @@ -11,8 +11,7 @@ decl {\#include } {public decl {\#include } {public } -decl {\#include "../Params/PresetsArray.h"} {selected -} +decl {\#include "../Params/PresetsArray.h"} {} decl {\#include "../Params/Presets.h"} {public } @@ -190,12 +189,14 @@ paste(p,pui);} {} pastebrowse->clear(); p->rescanforpresets(); -for (int i=0;iadd(name); - pastebrowse->add(name); -};} {} +for (int i=0;iadd(name.c_str()); + pastebrowse->add(name.c_str()); +};} {selected + } } decl {Presets *p;} {public } diff --git a/plugins/zynaddsubfx/src/UI/SUBnoteUI.cc b/plugins/zynaddsubfx/src/UI/SUBnoteUI.cc index a28f8d9a1..c00c374c4 100644 --- a/plugins/zynaddsubfx/src/UI/SUBnoteUI.cc +++ b/plugins/zynaddsubfx/src/UI/SUBnoteUI.cc @@ -513,7 +513,7 @@ Fl_Double_Window* SUBnoteUI::make_window() { o->value(pars->Pfixedfreq); } // Fl_Check_Button* hz440 { WidgetPDial* o = fixedfreqetdial = new WidgetPDial(610, 45, 15, 15, "Eq.T."); - fixedfreqetdial->tooltip("How the frequency varies according to the keyboard (leftmost for fixed frequen\ + fixedfreqetdial->tooltip("How the frequency varies acording to the keyboard (leftmost for fixed frequen\ cy)"); fixedfreqetdial->box(FL_ROUND_UP_BOX); fixedfreqetdial->color(FL_BACKGROUND_COLOR); diff --git a/plugins/zynaddsubfx/src/UI/SUBnoteUI.fl b/plugins/zynaddsubfx/src/UI/SUBnoteUI.fl index d7406d475..ef50a0bb9 100644 --- a/plugins/zynaddsubfx/src/UI/SUBnoteUI.fl +++ b/plugins/zynaddsubfx/src/UI/SUBnoteUI.fl @@ -276,7 +276,7 @@ if (x==0) fixedfreqetdial->deactivate(); Fl_Dial fixedfreqetdial { label {Eq.T.} callback {pars->PfixedfreqET=(int) o->value();} - tooltip {How the frequency varies according to the keyboard (leftmost for fixed frequency)} xywh {610 45 15 15} box ROUND_UP_BOX labelsize 10 align 8 maximum 127 step 1 + tooltip {How the frequency varies acording to the keyboard (leftmost for fixed frequency)} xywh {610 45 15 15} box ROUND_UP_BOX labelsize 10 align 8 maximum 127 step 1 code0 {o->value(pars->PfixedfreqET);} code1 {if (pars->Pfixedfreq==0) o->deactivate();} class WidgetPDial