diff --git a/ChangeLog b/ChangeLog index c27046fea..ebfee74d2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-01-28 Paul Giblock + * plugins/lb302/lb302.cpp: + * plugins/lb302/lb302.h: + finished LB302 M/V-split. however, more changes can be made to meet + the coding guidelines. Let's save this job for LB303 + + * include/automatable_model.h: + cleaned up code for boolModel + 2008-01-26 Tobias Doerffel * src/widgets/automatable_button.cpp: diff --git a/include/automatable_model.h b/include/automatable_model.h index c77551f0f..d610fc669 100644 --- a/include/automatable_model.h +++ b/include/automatable_model.h @@ -286,7 +286,6 @@ public: // some model-primitives -//generateModelPrimitive(bool,signed char); generateModelPrimitive(float,float); generateModelPrimitive(int,int); diff --git a/plugins/lb302/lb302.cpp b/plugins/lb302/lb302.cpp index 443d3a0c4..99cfc45c1 100644 --- a/plugins/lb302/lb302.cpp +++ b/plugins/lb302/lb302.cpp @@ -83,7 +83,7 @@ plugin::descriptor lb302_plugin_descriptor = STRINGIFY_PLUGIN_NAME( PLUGIN_NAME ), "LB302", QT_TRANSLATE_NOOP( "pluginBrowser", - "Incomplete monophonic immitation tb303" ), + "Incomplete monophonic immitation tb303" ), "Paul Giblock ", 0x0100, plugin::Instrument, @@ -97,47 +97,51 @@ plugin::descriptor lb302_plugin_descriptor = // lb302Filter // -lb302Filter::lb302Filter(lb302FilterKnobState* p_fs) : - fs(p_fs), +lb302Filter::lb302Filter(lb302FilterKnobState* p_fs) : + fs(p_fs), vcf_c0(0), - vcf_e0(0), - vcf_e1(0) + vcf_e0(0), + vcf_e1(0) { }; + void lb302Filter::recalc() { - vcf_e1 = exp(6.109 + 1.5876*(fs->envmod) + 2.1553*(fs->cutoff) - 1.2*(1.0-(fs->reso))); - vcf_e0 = exp(5.613 - 0.8*(fs->envmod) + 2.1553*(fs->cutoff) - 0.7696*(1.0-(fs->reso))); - vcf_e0*=M_PI/44100.0; - vcf_e1*=M_PI/44100.0; - vcf_e1 -= vcf_e0; + vcf_e1 = exp(6.109 + 1.5876*(fs->envmod) + 2.1553*(fs->cutoff) - 1.2*(1.0-(fs->reso))); + vcf_e0 = exp(5.613 - 0.8*(fs->envmod) + 2.1553*(fs->cutoff) - 0.7696*(1.0-(fs->reso))); + vcf_e0*=M_PI/44100.0; + vcf_e1*=M_PI/44100.0; + vcf_e1 -= vcf_e0; - vcf_rescoeff = exp(-1.20 + 3.455*(fs->reso)); + vcf_rescoeff = exp(-1.20 + 3.455*(fs->reso)); }; + void lb302Filter::envRecalc() { - vcf_c0 *= fs->envdecay; // Filter Decay. vcf_decay is adjusted for Hz and ENVINC - // vcf_rescoeff = exp(-1.20 + 3.455*(fs->reso)); moved above + vcf_c0 *= fs->envdecay; // Filter Decay. vcf_decay is adjusted for Hz and ENVINC + // vcf_rescoeff = exp(-1.20 + 3.455*(fs->reso)); moved above }; + void lb302Filter::playNote() { - vcf_c0 = vcf_e1; + vcf_c0 = vcf_e1; } + // // lb302FilterIIR2 // lb302FilterIIR2::lb302FilterIIR2(lb302FilterKnobState* p_fs) : - lb302Filter(p_fs), - vcf_d1(0), - vcf_d2(0), - vcf_a(0), - vcf_b(0), - vcf_c(1) + lb302Filter(p_fs), + vcf_d1(0), + vcf_d2(0), + vcf_a(0), + vcf_b(0), + vcf_c(1) { m_dist = new effectLib::distortion<>( 1.0, 1.0f); @@ -145,164 +149,172 @@ lb302FilterIIR2::lb302FilterIIR2(lb302FilterKnobState* p_fs) : }; - - lb302FilterIIR2::~lb302FilterIIR2() { delete m_dist; } - - void lb302FilterIIR2::recalc() { - lb302Filter::recalc(); + lb302Filter::recalc(); //m_dist->setThreshold(0.5+(fs->dist*2.0)); m_dist->setThreshold(fs->dist*75.0); }; + void lb302FilterIIR2::envRecalc() { - float k, w; - - lb302Filter::envRecalc(); + float k, w; - w = vcf_e0 + vcf_c0; // e0 is adjusted for Hz and doesn't need ENVINC - k = exp(-w/vcf_rescoeff); - // Does this mean c0 is inheritantly? - vcf_a = 2.0*cos(2.0*w) * k; - vcf_b = -k*k; - vcf_c = 1.0 - vcf_a - vcf_b; + lb302Filter::envRecalc(); + + w = vcf_e0 + vcf_c0; // e0 is adjusted for Hz and doesn't need ENVINC + k = exp(-w/vcf_rescoeff); // Does this mean c0 is inheritantly? + + vcf_a = 2.0*cos(2.0*w) * k; + vcf_b = -k*k; + vcf_c = 1.0 - vcf_a - vcf_b; } float lb302FilterIIR2::process(const float& samp) { - float ret = vcf_a*vcf_d1 + vcf_b*vcf_d2 + vcf_c*samp; - // Delayed samples for filter - vcf_d2 = vcf_d1; - vcf_d1 = ret; + float ret = vcf_a*vcf_d1 + vcf_b*vcf_d2 + vcf_c*samp; + // Delayed samples for filter + vcf_d2 = vcf_d1; + vcf_d1 = ret; if(fs->dist > 0) ret=m_dist->nextSample(ret); - // output = IIR2 + dry - return ret; + + // output = IIR2 + dry + return ret; } + void lb302FilterIIR2::getState(lb302FilterState* fs) { - fs->iir.vcf_c0 = vcf_c0; - fs->iir.vcf_a = vcf_a; - fs->iir.vcf_b = vcf_b; - fs->iir.vcf_c = vcf_c; - fs->iir.vcf_d1 = vcf_d1; - fs->iir.vcf_d2 = vcf_d2; + fs->iir.vcf_c0 = vcf_c0; + fs->iir.vcf_a = vcf_a; + fs->iir.vcf_b = vcf_b; + fs->iir.vcf_c = vcf_c; + fs->iir.vcf_d1 = vcf_d1; + fs->iir.vcf_d2 = vcf_d2; } + void lb302FilterIIR2::setState(const lb302FilterState* fs) { - vcf_c0 = fs->iir.vcf_c0; - vcf_a = fs->iir.vcf_a; - vcf_b = fs->iir.vcf_b; - vcf_c = fs->iir.vcf_c; - vcf_d1 = fs->iir.vcf_d1; - vcf_d2 = fs->iir.vcf_d2; + vcf_c0 = fs->iir.vcf_c0; + vcf_a = fs->iir.vcf_a; + vcf_b = fs->iir.vcf_b; + vcf_c = fs->iir.vcf_c; + vcf_d1 = fs->iir.vcf_d1; + vcf_d2 = fs->iir.vcf_d2; } + + // // lb302Filter3Pole // lb302Filter3Pole::lb302Filter3Pole(lb302FilterKnobState *p_fs) : - lb302Filter(p_fs), - ay1(0), - ay2(0), - aout(0), - lastin(0) + lb302Filter(p_fs), + ay1(0), + ay2(0), + aout(0), + lastin(0) { }; + void lb302Filter3Pole::recalc() { - // DO NOT CALL BASE CLASS - vcf_e0 = 0.000001; - vcf_e1 = 1.0; + // DO NOT CALL BASE CLASS + vcf_e0 = 0.000001; + vcf_e1 = 1.0; } + // TODO: Try using k instead of vcf_reso void lb302Filter3Pole::envRecalc() { - float w,k; - float kfco; - - lb302Filter::envRecalc(); - - - w = vcf_e0 + vcf_c0; // e0 is adjusted for Hz and doesn't need ENVINC - k = (fs->cutoff > 0.975)?0.975:fs->cutoff; - kfco = 50.f+(k)*((2300.f-1600.f*(fs->envmod))+(w)*(700.f+1500.f*(k)+(1500.f+(k)*(44100.f/2.f-6000.f))*(fs->envmod))); - //+iacc*(.3+.7*kfco*kenvmod)*kaccent*kaccurve*2000 + float w,k; + float kfco; + lb302Filter::envRecalc(); + // e0 is adjusted for Hz and doesn't need ENVINC + w = vcf_e0 + vcf_c0; + k = (fs->cutoff > 0.975)?0.975:fs->cutoff; + kfco = 50.f + (k)*((2300.f-1600.f*(fs->envmod))+(w) * + (700.f+1500.f*(k)+(1500.f+(k)*(44100.f/2.f-6000.f)) * + (fs->envmod)) ); + //+iacc*(.3+.7*kfco*kenvmod)*kaccent*kaccurve*2000 #ifdef LB_24_IGNORE_ENVELOPE - // kfcn = fs->cutoff; - kfcn = 2.0 * kfco / LB_HZ; + // kfcn = fs->cutoff; + kfcn = 2.0 * kfco / LB_HZ; #else - kfcn = w; + kfcn = w; #endif - kp = ((-2.7528*kfcn + 3.0429)*kfcn + 1.718)*kfcn - 0.9984; - kp1 = kp+1.0; - kp1h = 0.5*kp1; + kp = ((-2.7528*kfcn + 3.0429)*kfcn + 1.718)*kfcn - 0.9984; + kp1 = kp+1.0; + kp1h = 0.5*kp1; #ifdef LB_24_RES_TRICK - k = exp(-w/vcf_rescoeff); - kres = (((k))) * (((-2.7079*kp1 + 10.963)*kp1 - 14.934)*kp1 + 8.4974); + k = exp(-w/vcf_rescoeff); + kres = (((k))) * (((-2.7079*kp1 + 10.963)*kp1 - 14.934)*kp1 + 8.4974); #else - kres = (((fs->reso))) * (((-2.7079*kp1 + 10.963)*kp1 - 14.934)*kp1 + 8.4974); + kres = (((fs->reso))) * (((-2.7079*kp1 + 10.963)*kp1 - 14.934)*kp1 + 8.4974); #endif - value = 1.0+( (fs->dist) *(1.5 + 2.0*kres*(1.0-kfcn))); // ENVMOD was DIST*/ + value = 1.0+( (fs->dist) *(1.5 + 2.0*kres*(1.0-kfcn))); // ENVMOD was DIST } + float lb302Filter3Pole::process(const float& samp) { - float ax1 = lastin; - float ay11 = ay1; - float ay31 = ay2; - lastin = (samp) - tanh(kres*aout); - ay1 = kp1h * (lastin+ax1) - kp*ay1; - ay2 = kp1h * (ay1 + ay11) - kp*ay2; - aout = kp1h * (ay2 + ay31) - kp*aout; - - return tanh(aout*value)*LB_24_VOL_ADJUST/(1.0+fs->dist); + float ax1 = lastin; + float ay11 = ay1; + float ay31 = ay2; + lastin = (samp) - tanh(kres*aout); + ay1 = kp1h * (lastin+ax1) - kp*ay1; + ay2 = kp1h * (ay1 + ay11) - kp*ay2; + aout = kp1h * (ay2 + ay31) - kp*aout; + + return tanh(aout*value)*LB_24_VOL_ADJUST/(1.0+fs->dist); } + void lb302Filter3Pole::getState(lb302FilterState* fs) { - fs->pole.aout = aout; - fs->pole.vcf_c0 = vcf_c0; - fs->pole.kp = kp; - fs->pole.kp1h = kp1h; - fs->pole.kres = kres; - fs->pole.ay1 = ay1; - fs->pole.ay2 = ay2; - fs->pole.lastin = lastin; - fs->pole.value = value; + fs->pole.aout = aout; + fs->pole.vcf_c0 = vcf_c0; + fs->pole.kp = kp; + fs->pole.kp1h = kp1h; + fs->pole.kres = kres; + fs->pole.ay1 = ay1; + fs->pole.ay2 = ay2; + fs->pole.lastin = lastin; + fs->pole.value = value; } + void lb302Filter3Pole::setState(const lb302FilterState* fs) { - aout = fs->pole.aout; - vcf_c0 = fs->pole.vcf_c0; - kp = fs->pole.kp; - kp1h = fs->pole.kp1h; - kres = fs->pole.kres; - ay1 = fs->pole.ay1; - ay2 = fs->pole.ay2; - lastin = fs->pole.lastin; - value = fs->pole.value; + aout = fs->pole.aout; + vcf_c0 = fs->pole.vcf_c0; + kp = fs->pole.kp; + kp1h = fs->pole.kp1h; + kres = fs->pole.kres; + ay1 = fs->pole.ay1; + ay2 = fs->pole.ay2; + lastin = fs->pole.lastin; + value = fs->pole.value; } + // // LBSynth // @@ -323,131 +335,127 @@ lb302Synth::lb302Synth( instrumentTrack * _instrumentTrack ) : db24Toggle( FALSE, this ) { -printf("Set track: %Lx\n", (unsigned long long)_instrumentTrack); -/* - connect( &vcf_cut_knob, SIGNAL( valueChanged( float ) ), - this, SLOT ( filterChanged( float ) ) ); + connect( &vcf_cut_knob, SIGNAL( dataChanged( ) ), + this, SLOT ( filterChanged( ) ) ); - connect( &vcf_res_knob, SIGNAL( valueChanged( float ) ), - this, SLOT ( filterChanged( float ) ) ); + connect( &vcf_res_knob, SIGNAL( dataChanged( ) ), + this, SLOT ( filterChanged( ) ) ); - connect( &vcf_mod_knob, SIGNAL( valueChanged( float ) ), - this, SLOT ( filterChanged( float ) ) ); + connect( &vcf_mod_knob, SIGNAL( dataChanged( ) ), + this, SLOT ( filterChanged( ) ) ); - connect( &vcf_dec_knob, SIGNAL( valueChanged( float ) ), - this, SLOT ( filterChanged( float ) ) ); + connect( &vcf_dec_knob, SIGNAL( dataChanged( ) ), + this, SLOT ( filterChanged( ) ) ); - connect( &vco_fine_detune_knob, SIGNAL( valueChanged( float ) ), - this, SLOT ( detuneChanged( float) ) ); + connect( &vco_fine_detune_knob, SIGNAL( dataChanged( ) ), + this, SLOT ( filterChanged( ) ) ); - connect( &db24Toggle, SIGNAL( toggled( bool ) ), - this, SLOT ( db24Toggled( bool) ) ); + connect( &db24Toggle, SIGNAL( dataChanged( ) ), + this, SLOT ( db24Toggled( ) ) ); - connect( &dist_knob, SIGNAL( valueChanged(float) ), - this, SLOT ( filterChanged( float ))); + connect( &dist_knob, SIGNAL( dataChanged( ) ), + this, SLOT ( filterChanged( ))); - connect( &wave_knob, SIGNAL( valueChanged(float) ), - this, SLOT ( waveChanged( float ))); -*/ + connect( &wave_knob, SIGNAL( dataChanged( ) ), + this, SLOT ( waveChanged( ))); - vcf_cut_knob.setTrack( _instrumentTrack ); - vcf_res_knob.setTrack( _instrumentTrack ); - vcf_mod_knob.setTrack( _instrumentTrack ); - vcf_dec_knob.setTrack( _instrumentTrack ); + vcf_cut_knob.setTrack( _instrumentTrack ); + vcf_res_knob.setTrack( _instrumentTrack ); + vcf_mod_knob.setTrack( _instrumentTrack ); + vcf_dec_knob.setTrack( _instrumentTrack ); - vco_fine_detune_knob.setTrack( _instrumentTrack ); + vco_fine_detune_knob.setTrack( _instrumentTrack ); - dist_knob.setTrack( _instrumentTrack ); - wave_knob.setTrack( _instrumentTrack ); - slide_dec_knob.setTrack( _instrumentTrack ); - - slideToggle.setTrack( _instrumentTrack ); - accentToggle.setTrack( _instrumentTrack ); - deadToggle.setTrack( _instrumentTrack ); - db24Toggle.setTrack( _instrumentTrack ); + dist_knob.setTrack( _instrumentTrack ); + wave_knob.setTrack( _instrumentTrack ); + slide_dec_knob.setTrack( _instrumentTrack ); + + slideToggle.setTrack( _instrumentTrack ); + accentToggle.setTrack( _instrumentTrack ); + deadToggle.setTrack( _instrumentTrack ); + db24Toggle.setTrack( _instrumentTrack ); - // SYNTH + // SYNTH - vco_inc = 0.0; + vco_inc = 0.0; vco_c = 0; vco_k = 0; - - vco_slide = 0; vco_slideinc = 0; - vco_slidebase = 0; - fs.cutoff = 0; fs.envmod = 0; - fs.reso = 0; fs.envdecay = 0; - fs.dist = 0; + vco_slide = 0; vco_slideinc = 0; + vco_slidebase = 0; + + fs.cutoff = 0; + fs.envmod = 0; + fs.reso = 0; + fs.envdecay = 0; + fs.dist = 0; vcf_envpos = ENVINC; - vco_detune = 0; + vco_detune = 0; - vca_mode = 3; vca_a = 0; // Start VCA on an attack. + // 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 = SAWTOOTH; + //vca_attack = 1.0 - 0.94406088; + vca_attack = 1.0 - 0.96406088; + vca_decay = 0.99897516; - vca_a0 = 0.5; // Experimenting between original (0.5) and 1.0 - vca_a = 9; - vca_mode = 3; + vco_shape = SAWTOOTH; - vcf = new lb302FilterIIR2(&fs); + // Experimenting with a0 between original (0.5) and 1.0 + vca_a0 = 0.5; + vca_a = 9; + vca_mode = 3; - use_hold_note = false; - sample_cnt = 0; - release_frame = 1<<24; - catch_frame = 0; - catch_decay = 0; + vcf = new lb302FilterIIR2(&fs); - recalcFilter(); + use_hold_note = false; + sample_cnt = 0; + release_frame = 1<<24; + catch_frame = 0; + catch_decay = 0; - lastFramesPlayed = 1; // because we subtract 1 later - last_offset = 0; + recalcFilter(); - period_states = NULL; - period_states_cnt = 0; + lastFramesPlayed = 1; // because we subtract 1 later + last_offset = 0; - filterChanged(0.0); - detuneChanged(0.0); + period_states = NULL; + period_states_cnt = 0; + + filterChanged(); + detuneChanged(); } - - lb302Synth::~lb302Synth() { - delete vcf; + delete vcf; } - - void lb302Synth::saveSettings( QDomDocument & _doc, - QDomElement & _this ) + QDomElement & _this ) { vcf_cut_knob.saveSettings( _doc, _this, "vcf_cut" ); vcf_res_knob.saveSettings( _doc, _this, "vcf_res" ); vcf_mod_knob.saveSettings( _doc, _this, "vcf_mod" ); vcf_dec_knob.saveSettings( _doc, _this, "vcf_dec" ); - vco_fine_detune_knob.saveSettings( _doc, _this, "vco_detune" ); - wave_knob.saveSettings( _doc, _this, "shape"); - dist_knob.saveSettings( _doc, _this, "dist"); - slide_dec_knob.saveSettings( _doc, _this, "slide_dec"); + vco_fine_detune_knob.saveSettings( _doc, _this, "vco_detune" ); + wave_knob.saveSettings( _doc, _this, "shape"); + dist_knob.saveSettings( _doc, _this, "dist"); + slide_dec_knob.saveSettings( _doc, _this, "slide_dec"); - slideToggle.saveSettings( _doc, _this, "slide"); - deadToggle.saveSettings( _doc, _this, "dead"); - db24Toggle.saveSettings( _doc, _this, "db24"); + slideToggle.saveSettings( _doc, _this, "slide"); + deadToggle.saveSettings( _doc, _this, "dead"); + db24Toggle.saveSettings( _doc, _this, "db24"); } - - void lb302Synth::loadSettings( const QDomElement & _this ) { vcf_cut_knob.loadSettings( _this, "vcf_cut" ); @@ -455,73 +463,77 @@ void lb302Synth::loadSettings( const QDomElement & _this ) vcf_mod_knob.loadSettings( _this, "vcf_mod" ); vcf_dec_knob.loadSettings( _this, "vcf_dec" ); - vco_fine_detune_knob.loadSettings( _this, "vco_detune" ); - dist_knob.loadSettings( _this, "dist"); - wave_knob.loadSettings( _this, "shape"); - slide_dec_knob.loadSettings( _this, "slide_dec"); + vco_fine_detune_knob.loadSettings( _this, "vco_detune" ); + dist_knob.loadSettings( _this, "dist"); + wave_knob.loadSettings( _this, "shape"); + slide_dec_knob.loadSettings( _this, "slide_dec"); - slideToggle.loadSettings( _this, "slide"); - deadToggle.loadSettings( _this, "dead"); - db24Toggle.loadSettings( _this, "db24"); + slideToggle.loadSettings( _this, "slide"); + deadToggle.loadSettings( _this, "dead"); + db24Toggle.loadSettings( _this, "db24"); - filterChanged(0.0); - detuneChanged(0.0); + filterChanged(); + detuneChanged(); } // TODO: Split into one function per knob. envdecay doesn't require // recalcFilter. -void lb302Synth::filterChanged( float ) +void lb302Synth::filterChanged( void ) { - fs.cutoff = vcf_cut_knob.value(); - fs.reso = vcf_res_knob.value(); - fs.envmod = vcf_mod_knob.value(); - fs.dist = LB_DIST_RATIO*dist_knob.value(); + fs.cutoff = vcf_cut_knob.value(); + fs.reso = vcf_res_knob.value(); + fs.envmod = vcf_mod_knob.value(); + fs.dist = LB_DIST_RATIO*dist_knob.value(); - float d = 0.2 + (2.3*vcf_dec_knob.value()); - d*=LB_HZ; // d *= smpl rate - fs.envdecay = pow(0.1, 1.0/d * ENVINC); // decay is 0.1 to the 1/d * ENVINC - // vcf_envdecay is now adjusted for both - // sampling rate and ENVINC - recalcFilter(); -} + float d = 0.2 + (2.3*vcf_dec_knob.value()); -void lb302Synth::db24Toggled( bool ) -{ - delete vcf; - if(db24Toggle.value()) { - vcf = new lb302Filter3Pole(&fs); - } - else { - vcf = new lb302FilterIIR2(&fs); - } - recalcFilter(); + d *= LB_HZ; // d *= smpl rate + fs.envdecay = pow(0.1, 1.0/d * ENVINC); // decay is 0.1 to the 1/d * ENVINC + // vcf_envdecay is now adjusted for both + // sampling rate and ENVINC + recalcFilter(); } -void lb302Synth::detuneChanged( float ) +void lb302Synth::db24Toggled( void ) { - float freq = vco_inc*LB_HZ/vco_detune; - float slidebase_freq=0; - - if(vco_slide) { - slidebase_freq = vco_slidebase*LB_HZ/vco_detune; - } - - vco_detune = powf(2.0f, (float)vco_fine_detune_knob.value()/1200.0f); - vco_inc = freq*vco_detune/LB_HZ; - - // If a slide note is pending, - if(vco_slideinc) - vco_slideinc = vco_inc; - - // If currently sliding, - // May need to rescale vco_slide as well - if(vco_slide) - vco_slidebase=slidebase_freq*vco_detune/LB_HZ; + delete vcf; + if(db24Toggle.value()) { + vcf = new lb302Filter3Pole(&fs); + } + else { + vcf = new lb302FilterIIR2(&fs); + } + recalcFilter(); } + +void lb302Synth::detuneChanged( void ) +{ + float freq = vco_inc*LB_HZ/vco_detune; + float slidebase_freq=0; + + if(vco_slide) { + slidebase_freq = vco_slidebase*LB_HZ/vco_detune; + } + + vco_detune = powf(2.0f, (float)vco_fine_detune_knob.value()/1200.0f); + vco_inc = freq*vco_detune/LB_HZ; + + // If a slide note is pending, + if(vco_slideinc) + vco_slideinc = vco_inc; + + // If currently sliding, + // May need to rescale vco_slide as well + if(vco_slide) + vco_slidebase = slidebase_freq*vco_detune/LB_HZ; +} + + // TODO: Set vco_shape in here. -void lb302Synth::waveChanged( float ) +// setHintText is impossible from the synth now?? +void lb302Synth::waveChanged( void ) { /* switch(int(rint(wave_knob.value()))) { @@ -535,231 +547,241 @@ void lb302Synth::waveChanged( float ) */ } + QString lb302Synth::nodeName( void ) const { return( lb302_plugin_descriptor.name ); } + // OBSOLETE. Break apart once we get Q_OBJECT to work. >:[ void lb302Synth::recalcFilter() { - vcf->recalc(); + vcf->recalc(); - // THIS IS OLD 3pole/24dB code, I may reintegrate it. Don't need it - // right now. Should be toggled by LB_24_RES_TRICK at the moment. + // THIS IS OLD 3pole/24dB code, I may reintegrate it. Don't need it + // right now. Should be toggled by LB_24_RES_TRICK at the moment. - /*kfcn = 2.0 * (((vcf_cutoff*3000))) / LB_HZ; - kp = ((-2.7528*kfcn + 3.0429)*kfcn + 1.718)*kfcn - 0.9984; - kp1 = kp+1.0; - kp1h = 0.5*kp1; - kres = (((vcf_reso))) * (((-2.7079*kp1 + 10.963)*kp1 - 14.934)*kp1 + 8.4974); - value = 1.0+( (((0))) *(1.5 + 2.0*kres*(1.0-kfcn))); // ENVMOD was DIST*/ + /*kfcn = 2.0 * (((vcf_cutoff*3000))) / LB_HZ; + kp = ((-2.7528*kfcn + 3.0429)*kfcn + 1.718)*kfcn - 0.9984; + kp1 = kp+1.0; + kp1h = 0.5*kp1; + kres = (((vcf_reso))) * (((-2.7079*kp1 + 10.963)*kp1 - 14.934)*kp1 + 8.4974); + value = 1.0+( (((0))) *(1.5 + 2.0*kres*(1.0-kfcn))); // ENVMOD was DIST*/ - vcf_envpos = ENVINC; // Trigger filter update in process() + vcf_envpos = ENVINC; // Trigger filter update in process() } inline int MIN(int a, int b) { - return (a= ENVINC) { - vcf->envRecalc(); - - vcf_envpos = 0; + vcf->envRecalc(); - if (vco_slide) { - vco_inc=vco_slidebase-vco_slide; - // Calculate coeff from dec_knob on knob change. - vco_slide*= 0.9+(slide_dec_knob.value()*0.0999); // TODO: Adjust for Hz and ENVINC + vcf_envpos = 0; - } + if (vco_slide) { + vco_inc=vco_slidebase-vco_slide; + // Calculate coeff from dec_knob on knob change. + vco_slide*= 0.9+(slide_dec_knob.value()*0.0999); // TODO: Adjust for Hz and ENVINC + + } } - sample_cnt++; + sample_cnt++; vcf_envpos++; - // unused variables - //float old_vco_k = vco_k; - //bool looking; - int decay_frames = 128; + // unused variables + //float old_vco_k = vco_k; + //bool looking; + int decay_frames = 128; // update vco - vco_c += vco_inc; + vco_c += vco_inc; - if(vco_c > 0.5) vco_c -= 1.0; + if(vco_c > 0.5) + vco_c -= 1.0; - if (catch_decay > 0) { - if (catch_decay < decay_frames) { - catch_decay++; - } - else if (use_hold_note) { - use_hold_note = false; - initNote(&hold_note); - } - } - - - switch(int(rint(wave_knob.value()))) { - case 0: vco_shape = SAWTOOTH; break; - case 1: vco_shape = INVERTED_SAWTOOTH; break; - case 2: vco_shape = TRIANGLE; break; - case 3: vco_shape = SQUARE; break; - case 4: vco_shape = ROUND_SQUARE; break; - case 5: vco_shape = MOOG; break; - default: vco_shape = SAWTOOTH; break; - } + if (catch_decay > 0) { + if (catch_decay < decay_frames) { + catch_decay++; + } + else if (use_hold_note) { + use_hold_note = false; + initNote(&hold_note); + } + } - // add vco_shape_param the changes the shape of each curve. - // merge sawtooths with triangle and square with round square? - switch (vco_shape) { - case SAWTOOTH: // p0: curviness of line - vco_k = vco_c; // Is this sawtooth backwards? - break; + switch(int(rint(wave_knob.value()))) { + case 0: vco_shape = SAWTOOTH; break; + case 1: vco_shape = INVERTED_SAWTOOTH; break; + case 2: vco_shape = TRIANGLE; break; + case 3: vco_shape = SQUARE; break; + case 4: vco_shape = ROUND_SQUARE; break; + case 5: vco_shape = MOOG; break; + default: vco_shape = SAWTOOTH; break; + } - case INVERTED_SAWTOOTH: // p0: curviness of line - vco_k = -vco_c; // Is this sawtooth backwards? - break; + // add vco_shape_param the changes the shape of each curve. + // merge sawtooths with triangle and square with round square? + switch (vco_shape) { + case SAWTOOTH: // p0: curviness of line + vco_k = vco_c; // Is this sawtooth backwards? + break; - case TRIANGLE: // p0: duty rev.saw<->triangle<->saw p1: curviness - vco_k = (vco_c*2.0)+0.5; - if (vco_k>0.5) vco_k = 1.0-vco_k; - break; + case INVERTED_SAWTOOTH: // p0: curviness of line + vco_k = -vco_c; // Is this sawtooth backwards? + break; - case SQUARE: // p0: slope of top - vco_k = (vco_c<0)?0.5:-0.5; - break; + case TRIANGLE: // p0: duty rev.saw<->triangle<->saw p1: curviness + vco_k = (vco_c*2.0)+0.5; + if (vco_k>0.5) + vco_k = 1.0- vco_k; + break; - case ROUND_SQUARE: // p0: width of round - vco_k = (vco_c<0)?(sqrtf(1-(vco_c*vco_c*4))-0.5):-0.5; - break; + case SQUARE: // p0: slope of top + vco_k = (vco_c<0)?0.5:-0.5; + break; - case MOOG: // Maybe the fall should be exponential/sinsoidal instead of quadric. - // [-0.5, 0]: Rise, [0,0.25]: Slope down, [0.25,0.5]: Low - vco_k = (vco_c*2.0)+0.5; - if (vco_k>1.0) vco_k = -0.5 ; - else if (vco_k>0.5) { - w = 2.0*(vco_k-0.5)-1.0; - vco_k = 0.5 - sqrtf(1.0-(w*w)); - } - vco_k *= 2.0; // MOOG wave gets filtered away - break; - } + case ROUND_SQUARE: // p0: width of round + vco_k = (vco_c<0)?(sqrtf(1-(vco_c*vco_c*4))-0.5):-0.5; + break; - //vca_a = 0.5; - // Write out samples. + case MOOG: // Maybe the fall should be exponential/sinsoidal instead of quadric. + // [-0.5, 0]: Rise, [0,0.25]: Slope down, [0.25,0.5]: Low + vco_k = (vco_c*2.0)+0.5; + if (vco_k>1.0) { + vco_k = -0.5 ; + } + else if (vco_k>0.5) { + w = 2.0*(vco_k-0.5)-1.0; + vco_k = 0.5 - sqrtf(1.0-(w*w)); + } + vco_k *= 2.0; // MOOG wave gets filtered away + break; + } + + //vca_a = 0.5; + // Write out samples. #ifdef LB_FILTERED - samp = vcf->process(vco_k)*2.0*vca_a; + samp = vcf->process(vco_k)*2.0*vca_a; #else - samp = vco_k*vca_a; + samp = vco_k*vca_a; #endif - /* - float releaseFrames = desiredReleaseFrames(); - samp *= (releaseFrames - catch_decay)/releaseFrames; - */ - samp *= (float)(decay_frames - catch_decay)/(float)decay_frames; + /* + float releaseFrames = desiredReleaseFrames(); + samp *= (releaseFrames - catch_decay)/releaseFrames; + */ + samp *= (float)(decay_frames - catch_decay)/(float)decay_frames; - for(int c=0; c=release_frame) { - vca_mode=1; - } - - // Handle Envelope - // TODO: Add decay once I figure out how to extend past the end of a note. + if((int)i>=release_frame) { + vca_mode=1; + } + + // Handle Envelope + // TODO: Add decay once I figure out how to extend past the end of a note. if(vca_mode==0) { - vca_a+=(vca_a0-vca_a)*vca_attack; - if(sample_cnt>=0.5*44100) - vca_mode = 2; - } + vca_a+=(vca_a0-vca_a)*vca_attack; + if(sample_cnt>=0.5*44100) + vca_mode = 2; + } else if(vca_mode == 1) { vca_a *= vca_decay; - + // the following line actually speeds up processing - if(vca_a < (1/65536.0)) { vca_a = 0; vca_mode = 3; } + if(vca_a < (1/65536.0)) { + vca_a = 0; + vca_mode = 3; + } } - // Store state - period_states[i].vco_c = vco_c; - period_states[i].vca_a = vca_a; // Doesn't change anything (currently) - period_states[i].vca_mode = vca_mode; // Doesn't change anything (currently) - period_states[i].sample_cnt = sample_cnt; // Doesn't change anything (currently) - vcf->getState(&period_states[i].fs); + + // Store state + period_states[i].vco_c = vco_c; + period_states[i].vca_a = vca_a; // Doesn't change anything (currently) + period_states[i].vca_mode = vca_mode; // Doesn't change anything (currently) + period_states[i].sample_cnt = sample_cnt; // Doesn't change anything (currently) + vcf->getState(&period_states[i].fs); } return 1; } + /* Prepares the active LB302 note. I separated this into a function because it * needs to be called on0playNote() when a new note is started. It also needs * to be called from process() when a prior edge-to-edge note is done releasing. */ + void lb302Synth::initNote( lb302Note *n) { - catch_decay = 0; + catch_decay = 0; - vco_inc = n->vco_inc; + vco_inc = n->vco_inc; - // TODO: Try moving to the if() below - if(n->dead == 0 || (vca_mode==1 || vca_mode==3)) { - sample_cnt = 0; - vca_mode = 0; vca_a = 0; - } - else { - vca_mode = 2; - } + // TODO: Try moving to the if() below + if(n->dead == 0 || (vca_mode==1 || vca_mode==3)) { + sample_cnt = 0; + vca_mode = 0; + vca_a = 0; + } + else { + vca_mode = 2; + } - // Initiate Slide - // TODO: Break out into function, should be called again on detuneChanged - if (vco_slideinc) { - vco_slide = vco_inc-vco_slideinc; - vco_slidebase = vco_inc; - vco_slideinc = 0; - } - else { - vco_slide = 0; - } - // End break-out + // Initiate Slide + // TODO: Break out into function, should be called again on detuneChanged + if (vco_slideinc) { + vco_slide = vco_inc-vco_slideinc; + vco_slidebase = vco_inc; + vco_slideinc = 0; + } + else { + vco_slide = 0; + } + // End break-out - // Slide note, save inc for next note - if (slideToggle.value()) { - vco_slideinc = vco_inc; // May need to equal vco_slidebase+vco_slide if last note slid - } + // Slide note, save inc for next note + if (slideToggle.value()) { + vco_slideinc = vco_inc; // May need to equal vco_slidebase+vco_slide if last note slid + } - recalcFilter(); - - if(n->dead ==0){ - // Swap next two blocks?? - vcf->playNote(); - // Ensure envelope is recalculated - vcf_envpos = ENVINC; + recalcFilter(); + + if(n->dead ==0){ + // Swap next two blocks?? + vcf->playNote(); + // Ensure envelope is recalculated + vcf_envpos = ENVINC; - // Double Check - vca_mode = 0; - vca_a = 0.0; - } + // Double Check + vca_mode = 0; + vca_a = 0.0; + } } @@ -783,11 +805,11 @@ void lb302Synth::playNote( notePlayHandle * _n, bool ) // somewhere else f_cnt_t resume_pos = lastFramesPlayed-1; - bool decay_note = false; + bool decay_note = false; // find out which situation we're in constNotePlayHandleVector v = - notePlayHandle::nphsOfInstrumentTrack( getInstrumentTrack(), TRUE ); + notePlayHandle::nphsOfInstrumentTrack( getInstrumentTrack(), TRUE ); // more than one note running? if( v.count() > 1 ) { @@ -797,10 +819,10 @@ void lb302Synth::playNote( notePlayHandle * _n, bool ) // has taken over successfully (i.e. played more than the // difference of the two offsets)? if ( _n->released() && - yn->totalFramesPlayed() >= yn->offset() - on->offset() ) + yn->totalFramesPlayed() >= yn->offset() - on->offset() ) { // then we do not need to play something anymore - return; + return; } // have to fill up the frames left to the new note so limit @@ -816,7 +838,7 @@ void lb302Synth::playNote( notePlayHandle * _n, bool ) // new note while other notes are running? if( v.count() > 1 && yn == _n && - _n->totalFramesPlayed() == 0 ) + _n->totalFramesPlayed() == 0 ) { // if there had been a previous note whose // offset > _n->offset() it played more frames than @@ -824,9 +846,10 @@ void lb302Synth::playNote( notePlayHandle * _n, bool ) // the offset of the youngest note, otherwise we get // frames with both waves overlapped engine::getMixer()->clearAudioBuffer( - _n->getInstrumentTrack()->getAudioPort()-> - firstBuffer(), - framesPerPeriod - yn->offset(), yn->offset() ); + _n->getInstrumentTrack()->getAudioPort()->firstBuffer(), + framesPerPeriod - yn->offset(), + yn->offset() ); + resume_pos = yn->offset() - on->offset() - 1; // make sure we have positive value, otherwise we're // accessing states out of borders @@ -834,8 +857,9 @@ void lb302Synth::playNote( notePlayHandle * _n, bool ) { resume_pos += framesPerPeriod; } - decay_note = true; - } + + decay_note = true; + } } #ifdef LB_DEBUG @@ -854,91 +878,86 @@ void lb302Synth::playNote( notePlayHandle * _n, bool ) if (period_states == NULL) { period_states = new lb302State[framesPerPeriod]; - for (int i=0; i < framesPerPeriod; i++) { - period_states[i].vco_c = vco_c; - period_states[i].vca_a = vca_a; // Doesn't change anything (currently) - period_states[i].vca_mode = vca_mode; // Doesn't change anything (currently) - period_states[i].sample_cnt = sample_cnt; // Doesn't change anything (currently) - vcf->getState(&period_states[i].fs); - } - } + for (int i=0; i < framesPerPeriod; i++) { + period_states[i].vco_c = vco_c; + period_states[i].vca_a = vca_a; // Doesn't change anything (currently) + period_states[i].vca_mode = vca_mode; // Doesn't change anything (currently) + period_states[i].sample_cnt = sample_cnt; // Doesn't change anything (currently) + vcf->getState(&period_states[i].fs); + } + } - // now resume at the proper position and process as usual - lb302State *state = &period_states[resume_pos]; + // now resume at the proper position and process as usual + lb302State *state = &period_states[resume_pos]; - /// Actually resume the state, now that we have the right state object. - vco_c = state->vco_c; - vca_a = state->vca_a; - vca_mode = state->vca_mode; - sample_cnt = state->sample_cnt; - vcf->setState(&state->fs); + // Actually resume the state, now that we have the right state object. + vco_c = state->vco_c; + vca_a = state->vca_a; + vca_mode = state->vca_mode; + sample_cnt = state->sample_cnt; + vcf->setState(&state->fs); - /// Currently have release/decay disabled - // Start the release decay if this is the first release period. - //if (_n->released() && catch_decay == 0) - // catch_decay = 1; - + // Currently have release/decay disabled + // Start the release decay if this is the first release period. + //if (_n->released() && catch_decay == 0) + // catch_decay = 1; - release_frame = _n->framesLeft() - desiredReleaseFrames(); - if ( _n->totalFramesPlayed() <= 0 ) { - /// This code is obsolete, hence the "if false" + release_frame = _n->framesLeft() - desiredReleaseFrames(); - // Existing note. Allow it to decay. - if(deadToggle.value() == 0 && decay_note) { + if ( _n->totalFramesPlayed() <= 0 ) { + // This code is obsolete, hence the "if false" + + // Existing note. Allow it to decay. + if(deadToggle.value() == 0 && decay_note) { #ifdef LB_DECAY - if (catch_decay < 1) { - // BEGIN NOT SURE OF... - //lb302State *st = &period_states[period_states_cnt-1]; - //vca_a = st->vca_a; - //sample_cnt = st->sample_cnt; - // END NOT SURE OF + if (catch_decay < 1) { + // BEGIN NOT SURE OF... + //lb302State *st = &period_states[period_states_cnt-1]; + //vca_a = st->vca_a; + //sample_cnt = st->sample_cnt; + // END NOT SURE OF - // Reserve this note for retrigger in process() - hold_note.vco_inc = _n->frequency()*vco_detune/LB_HZ; // TODO: Use actual sampling rate. - hold_note.dead = deadToggle->value(); - use_hold_note = true; - catch_decay = 1; - } - else { - } + // Reserve this note for retrigger in process() + hold_note.vco_inc = _n->frequency()*vco_detune/LB_HZ; // TODO: Use actual sampling rate. + hold_note.dead = deadToggle->value(); + use_hold_note = true; + catch_decay = 1; + } #else - lb302Note note; - note.vco_inc = _n->frequency()*vco_detune/LB_HZ; // TODO: Use actual sampling rate. - note.dead = deadToggle.value(); - initNote(¬e); - vca_mode=0; - vca_a = state->vca_a; + lb302Note note; + note.vco_inc = _n->frequency()*vco_detune/LB_HZ; // TODO: Use actual sampling rate. + note.dead = deadToggle.value(); + initNote(¬e); + vca_mode=0; + vca_a = state->vca_a; #endif - } - /// Start a new note. - else { - lb302Note note; - note.vco_inc = _n->frequency()*vco_detune/LB_HZ; // TODO: Use actual sampling rate. - note.dead = deadToggle.value(); - initNote(¬e); - use_hold_note = false; - } + } + /// Start a new note. + else { + lb302Note note; + note.vco_inc = _n->frequency()*vco_detune/LB_HZ; // TODO: Use actual sampling rate. + note.dead = deadToggle.value(); + initNote(¬e); + use_hold_note = false; + } + + } - } - sampleFrame *buf = new sampleFrame[frames]; - process(buf, frames); - printf("track %Lx\n", getInstrumentTrack()); - getInstrumentTrack()->processAudioBuffer( buf, frames, _n ); + process(buf, frames); + getInstrumentTrack()->processAudioBuffer( buf, frames, _n ); - delete[] buf; + delete[] buf; - lastFramesPlayed = frames;//_n->framesLeftForCurrentPeriod(); //_n->totalFramesPlayed(); + lastFramesPlayed = frames; //_n->framesLeftForCurrentPeriod(); //_n->totalFramesPlayed(); } - - void lb302Synth::deleteNotePluginData( notePlayHandle * _n ) { } @@ -1019,31 +1038,34 @@ lb302SynthView::lb302SynthView( instrument * _instrument, QWidget * _parent ) : setPalette( pal ); } + lb302SynthView::~lb302SynthView() { } + void lb302SynthView::modelChanged( void ) { lb302Synth * syn = castModel(); m_vcfCutKnob->setModel( &syn->vcf_cut_knob ); m_vcfResKnob->setModel( &syn->vcf_res_knob ); - m_vcfDecKnob->setModel( &syn->vcf_dec_knob ); + m_vcfDecKnob->setModel( &syn->vcf_dec_knob ); m_vcfModKnob->setModel( &syn->vcf_mod_knob ); + m_slideDecKnob->setModel( &syn->slide_dec_knob ); - m_vcoFineDetuneKnob->setModel( &syn->vco_fine_detune_knob ); + m_vcoFineDetuneKnob->setModel( &syn->vco_fine_detune_knob ); - m_distKnob->setModel( &syn->dist_knob ); - m_waveKnob->setModel( &syn->wave_knob ); + m_distKnob->setModel( &syn->dist_knob ); + m_waveKnob->setModel( &syn->wave_knob ); - m_slideToggle->setModel( &syn->slideToggle ); - m_accentToggle->setModel( &syn->accentToggle ); - m_deadToggle->setModel( &syn->deadToggle ); - m_db24Toggle->setModel( &syn->db24Toggle ); + m_slideToggle->setModel( &syn->slideToggle ); + m_accentToggle->setModel( &syn->accentToggle ); + m_deadToggle->setModel( &syn->deadToggle ); + m_db24Toggle->setModel( &syn->db24Toggle ); } - + extern "C" { @@ -1052,8 +1074,8 @@ extern "C" plugin * lmms_plugin_main( model *, void * _data ) { -return( new lb302Synth( - static_cast( _data ) ) ); + return( new lb302Synth( + static_cast( _data ) ) ); } diff --git a/plugins/lb302/lb302.h b/plugins/lb302/lb302.h index 1b31ed8bb..99a88f88c 100644 --- a/plugins/lb302/lb302.h +++ b/plugins/lb302/lb302.h @@ -44,94 +44,94 @@ class notePlayHandle; class lb302FilterKnobState { - public: - float cutoff; - float reso; - float envmod; - float envdecay; - float dist; + public: + float cutoff; + float reso; + float envmod; + float envdecay; + float dist; }; class lb302FilterIIR2State { - public: - float vcf_c0; - float vcf_a; - float vcf_b; - float vcf_c; - float vcf_d1; - float vcf_d2; + public: + float vcf_c0; + float vcf_a; + float vcf_b; + float vcf_c; + float vcf_d1; + float vcf_d2; }; class lb302Filter3PoleState { - public: - float vcf_c0; - float kp, - kp1h, - kres, - ay1, - ay2, - lastin, - value; - float aout; + public: + float vcf_c0; + float kp, + kp1h, + kres, + ay1, + ay2, + lastin, + value; + float aout; }; typedef union { - lb302FilterIIR2State iir; - lb302Filter3PoleState pole; + lb302FilterIIR2State iir; + lb302Filter3PoleState pole; } lb302FilterState; class lb302Filter { - public: - lb302Filter(lb302FilterKnobState* p_fs); - virtual ~lb302Filter() {}; + public: + lb302Filter(lb302FilterKnobState* p_fs); + virtual ~lb302Filter() {}; - virtual void recalc(); - virtual void envRecalc(); - virtual float process(const float& samp)=0; - virtual void playNote(); + virtual void recalc(); + virtual void envRecalc(); + virtual float process(const float& samp)=0; + virtual void playNote(); - virtual void getState(lb302FilterState* fs)=0; - virtual void setState(const lb302FilterState* fs)=0; + virtual void getState(lb302FilterState* fs)=0; + virtual void setState(const lb302FilterState* fs)=0; - protected: - lb302FilterKnobState *fs; - - // Filter Decay + protected: + lb302FilterKnobState *fs; + + // Filter Decay float vcf_c0; // c0=e1 on retrigger; c0*=ed every sample; cutoff=e0+c0 float vcf_e0, // e0 and e1 for interpolation - vcf_e1; - float vcf_rescoeff; // Resonance coefficient [0.30,9.54] + vcf_e1; + float vcf_rescoeff; // Resonance coefficient [0.30,9.54] }; class lb302FilterIIR2 : public lb302Filter { - public: - lb302FilterIIR2(lb302FilterKnobState* p_fs); + public: + lb302FilterIIR2(lb302FilterKnobState* p_fs); virtual ~lb302FilterIIR2(); - virtual void recalc(); - virtual void envRecalc(); - virtual float process(const float& samp); + virtual void recalc(); + virtual void envRecalc(); + virtual float process(const float& samp); - virtual void getState(lb302FilterState* fs); - virtual void setState(const lb302FilterState* fs); + virtual void getState(lb302FilterState* fs); + virtual void setState(const lb302FilterState* fs); - protected: - float vcf_d1, // d1 and d2 are added back into the sample with - vcf_d2; // vcf_a and b as coefficients. IIR2 resonance - // loop. + protected: + float vcf_d1, // d1 and d2 are added back into the sample with + vcf_d2; // vcf_a and b as coefficients. IIR2 resonance + // loop. + + // IIR2 Coefficients for mixing dry and delay. + float vcf_a, // Mixing coefficients for the final sound. + vcf_b, // + vcf_c; - // IIR2 Coefficients for mixing dry and delay. - float vcf_a, // Mixing coefficients for the final sound. - vcf_b, // - vcf_c; - effectLib::monoToStereoAdaptor > * m_dist_fx; effectLib::distortion<> * m_dist; }; @@ -139,72 +139,72 @@ class lb302FilterIIR2 : public lb302Filter class lb302Filter3Pole : public lb302Filter { - public: - lb302Filter3Pole(lb302FilterKnobState* p_fs); + public: + lb302Filter3Pole(lb302FilterKnobState* p_fs); - //virtual void recalc(); - virtual void envRecalc(); - virtual void recalc(); - virtual float process(const float& samp); + //virtual void recalc(); + virtual void envRecalc(); + virtual void recalc(); + virtual float process(const float& samp); - virtual void getState(lb302FilterState* fs); - virtual void setState(const lb302FilterState* fs); + virtual void getState(lb302FilterState* fs); + virtual void setState(const lb302FilterState* fs); - protected: - float kfcn, - kp, - kp1, - kp1h, - kres; - float ay1, - ay2, - aout, - lastin, - value; + protected: + float kfcn, + kp, + kp1, + kp1h, + kres; + float ay1, + ay2, + aout, + lastin, + value; }; - + class lb302State { public: - float vco_c; - float vca_a; - int vca_mode; - int sample_cnt; + float vco_c; + float vca_a; + int vca_mode; + int sample_cnt; - lb302FilterState fs; + lb302FilterState fs; }; class lb302Note { public: - float vco_inc; - bool dead; + float vco_inc; + bool dead; }; class lb302Synth : public instrument { - Q_OBJECT + Q_OBJECT public: lb302Synth( instrumentTrack * _channel_track ); virtual ~lb302Synth(); virtual void FASTCALL playNote( notePlayHandle * _n, - bool _try_parallelizing ); + bool _try_parallelizing ); virtual void FASTCALL deleteNotePluginData( notePlayHandle * _n ); virtual void FASTCALL saveSettings( QDomDocument & _doc, - QDomElement & _parent ); + QDomElement & _parent ); virtual void FASTCALL loadSettings( const QDomElement & _this ); virtual QString nodeName( void ) const; - virtual bool isMonophonic(void) const { - return true; - } + virtual bool isMonophonic(void) const { + return true; + } virtual f_cnt_t desiredReleaseFrames( void ) const { @@ -215,83 +215,83 @@ public: private: - void initNote(lb302Note *note); + void initNote(lb302Note *note); private: knobModel vcf_cut_knob; knobModel vcf_res_knob; knobModel vcf_mod_knob; - knobModel vcf_dec_knob; + knobModel vcf_dec_knob; - knobModel vco_fine_detune_knob; + knobModel vco_fine_detune_knob; - knobModel dist_knob; - knobModel wave_knob; - knobModel slide_dec_knob; + knobModel dist_knob; + knobModel wave_knob; + knobModel slide_dec_knob; - boolModel slideToggle; - boolModel accentToggle; - boolModel deadToggle; - boolModel db24Toggle; + boolModel slideToggle; + boolModel accentToggle; + boolModel deadToggle; + boolModel db24Toggle; public slots: - void filterChanged(float); - void detuneChanged(float); - void waveChanged(float); - void db24Toggled( bool ); + void filterChanged( void ); + void detuneChanged( void ); + void waveChanged( void ); + void db24Toggled( void ); private: - // Oscillator - float vco_inc, // Sample increment for the frequency. Creates Sawtooth. - vco_k, // Raw oscillator sample [-0.5,0.5] - vco_c; // Raw oscillator sample [-0.5,0.5] + // Oscillator + float vco_inc, // Sample increment for the frequency. Creates Sawtooth. + vco_k, // Raw oscillator sample [-0.5,0.5] + vco_c; // Raw oscillator sample [-0.5,0.5] - float vco_slide, //* Current value of slide exponential curve. Nonzero=sliding - vco_slideinc, //* Slide base to use in next node. Nonzero=slide next note - vco_slidebase; //* The base vco_inc while sliding. + float vco_slide, //* Current value of slide exponential curve. Nonzero=sliding + vco_slideinc, //* Slide base to use in next node. Nonzero=slide next note + vco_slidebase; //* The base vco_inc while sliding. - float vco_detune; + float vco_detune; - enum vco_shape_t { SAWTOOTH, INVERTED_SAWTOOTH, SQUARE, TRIANGLE, MOOG, ROUND_SQUARE }; - vco_shape_t vco_shape; + enum vco_shape_t { SAWTOOTH, INVERTED_SAWTOOTH, SQUARE, TRIANGLE, MOOG, ROUND_SQUARE }; + vco_shape_t vco_shape; - // User settings - lb302FilterKnobState fs; - lb302Filter *vcf; - lb302Note hold_note; - bool use_hold_note; - - int lastFramesPlayed; - int release_frame; + // User settings + lb302FilterKnobState fs; + lb302Filter *vcf; + lb302Note hold_note; + bool use_hold_note; - - // More States - int vcf_envpos; // Update counter. Updates when >= ENVINC + int lastFramesPlayed; + int release_frame; + + + // More States + int vcf_envpos; // Update counter. Updates when >= ENVINC float vca_attack, // Amp attack - vca_decay, // Amp decay - vca_a0, // Initial amplifier coefficient - vca_a; // Amplifier coefficient. - - // Envelope State + vca_decay, // Amp decay + vca_a0, // Initial amplifier coefficient + vca_a; // Amplifier coefficient. + + // Envelope State int vca_mode; // 0: attack, 1: decay, 2: idle - // My hacks - int sample_cnt; - - int last_offset; + // My hacks + int sample_cnt; - lb302State *period_states; - int period_states_cnt; + int last_offset; - int catch_frame; - int catch_decay; + lb302State *period_states; + int period_states_cnt; - void recalcFilter(); + int catch_frame; + int catch_decay; - int process(sampleFrame *outbuf, const Uint32 size); + void recalcFilter(); + + int process(sampleFrame *outbuf, const Uint32 size); friend class lb302SynthView; @@ -302,7 +302,7 @@ class lb302SynthView : public instrumentView { public: lb302SynthView( instrument * _instrument, - QWidget * _parent ); + QWidget * _parent ); virtual ~lb302SynthView(); private: @@ -310,19 +310,19 @@ private: knob * m_vcfCutKnob; knob * m_vcfResKnob; - knob * m_vcfDecKnob; + knob * m_vcfDecKnob; knob * m_vcfModKnob; - knob * m_vcoFineDetuneKnob; + knob * m_vcoFineDetuneKnob; - knob * m_distKnob; - knob * m_waveKnob; - knob * m_slideDecKnob; + knob * m_distKnob; + knob * m_waveKnob; + knob * m_slideDecKnob; - ledCheckBox * m_slideToggle; - ledCheckBox * m_accentToggle; - ledCheckBox * m_deadToggle; - ledCheckBox * m_db24Toggle; + ledCheckBox * m_slideToggle; + ledCheckBox * m_accentToggle; + ledCheckBox * m_deadToggle; + ledCheckBox * m_db24Toggle; } ;