diff options
Diffstat (limited to 'synth/envelope.cpp')
-rw-r--r-- | synth/envelope.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/synth/envelope.cpp b/synth/envelope.cpp index 481b78f..3e9c6ac 100644 --- a/synth/envelope.cpp +++ b/synth/envelope.cpp @@ -1,12 +1,14 @@ #include "envelope.h" -Envelope::Envelope(jack_nframes_t a, jack_nframes_t d, fixed_t s, jack_nframes_t r, bool h) +Envelope::Envelope(jack_nframes_t a, jack_nframes_t d, fixed_t s, jack_nframes_t r, bool h, int frames) { level=0; t=0; state=ATTACK; max=ONE; + nth_frame=frames; + set_ratefactor(1.0); set_attack(a); @@ -16,13 +18,15 @@ Envelope::Envelope(jack_nframes_t a, jack_nframes_t d, fixed_t s, jack_nframes_t set_hold(h); } -Envelope::Envelope(env_settings_t s) +Envelope::Envelope(env_settings_t s, int frames) { level=0; t=0; state=ATTACK; max=ONE; + nth_frame=frames; + set_ratefactor(1.0); set_attack(s.attack); @@ -44,7 +48,7 @@ void Envelope::set_ratefactor(double factor) void Envelope::set_attack(jack_nframes_t a) { attack_orig=a; - attack=a*ratefactor >>SCALE; + attack=(a*ratefactor >>SCALE)/nth_frame; if (state==ATTACK) t=attack*level >>SCALE; @@ -53,7 +57,7 @@ void Envelope::set_attack(jack_nframes_t a) void Envelope::set_decay(jack_nframes_t d) { decay_orig=d; - decay=d*ratefactor >>SCALE; + decay=(d*ratefactor >>SCALE)/nth_frame; if ((state==DECAY) && (sustain!=ONE)) if (sustain<ONE) //to avoid a div. by zero @@ -69,7 +73,7 @@ void Envelope::set_sustain(fixed_t s) void Envelope::set_release(jack_nframes_t r) { release_orig=r; - release=r*ratefactor >>SCALE; + release=(r*ratefactor >>SCALE)/nth_frame; if (state==RELEASE) if (sustain>0) //to avoid a div. by zero |