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-08 19:35:27 +0100
commit8320af55e716f352f2720801fcd73913f2e7d19c (patch)
treee36f1ea85d688f8314348a22e6b863af7c6eafeb /synth/envelope.cpp
parentd84da6cdfb9027a67b8ab50fe2c23374acc3b245 (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