commit 85ed5029787cbbc3b4ea50bc18b9182526d923eb
parent da1fabc182d64af33b7a6e668d508530046d134d
Author: Hans Petter Selasky <hps@selasky.org>
Date: Sat, 22 Feb 2020 02:07:02 +0100
Make sure missing parameters in the instrument files get initialized
to the preset default values. This typically happens when adding new
parameters which are not present in older presets.
Signed-off-by: Hans Petter Selasky <hps@selasky.org>
Diffstat:
19 files changed, 193 insertions(+), 123 deletions(-)
diff --git a/src/Effects/Alienwah.cpp b/src/Effects/Alienwah.cpp
@@ -183,11 +183,11 @@ void Alienwah::setdelay(unsigned char _Pdelay)
cleanup();
}
-void Alienwah::setpreset(unsigned char npreset)
+unsigned char Alienwah::getpresetpar(unsigned char npreset, unsigned int npar)
{
- const int PRESET_SIZE = 11;
- const int NUM_PRESETS = 4;
- unsigned char presets[NUM_PRESETS][PRESET_SIZE] = {
+#define PRESET_SIZE 11
+#define NUM_PRESETS 4
+ static const unsigned char presets[NUM_PRESETS][PRESET_SIZE] = {
//AlienWah1
{127, 64, 70, 0, 0, 62, 60, 105, 25, 0, 64},
//AlienWah2
@@ -197,17 +197,25 @@ void Alienwah::setpreset(unsigned char npreset)
//AlienWah4
{93, 64, 25, 0, 1, 66, 101, 11, 47, 0, 86}
};
+ if(npreset < NUM_PRESETS && npar < PRESET_SIZE) {
+ if (npar == 0 && insertion == 0) {
+ /* lower the volume if this is system effect */
+ return presets[npreset][npar] / 2;
+ }
+ return presets[npreset][npar];
+ }
+ return 0;
+}
+void Alienwah::setpreset(unsigned char npreset)
+{
if(npreset >= NUM_PRESETS)
npreset = NUM_PRESETS - 1;
- 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
+ for(int n = 0; n != 128; n++)
+ changepar(n, getpresetpar(npreset, n));
Ppreset = npreset;
}
-
void Alienwah::changepar(int npar, unsigned char value)
{
switch(npar) {
diff --git a/src/Effects/Alienwah.h b/src/Effects/Alienwah.h
@@ -30,6 +30,7 @@ class Alienwah:public Effect
~Alienwah();
void out(const Stereo<float *> &smp);
+ unsigned char getpresetpar(unsigned char npreset, unsigned int npar);
void setpreset(unsigned char npreset);
void changepar(int npar, unsigned char value);
unsigned char getpar(int npar) const;
diff --git a/src/Effects/Chorus.cpp b/src/Effects/Chorus.cpp
@@ -210,12 +210,11 @@ void Chorus::setvolume(unsigned char _Pvolume)
volume = (!insertion) ? 1.0f : outvolume;
}
-
-void Chorus::setpreset(unsigned char npreset)
+unsigned char Chorus::getpresetpar(unsigned char npreset, unsigned int npar)
{
- const int PRESET_SIZE = 12;
- const int NUM_PRESETS = 10;
- unsigned char presets[NUM_PRESETS][PRESET_SIZE] = {
+#define PRESET_SIZE 12
+#define NUM_PRESETS 10
+ static const unsigned char presets[NUM_PRESETS][PRESET_SIZE] = {
//Chorus1
{64, 64, 50, 0, 0, 90, 40, 85, 64, 119, 0, 0},
//Chorus2
@@ -237,15 +236,21 @@ void Chorus::setpreset(unsigned char npreset)
//Flange5
{64, 64, 55, 105, 0, 24, 39, 19, 17, 0, 0, 1}
};
+ if(npreset < NUM_PRESETS && npar < PRESET_SIZE) {
+ return presets[npreset][npar];
+ }
+ return 0;
+}
+void Chorus::setpreset(unsigned char npreset)
+{
if(npreset >= NUM_PRESETS)
npreset = NUM_PRESETS - 1;
- for(int n = 0; n < PRESET_SIZE; ++n)
- changepar(n, presets[npreset][n]);
+ for(int n = 0; n != 128; n++)
+ changepar(n, getpresetpar(npreset, n));
Ppreset = npreset;
}
-
void Chorus::changepar(int npar, unsigned char value)
{
switch(npar) {
diff --git a/src/Effects/Chorus.h b/src/Effects/Chorus.h
@@ -29,6 +29,7 @@ class Chorus:public Effect
/**Destructor*/
~Chorus();
void out(const Stereo<float *> &input);
+ unsigned char getpresetpar(unsigned char npreset, unsigned int npar);
void setpreset(unsigned char npreset);
/**
* Sets the value of the chosen variable
diff --git a/src/Effects/Distorsion.cpp b/src/Effects/Distorsion.cpp
@@ -218,37 +218,44 @@ void Distorsion::sethpf(unsigned char _Phpf)
hpfr->setfreq(fr);
}
-
-void Distorsion::setpreset(unsigned char npreset)
+unsigned char Distorsion::getpresetpar(unsigned char npreset, unsigned int npar)
{
- const int PRESET_SIZE = 11;
- const int NUM_PRESETS = 6;
- unsigned char presets[NUM_PRESETS][PRESET_SIZE] = {
+#define PRESET_SIZE 13
+#define NUM_PRESETS 6
+ static const unsigned char presets[NUM_PRESETS][PRESET_SIZE] = {
//Overdrive 1
- {127, 64, 35, 56, 70, 0, 0, 96, 0, 0, 0},
+ {127, 64, 35, 56, 70, 0, 0, 96, 0, 0, 0, 32, 64},
//Overdrive 2
- {127, 64, 35, 29, 75, 1, 0, 127, 0, 0, 0},
+ {127, 64, 35, 29, 75, 1, 0, 127, 0, 0, 0, 32, 64},
//A. Exciter 1
- {64, 64, 35, 75, 80, 5, 0, 127, 105, 1, 0},
+ {64, 64, 35, 75, 80, 5, 0, 127, 105, 1, 0, 32, 64},
//A. Exciter 2
- {64, 64, 35, 85, 62, 1, 0, 127, 118, 1, 0},
+ {64, 64, 35, 85, 62, 1, 0, 127, 118, 1, 0, 32, 64},
//Guitar Amp
- {127, 64, 35, 63, 75, 2, 0, 55, 0, 0, 0},
+ {127, 64, 35, 63, 75, 2, 0, 55, 0, 0, 0, 32, 64},
//Quantisize
- {127, 64, 35, 88, 75, 4, 0, 127, 0, 1, 0}
+ {127, 64, 35, 88, 75, 4, 0, 127, 0, 1, 0, 32, 64}
};
+ if(npreset < NUM_PRESETS && npar < PRESET_SIZE) {
+ if(npar == 0 && insertion == 0) {
+ /* lower the volume if this is system effect */
+ return (3 * presets[npreset][npar]) / 2;
+ }
+ return presets[npreset][npar];
+ }
+ return 0;
+}
+void Distorsion::setpreset(unsigned char npreset)
+{
if(npreset >= NUM_PRESETS)
npreset = NUM_PRESETS - 1;
- for(int n = 0; n < PRESET_SIZE; ++n)
- changepar(n, presets[npreset][n]);
- if(!insertion) //lower the volume if this is system effect
- changepar(0, (int) (presets[npreset][0] / 1.5f));
+ for(int n = 0; n != 128; n++)
+ changepar(n, getpresetpar(npreset, n));
Ppreset = npreset;
cleanup();
}
-
void Distorsion::changepar(int npar, unsigned char value)
{
switch(npar) {
diff --git a/src/Effects/Distorsion.h b/src/Effects/Distorsion.h
@@ -25,6 +25,7 @@ class Distorsion:public Effect
Distorsion(EffectParams pars);
~Distorsion();
void out(const Stereo<float *> &smp);
+ unsigned char getpresetpar(unsigned char npreset, unsigned int npar);
void setpreset(unsigned char npreset);
void changepar(int npar, unsigned char value);
unsigned char getpar(int npar) const;
diff --git a/src/Effects/DynamicFilter.cpp b/src/Effects/DynamicFilter.cpp
@@ -273,11 +273,11 @@ void DynamicFilter::setfilterpreset(unsigned char npreset)
reinitfilter();
}
-void DynamicFilter::setpreset(unsigned char npreset, bool protect)
+unsigned char DynamicFilter::getpresetpar(unsigned char npreset, unsigned int npar)
{
- const int PRESET_SIZE = 10;
- const int NUM_PRESETS = 5;
- unsigned char presets[NUM_PRESETS][PRESET_SIZE] = {
+#define PRESET_SIZE 10
+#define NUM_PRESETS 5
+ static const unsigned char presets[NUM_PRESETS][PRESET_SIZE] = {
//WahWah
{110, 64, 80, 0, 0, 64, 0, 90, 0, 60},
//AutoWah
@@ -289,20 +289,27 @@ void DynamicFilter::setpreset(unsigned char npreset, bool protect)
//VocalMorph1
{127, 64, 50, 0, 0, 96, 64, 0, 0, 60}
};
+ if(npreset < NUM_PRESETS && npar < PRESET_SIZE) {
+ if(npar == 0 && insertion == 0) {
+ /* lower the volume if this is system effect */
+ return presets[npreset][npar] / 2;
+ }
+ return presets[npreset][npar];
+ }
+ return 0;
+}
+void DynamicFilter::setpreset(unsigned char npreset, bool protect)
+{
if(npreset >= NUM_PRESETS)
npreset = NUM_PRESETS - 1;
- for(int n = 0; n < PRESET_SIZE; ++n)
- changepar(n, presets[npreset][n]);
-
- if(insertion == 0) //lower the volume if this is system effect
- changepar(0, presets[npreset][0] * 0.5f);
+ for(int n = 0; n != 128; n++)
+ changepar(n, getpresetpar(npreset, n));
Ppreset = npreset;
if(!protect)
setfilterpreset(npreset);
}
-
void DynamicFilter::changepar(int npar, unsigned char value)
{
switch(npar) {
diff --git a/src/Effects/DynamicFilter.h b/src/Effects/DynamicFilter.h
@@ -27,6 +27,7 @@ class DynamicFilter:public Effect
~DynamicFilter();
void out(const Stereo<float *> &smp);
+ unsigned char getpresetpar(unsigned char npreset, unsigned int npar);
void setpreset(unsigned char npreset) { setpreset(npreset, false); };
void setpreset(unsigned char npreset, bool protect);
void changepar(int npar, unsigned char value);
diff --git a/src/Effects/EQ.cpp b/src/Effects/EQ.cpp
@@ -100,11 +100,6 @@ EQ::EQ(EffectParams pars)
:Effect(pars)
{
for(int i = 0; i < MAX_EQ_BANDS; ++i) {
- filter[i].Ptype = 0;
- filter[i].Pfreq = 64;
- filter[i].Pgain = 64;
- filter[i].Pq = 64;
- filter[i].Pstages = 0;
filter[i].l = memory.alloc<AnalogFilter>(6, 1000.0f, 1.0f, 0, pars.srate, pars.bufsize);
filter[i].r = memory.alloc<AnalogFilter>(6, 1000.0f, 1.0f, 0, pars.srate, pars.bufsize);
}
@@ -157,20 +152,30 @@ void EQ::setvolume(unsigned char _Pvolume)
volume = (!insertion) ? 1.0f : outvolume;
}
-
-void EQ::setpreset(unsigned char npreset)
+unsigned char EQ::getpresetpar(unsigned char npreset, unsigned int npar)
{
- const int PRESET_SIZE = 1;
- const int NUM_PRESETS = 2;
- unsigned char presets[NUM_PRESETS][PRESET_SIZE] = {
+#define PRESET_SIZE 1
+#define NUM_PRESETS 2
+ static const unsigned char presets[NUM_PRESETS][PRESET_SIZE] = {
{67}, //EQ 1
{67} //EQ 2
};
+ if(npreset < NUM_PRESETS && npar < PRESET_SIZE) {
+ return presets[npreset][npar];
+ } else if (npar >= 10 && npar < (10 + MAX_EQ_BANDS * 5)) {
+ static const unsigned char bp_preset[5] = { 0, 64, 64, 64, 0 };
+ return bp_preset[npar % 5];
+ }
+ return 0;
+}
+
+void EQ::setpreset(unsigned char npreset)
+{
if(npreset >= NUM_PRESETS)
npreset = NUM_PRESETS - 1;
- for(int n = 0; n < PRESET_SIZE; ++n)
- changepar(n, presets[npreset][n]);
+ for(int n = 0; n != 128; n++)
+ changepar(n, getpresetpar(npreset, n));
Ppreset = npreset;
}
diff --git a/src/Effects/EQ.h b/src/Effects/EQ.h
@@ -25,6 +25,7 @@ class EQ:public Effect
EQ(EffectParams pars);
~EQ();
void out(const Stereo<float *> &smp);
+ unsigned char getpresetpar(unsigned char npreset, unsigned int npar);
void setpreset(unsigned char npreset);
void changepar(int npar, unsigned char value);
unsigned char getpar(int npar) const;
diff --git a/src/Effects/Echo.cpp b/src/Effects/Echo.cpp
@@ -202,11 +202,11 @@ void Echo::sethidamp(unsigned char _Phidamp)
hidamp = 1.0f - Phidamp / 127.0f;
}
-void Echo::setpreset(unsigned char npreset)
+unsigned char Echo::getpresetpar(unsigned char npreset, unsigned int npar)
{
- const int PRESET_SIZE = 7;
- const int NUM_PRESETS = 9;
- unsigned char presets[NUM_PRESETS][PRESET_SIZE] = {
+#define PRESET_SIZE 7
+#define NUM_PRESETS 9
+ static const unsigned char presets[NUM_PRESETS][PRESET_SIZE] = {
{67, 64, 35, 64, 30, 59, 0 }, //Echo 1
{67, 64, 21, 64, 30, 59, 0 }, //Echo 2
{67, 75, 60, 64, 30, 59, 10}, //Echo 3
@@ -217,17 +217,25 @@ void Echo::setpreset(unsigned char npreset)
{81, 60, 26, 100, 127, 67, 36}, //Panning Echo 3
{62, 64, 28, 64, 100, 90, 55} //Feedback Echo
};
+ if(npreset < NUM_PRESETS && npar < PRESET_SIZE) {
+ if(npar == 0 && insertion != 0) {
+ /* lower the volume if this is insertion effect */
+ return presets[npreset][npar] / 2;
+ }
+ return presets[npreset][npar];
+ }
+ return 0;
+}
+void Echo::setpreset(unsigned char npreset)
+{
if(npreset >= NUM_PRESETS)
npreset = NUM_PRESETS - 1;
- for(int n = 0; n < PRESET_SIZE; ++n)
- changepar(n, presets[npreset][n]);
- if(insertion)
- setvolume(presets[npreset][0] / 2); //lower the volume if this is insertion effect
+ for(int n = 0; n != 128; n++)
+ changepar(n, getpresetpar(npreset, n));
Ppreset = npreset;
}
-
void Echo::changepar(int npar, unsigned char value)
{
switch(npar) {
diff --git a/src/Effects/Echo.h b/src/Effects/Echo.h
@@ -27,6 +27,7 @@ class Echo:public Effect
~Echo();
void out(const Stereo<float *> &input);
+ unsigned char getpresetpar(unsigned char npreset, unsigned int npar);
void setpreset(unsigned char npreset);
/**
* Sets the value of the chosen variable
diff --git a/src/Effects/Effect.h b/src/Effects/Effect.h
@@ -113,6 +113,13 @@ class Effect
Effect(EffectParams pars);
virtual ~Effect() {}
/**
+ * Get default preset parameter value
+ * @param npreset chosen preset
+ * @param npar chosen parameter
+ * @return the default parameter value
+ **/
+ virtual unsigned char getpresetpar(unsigned char npreset, unsigned int npar) = 0;
+ /**
* Choose a preset
* @param npreset number of chosen preset*/
virtual void setpreset(unsigned char npreset) = 0;
diff --git a/src/Effects/EffectMgr.cpp b/src/Effects/EffectMgr.cpp
@@ -180,7 +180,7 @@ EffectMgr::EffectMgr(Allocator &alloc, const SYNTH_T &synth_,
setpresettype("Peffect");
memset(efxoutl, 0, synth.bufferbytes);
memset(efxoutr, 0, synth.bufferbytes);
- memset(settings, 0, sizeof(settings));
+ memset(settings, 255, sizeof(settings));
defaults();
}
@@ -249,7 +249,7 @@ void EffectMgr::changeeffectrt(int _nefx, bool avoidSmash)
}
if(!avoidSmash)
- for(int i=0; i<128; ++i)
+ for(int i = 0; i != 128; i++)
settings[i] = geteffectparrt(i);
}
@@ -257,7 +257,6 @@ void EffectMgr::changeeffect(int _nefx)
{
nefx = _nefx;
//preset = 0;
- //memset(settings, 0, sizeof(settings));
}
//Obtain the effect number
@@ -266,14 +265,29 @@ int EffectMgr::geteffect(void)
return nefx;
}
+void EffectMgr::changesettingsrt(const short int *p_value)
+{
+ for(int i = 0; i != 128; i++) {
+ short int value = p_value[i];
+ /* check if setting is missing */
+ if(value == -1) {
+ if(efx)
+ value = efx->getpresetpar(preset, i);
+ else
+ value = 0;
+ }
+ /* update settings */
+ seteffectparrt(i, value);
+ }
+}
+
// Initialize An Effect in RT context
void EffectMgr::init(void)
{
kill();
changeeffectrt(nefx, true);
changepresetrt(preset, true);
- for(int i=0; i<128; ++i)
- seteffectparrt(i, settings[i]);
+ changesettingsrt(settings);
}
//Strip effect manager of it's realtime memory
@@ -317,15 +331,17 @@ void EffectMgr::changepresetrt(unsigned char npreset, bool avoidSmash)
if(efx)
efx->setpreset(npreset);
if(!avoidSmash)
- for(int i=0; i<128; ++i)
+ for(int i = 0; i != 128; i++)
settings[i] = geteffectparrt(i);
}
//Change a parameter of the current effect
void EffectMgr::seteffectparrt(int npar, unsigned char value)
{
- if(npar<128)
- settings[npar] = value;
+ if(npar < 0 || npar >= 128)
+ return;
+ settings[npar] = value;
+
if(!efx)
return;
try {
@@ -335,23 +351,6 @@ void EffectMgr::seteffectparrt(int npar, unsigned char value)
}
}
-//Change a parameter of the current effect
-void EffectMgr::seteffectpar(int npar, unsigned char value)
-{
- settings[npar] = value;
-}
-
-//Get a parameter of the current effect
-unsigned char EffectMgr::geteffectpar(int npar)
-{
- if(npar<128)
- return settings[npar];
-
- if(!efx)
- return 0;
- return efx->getpar(npar);
-}
-
unsigned char EffectMgr::geteffectparrt(int npar)
{
if(!efx)
@@ -448,8 +447,7 @@ void EffectMgr::paste(EffectMgr &e)
{
changeeffectrt(e.nefx, true);
changepresetrt(e.preset, true);
- for(int i=0;i<128;++i)
- seteffectparrt(i, e.settings[i]);
+ changesettingsrt(e.settings);
if(dynamic_cast<DynamicFilter*>(efx)) {
std::swap(filterpars, e.filterpars);
efx->filterpars = filterpars;
@@ -466,14 +464,18 @@ void EffectMgr::add2XML(XMLwrapper& xml)
xml.addpar("preset", preset);
xml.beginbranch("EFFECT_PARAMETERS");
- for(int n = 0; n < 128; ++n) {
- int par = 0;
- if(efx)
+ for(int n = 0; n != 128; n++) {
+ int par;
+ int def;
+ if(efx) {
par = efx->getpar(n);
- else if(n<128)
+ def = efx->getpresetpar(preset, n);
+ } else {
par = settings[n];
-
- if(par == 0)
+ def = -1;
+ }
+ /* don't store default values */
+ if(par == def)
continue;
xml.beginbranch("par_no", n);
xml.addpar("par", par);
@@ -498,13 +500,13 @@ void EffectMgr::getfromXML(XMLwrapper& xml)
preset = xml.getpar127("preset", preset);
if(xml.enterbranch("EFFECT_PARAMETERS")) {
- for(int n = 0; n < 128; ++n) {
- seteffectpar(n, 0); //erase effect parameter
- if(xml.enterbranch("par_no", n) == 0)
- continue;
- int par = geteffectpar(n);
- seteffectpar(n, xml.getpar127("par", par));
- xml.exitbranch();
+ for(int n = 0; n != 128; n++) {
+ if(xml.enterbranch("par_no", n) == 0) {
+ settings[n] = -1; /* use default */
+ } else {
+ settings[n] = xml.getpar127("par", 0);
+ xml.exitbranch();
+ }
}
assert(filterpars);
if(xml.enterbranch("FILTER")) {
diff --git a/src/Effects/EffectMgr.h b/src/Effects/EffectMgr.h
@@ -50,13 +50,13 @@ class EffectMgr:public Presets
void kill(void) REALTIME;
void cleanup(void) REALTIME;
+ void changesettingsrt(const short int *) REALTIME;
void changeeffectrt(int nefx_, bool avoidSmash=false) REALTIME;
void changeeffect(int nefx_) NONREALTIME;
int geteffect(void);
void changepreset(unsigned char npreset) NONREALTIME;
void changepresetrt(unsigned char npreset, bool avoidSmash=false) REALTIME;
unsigned char getpreset(void);
- void seteffectpar(int npar, unsigned char value) NONREALTIME;
void seteffectparrt(int npar, unsigned char value) REALTIME;
unsigned char geteffectpar(int npar);
unsigned char geteffectparrt(int npar) REALTIME;
@@ -101,7 +101,7 @@ class EffectMgr:public Presets
*
* See also: PresetExtractor.cpp
*/
- char settings[128];
+ short int settings[128];
bool dryonly;
Allocator &memory;
diff --git a/src/Effects/Phaser.cpp b/src/Effects/Phaser.cpp
@@ -402,12 +402,11 @@ void Phaser::setdepth(unsigned char Pdepth)
depth = (float)(Pdepth) / 127.0f;
}
-
-void Phaser::setpreset(unsigned char npreset)
+unsigned char Phaser::getpresetpar(unsigned char npreset, unsigned int npar)
{
- const int PRESET_SIZE = 15;
- const int NUM_PRESETS = 12;
- unsigned char presets[NUM_PRESETS][PRESET_SIZE] = {
+#define PRESET_SIZE 15
+#define NUM_PRESETS 12
+ static const unsigned char presets[NUM_PRESETS][PRESET_SIZE] = {
//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,
@@ -438,14 +437,20 @@ void Phaser::setpreset(unsigned char npreset)
{64, 64, 1, 10, 1, 64, 70, 40, 12, 10, 0, 110,1, 20,
1 }
};
+ if(npreset < NUM_PRESETS && npar < PRESET_SIZE)
+ return presets[npreset][npar];
+ return 0;
+}
+
+void Phaser::setpreset(unsigned char npreset)
+{
if(npreset >= NUM_PRESETS)
npreset = NUM_PRESETS - 1;
- for(int n = 0; n < PRESET_SIZE; ++n)
- changepar(n, presets[npreset][n]);
+ for(int n = 0; n != 128; n++)
+ changepar(n, getpresetpar(npreset, n));
Ppreset = npreset;
}
-
void Phaser::changepar(int npar, unsigned char value)
{
switch(npar) {
diff --git a/src/Effects/Phaser.h b/src/Effects/Phaser.h
@@ -31,6 +31,7 @@ class Phaser:public Effect
Phaser(EffectParams pars);
~Phaser();
void out(const Stereo<float *> &input);
+ unsigned char getpresetpar(unsigned char npreset, unsigned int npar);
void setpreset(unsigned char npreset);
void changepar(int npar, unsigned char value);
unsigned char getpar(int npar) const;
diff --git a/src/Effects/Reverb.cpp b/src/Effects/Reverb.cpp
@@ -433,11 +433,11 @@ void Reverb::setbandwidth(unsigned char _Pbandwidth)
bandwidth->setBandwidth(powf(v, 2.0f) * 200.0f);
}
-void Reverb::setpreset(unsigned char npreset)
+unsigned char Reverb::getpresetpar(unsigned char npreset, unsigned int npar)
{
- const int PRESET_SIZE = 13;
- const int NUM_PRESETS = 13;
- unsigned char presets[NUM_PRESETS][PRESET_SIZE] = {
+#define PRESET_SIZE 13
+#define NUM_PRESETS 13
+ static const unsigned char presets[NUM_PRESETS][PRESET_SIZE] = {
//Cathedral1
{80, 64, 63, 24, 0, 0, 0, 85, 5, 83, 1, 64, 20},
//Cathedral2
@@ -465,17 +465,25 @@ void Reverb::setpreset(unsigned char npreset)
//VeryLong2
{90, 64, 111, 30, 0, 0, 0, 114, 90, 74, 1, 80, 20}
};
+ if(npreset < NUM_PRESETS && npar < PRESET_SIZE) {
+ if (npar == 0 && insertion != 0) {
+ /* lower the volume if reverb is insertion effect */
+ return presets[npreset][npar] / 2;
+ }
+ return presets[npreset][npar];
+ }
+ return 0;
+}
+void Reverb::setpreset(unsigned char npreset)
+{
if(npreset >= NUM_PRESETS)
npreset = NUM_PRESETS - 1;
- for(int n = 0; n < PRESET_SIZE; ++n)
- changepar(n, presets[npreset][n]);
- if(insertion)
- changepar(0, presets[npreset][0] / 2); //lower the volume if reverb is insertion effect
+ for(int n = 0; n != 128; n++)
+ changepar(n, getpresetpar(npreset, n));
Ppreset = npreset;
}
-
void Reverb::changepar(int npar, unsigned char value)
{
switch(npar) {
diff --git a/src/Effects/Reverb.h b/src/Effects/Reverb.h
@@ -30,6 +30,7 @@ class Reverb:public Effect
void out(const Stereo<float *> &smp);
void cleanup(void);
+ unsigned char getpresetpar(unsigned char npreset, unsigned int npar);
void setpreset(unsigned char npreset);
void changepar(int npar, unsigned char value);
unsigned char getpar(int npar) const;