summaryrefslogtreecommitdiff
path: root/synth/envelope.cpp
diff options
context:
space:
mode:
authorFlorian Jung <flo@thinkpad.(none)>2011-01-08 19:35:27 +0100
committerFlorian Jung <flo@thinkpad.(none)>2011-01-09 13:14:48 +0100
commit918f4c99f37b9ca2ae2bbd6c906b7e0f994af014 (patch)
treeb7ff7f1dd45bb9328c8bae128c6511b16327d3c5 /synth/envelope.cpp
parent5ae35443bfaa8e321365d549a812d853e0734b89 (diff)
Envelope::get_level() gets called rarely now
Also, changed .gitignore to ignore gmon.out
Diffstat (limited to 'synth/envelope.cpp')
-rw-r--r--synth/envelope.cpp14
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