Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 15 additions & 24 deletions plugins/lb302/lb302.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,12 @@ lb302Synth::lb302Synth( InstrumentTrack * _instrumentTrack ) :
slideToggle( false, this, tr( "Slide" ) ),
accentToggle( false, this, tr( "Accent" ) ),
deadToggle( false, this, tr( "Dead" ) ),
db24Toggle( false, this, tr( "24dB/oct Filter" ) )

db24Toggle( false, this, tr( "24dB/oct Filter" ) ),
vca_attack(1.0 - 0.96406088),
vca_decay(0.99897516),
vca_a0(0.5),
vca_a(0.),
vca_mode(never_played)
{

connect( Engine::mixer(), SIGNAL( sampleRateChanged( ) ),
Expand Down Expand Up @@ -327,21 +331,8 @@ lb302Synth::lb302Synth( InstrumentTrack * _instrumentTrack ) :

vcf_envpos = ENVINC;

// Start VCA on an attack.
vca_mode = 3;
vca_a = 0;

//vca_attack = 1.0 - 0.94406088;
vca_attack = 1.0 - 0.96406088;
vca_decay = 0.99897516;

vco_shape = BL_SAWTOOTH;

// Experimenting with a0 between original (0.5) and 1.0
vca_a0 = 0.5;
vca_a = 9;
vca_mode = 3;

vcfs[0] = new lb302FilterIIR2(&fs);
vcfs[1] = new lb302Filter3Pole(&fs);
db24Toggled();
Expand Down Expand Up @@ -481,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 )
Expand All @@ -505,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
Expand Down Expand Up @@ -645,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;
}
}

Expand All @@ -678,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();
Expand Down
9 changes: 8 additions & 1 deletion plugins/lb302/lb302.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,14 @@ public slots:
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;
Expand Down