summaryrefslogtreecommitdiff
path: root/synth
diff options
context:
space:
mode:
authorFlorian Jung <flo@thinkpad.(none)>2011-01-15 17:35:25 +0100
committerFlorian Jung <flo@thinkpad.(none)>2011-01-15 17:41:03 +0100
commit65381f7f64aacad7023b74c3f20293e8eca5fa22 (patch)
treee97756eeff8d15e3525a8969b1ae8b7a1aa02498 /synth
parent550497e9b09894a79c1c9888901bbbf4949a614b (diff)
Added pfactor-influence for freq_env_amount
Diffstat (limited to 'synth')
-rw-r--r--synth/note.cpp6
-rw-r--r--synth/parser.cpp8
-rw-r--r--synth/programs.cpp10
-rw-r--r--synth/programs.h2
4 files changed, 25 insertions, 1 deletions
diff --git a/synth/note.cpp b/synth/note.cpp
index 046642f..35a7115 100644
--- a/synth/note.cpp
+++ b/synth/note.cpp
@@ -23,6 +23,7 @@ Note::Note(int n, float v, program_t &prg, jack_nframes_t pf, fixed_t pb, int pr
pfactor.out=new fixed_t [n_oscillators];
+ pfactor.freq_env_amount=new fixed_t [n_oscillators];
pfactor.fm=new fixed_t* [n_oscillators];
for (int i=0;i<n_oscillators;i++)
pfactor.fm[i]=new fixed_t [n_oscillators];
@@ -126,6 +127,7 @@ Note::~Note()
delete [] old_oscval;
delete [] pfactor.out;
+ delete [] pfactor.freq_env_amount;
delete [] pfactor.fm;
}
@@ -139,6 +141,7 @@ void Note::recalc_factors()
for (int i=0;i<n_oscillators;i++)
{
pfactor.out[i]=calc_pfactor(curr_prg->pfactor.out[i], vel) * volume_factor;
+ pfactor.freq_env_amount[i]=calc_pfactor(curr_prg->pfactor.freq_env_amount[i], vel);
for (int j=0;j<n_oscillators;j++)
pfactor.fm[i][j]=calc_pfactor(curr_prg->pfactor.fm[i][j], vel);
@@ -151,6 +154,7 @@ void Note::apply_pfactor()
for (int i=0;i<n_oscillators;i++)
{
oscillator[i].output=orig.oscillator[i].output*pfactor.out[i] >>SCALE;
+ oscillator[i].freq_env_amount=orig.oscillator[i].freq_env_amount*pfactor.freq_env_amount[i] /ONE; //because it's a float
for (int j=0;j<n_oscillators;j++)
oscillator[i].fm_strength[j]=orig.oscillator[i].fm_strength[j]*pfactor.fm[i][j] >>SCALE;
@@ -234,7 +238,7 @@ void Note::set_param(const parameter_t &p, fixed_t v) //ACHTUNG:
case FREQ_SUSTAIN: factor_env[p.osc]->set_sustain(v); break;
case FREQ_RELEASE: factor_env[p.osc]->set_release(v*samp_rate >>SCALE); break;
case FREQ_HOLD: factor_env[p.osc]->set_hold((v!=0)); break;
- case FREQ_ENV_AMOUNT: oscillator[p.osc].freq_env_amount=double(v)/ONE; break;
+ case FREQ_ENV_AMOUNT: orig.oscillator[p.osc].freq_env_amount=double(v)/ONE; apply_pfactor(); break;
default: throw string("trying to set an unknown parameter");
diff --git a/synth/parser.cpp b/synth/parser.cpp
index a6f27cb..cd4ed02 100644
--- a/synth/parser.cpp
+++ b/synth/parser.cpp
@@ -238,6 +238,7 @@ void init_filter(filter_params_t &filter)
void init_pfactors(int n_osc, pfactor_formula_t &pfactor)
{
pfactor.out=new param_factor_t [n_osc];
+ pfactor.freq_env_amount=new param_factor_t [n_osc];
pfactor.fm=new param_factor_t* [n_osc];
pfactor.filter_env.offset=ONE;
@@ -254,6 +255,9 @@ void init_pfactors(int n_osc, pfactor_formula_t &pfactor)
pfactor.out[i].offset=0;
pfactor.out[i].vel_amount=ONE;
+ pfactor.freq_env_amount[i].offset=0;
+ pfactor.freq_env_amount[i].vel_amount=ONE;
+
pfactor.fm[i]=new param_factor_t [n_osc];
for (int j=0;j<n_osc;j++)
{
@@ -611,6 +615,10 @@ program_t parse(string fn)
case FILTER_OFFSET:
pfactor.filter_offset=parse_pfactor(strval);
break;
+
+ case FREQ_ENV_AMOUNT:
+ pfactor.freq_env_amount[ind]=parse_pfactor(strval);
+ break;
default:
throw string("velocity cannot influence parameter '"+array+"'");
diff --git a/synth/programs.cpp b/synth/programs.cpp
index cfbd9a1..0f675d6 100644
--- a/synth/programs.cpp
+++ b/synth/programs.cpp
@@ -51,6 +51,7 @@ program_t::program_t()
pfactor.fm=NULL;
pfactor.out=NULL;
+ pfactor.freq_env_amount=NULL;
create_func=NULL;
dl_handle=NULL;
@@ -74,6 +75,8 @@ void program_t::cleanup()
if (pfactor.out)
delete [] pfactor.out;
+ if (pfactor.freq_env_amount)
+ delete [] pfactor.freq_env_amount;
if (pfactor.fm)
{
for (unsigned int i=0;i<n_osc;i++)
@@ -119,6 +122,9 @@ program_t& program_t::operator=(const program_t &that)
this->pfactor.out=new param_factor_t [n_osc];
memcpy(this->pfactor.out, that.pfactor.out, sizeof(param_factor_t)*n_osc);
+ this->pfactor.freq_env_amount=new param_factor_t [n_osc];
+ memcpy(this->pfactor.freq_env_amount, that.pfactor.freq_env_amount, sizeof(param_factor_t)*n_osc);
+
this->pfactor.fm=new param_factor_t* [n_osc];
for (i=0;i<n_osc;i++)
{
@@ -227,6 +233,7 @@ void init_default_program(program_t &p)
p.pfactor.out=new param_factor_t [1];
+ p.pfactor.freq_env_amount=new param_factor_t [1];
p.pfactor.fm=new param_factor_t* [1];
p.pfactor.filter_env.offset=ONE;
@@ -239,6 +246,9 @@ void init_default_program(program_t &p)
p.pfactor.out[0].offset=0;
p.pfactor.out[0].vel_amount=ONE;
+
+ p.pfactor.freq_env_amount[0].offset=ONE;
+ p.pfactor.freq_env_amount[0].vel_amount=0;
p.pfactor.fm[0]=new param_factor_t [1];
p.pfactor.fm[0][0].offset=ONE;
diff --git a/synth/programs.h b/synth/programs.h
index 6a24db3..3ca4a65 100644
--- a/synth/programs.h
+++ b/synth/programs.h
@@ -80,6 +80,7 @@ struct pfactor_formula_t
{
param_factor_t **fm;
param_factor_t *out;
+ param_factor_t *freq_env_amount;
param_factor_t filter_env;
param_factor_t filter_res;
param_factor_t filter_offset;
@@ -89,6 +90,7 @@ struct pfactor_value_t
{
fixed_t **fm;
fixed_t *out;
+ fixed_t *freq_env_amount;
fixed_t filter_env;
fixed_t filter_res;
fixed_t filter_offset;