Introduce an enum to describe the VCA mode
Replace the integer encoding of the VCA mode with an enumeration.
This commit is contained in:
@@ -289,7 +289,7 @@ lb302Synth::lb302Synth( InstrumentTrack * _instrumentTrack ) :
|
||||
vca_decay(0.99897516),
|
||||
vca_a0(0.5),
|
||||
vca_a(0.),
|
||||
vca_mode(3)
|
||||
vca_mode(never_played)
|
||||
{
|
||||
|
||||
connect( Engine::mixer(), SIGNAL( sampleRateChanged( ) ),
|
||||
@@ -472,7 +472,7 @@ int lb302Synth::process(sampleFrame *outbuf, const int size)
|
||||
|
||||
if( release_frame == 0 || ! m_playingNote )
|
||||
{
|
||||
vca_mode = 1;
|
||||
vca_mode = decay;
|
||||
}
|
||||
|
||||
if( new_freq )
|
||||
@@ -496,7 +496,7 @@ int lb302Synth::process(sampleFrame *outbuf, const int size)
|
||||
// start decay if we're past release
|
||||
if( i >= release_frame )
|
||||
{
|
||||
vca_mode = 1;
|
||||
vca_mode = decay;
|
||||
}
|
||||
|
||||
// update vcf
|
||||
@@ -636,18 +636,18 @@ int lb302Synth::process(sampleFrame *outbuf, const int size)
|
||||
}
|
||||
|
||||
// Handle Envelope
|
||||
if(vca_mode==0) {
|
||||
if(vca_mode==attack) {
|
||||
vca_a+=(vca_a0-vca_a)*vca_attack;
|
||||
if(sample_cnt>=0.5*Engine::mixer()->processingSampleRate())
|
||||
vca_mode = 2;
|
||||
vca_mode = idle;
|
||||
}
|
||||
else if(vca_mode == 1) {
|
||||
else if(vca_mode == decay) {
|
||||
vca_a *= vca_decay;
|
||||
|
||||
// the following line actually speeds up processing
|
||||
if(vca_a < (1/65536.0)) {
|
||||
vca_a = 0;
|
||||
vca_mode = 3;
|
||||
vca_mode = never_played;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -669,15 +669,15 @@ void lb302Synth::initNote( lb302Note *n)
|
||||
|
||||
// Always reset vca on non-dead notes, and
|
||||
// Only reset vca on decaying(decayed) and never-played
|
||||
if(n->dead == 0 || (vca_mode==1 || vca_mode==3)) {
|
||||
if(n->dead == 0 || (vca_mode == decay || vca_mode == never_played)) {
|
||||
//printf(" good\n");
|
||||
sample_cnt = 0;
|
||||
vca_mode = 0;
|
||||
vca_mode = attack;
|
||||
// LB303:
|
||||
//vca_a = 0;
|
||||
}
|
||||
else {
|
||||
vca_mode = 2;
|
||||
vca_mode = idle;
|
||||
}
|
||||
|
||||
initSlide();
|
||||
|
||||
@@ -224,7 +224,14 @@ private:
|
||||
vca_a; // Amplifier coefficient.
|
||||
|
||||
// Envelope State
|
||||
int vca_mode; // 0: attack, 1: decay, 2: idle, 3: never played
|
||||
enum VCA_Mode
|
||||
{
|
||||
attack = 0,
|
||||
decay = 1,
|
||||
idle = 2,
|
||||
never_played = 3
|
||||
};
|
||||
VCA_Mode vca_mode;
|
||||
|
||||
// My hacks
|
||||
int sample_cnt;
|
||||
|
||||
Reference in New Issue
Block a user