void lb302Synth::playNote( notePlayHandle * _n, sampleFrame * _working_buffer ) { //fpp_t framesPerPeriod = engine::getMixer()->framesPerPeriod(); if( _n->isArpeggioBaseNote() ) { return; } // 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; bool decay_note = false; release_frame = _n->framesLeft() - desiredReleaseFrames(); //LB303 if ( _n->totalFramesPlayed() <= 0 ) { // This code is obsolete, hence the "if false" // Existing note. Allow it to decay. if(deadToggle.value() == 0 && decay_note) { /* lb302Note note; note.vco_inc = _n->frequency()*vco_detune/engine::getMixer()->processingSampleRate(); // TODO: Use actual sampling rate. note.dead = deadToggle.value(); initNote(¬e); vca_mode=0; */ } /// Start a new note. else if( _n->totalFramesPlayed() == 0 ) { new_freq = _n->unpitchedFrequency(); true_freq = _n->frequency(); _n->m_pluginData = this; } // Check for slide if( _n->unpitchedFrequency() == current_freq ) { true_freq = _n->frequency(); if( slideToggle.value() ) { vco_slidebase = GET_INC( true_freq ); // The REAL frequency } else { vco_inc = GET_INC( true_freq ); } } //LB303 } }
void Instrument::applyRelease( sampleFrame * buf, const NotePlayHandle * _n ) { const fpp_t frames = _n->framesLeftForCurrentPeriod(); const fpp_t fpp = Engine::mixer()->framesPerPeriod(); const f_cnt_t fl = _n->framesLeft(); if( fl <= desiredReleaseFrames()+fpp ) { for( fpp_t f = (fpp_t)( ( fl > desiredReleaseFrames() ) ? ( qMax( fpp - desiredReleaseFrames(), 0 ) + fl % fpp ) : 0 ); f < frames; ++f ) { const float fac = (float)( fl-f-1 ) / desiredReleaseFrames(); for( ch_cnt_t ch = 0; ch < DEFAULT_CHANNELS; ++ch ) { buf[f][ch] *= fac; } } } }
void kickerInstrument::playNote( NotePlayHandle * _n, sampleFrame * _working_buffer ) { const fpp_t frames = _n->framesLeftForCurrentPeriod(); const f_cnt_t offset = _n->noteOffset(); const float decfr = m_decayModel.value() * Engine::mixer()->processingSampleRate() / 1000.0f; const f_cnt_t tfp = _n->totalFramesPlayed(); if ( tfp == 0 ) { _n->m_pluginData = new SweepOsc( DistFX( m_distModel.value(), m_gainModel.value() ), m_startNoteModel.value() ? _n->frequency() : m_startFreqModel.value(), m_endNoteModel.value() ? _n->frequency() : m_endFreqModel.value(), m_noiseModel.value() * m_noiseModel.value(), m_clickModel.value() * 0.25f, m_slopeModel.value(), m_envModel.value(), m_distModel.value(), m_distEndModel.value(), decfr ); } else if( tfp > decfr && !_n->isReleased() ) { _n->noteOff(); } SweepOsc * so = static_cast<SweepOsc *>( _n->m_pluginData ); so->update( _working_buffer + offset, frames, Engine::mixer()->processingSampleRate() ); if( _n->isReleased() ) { const float done = _n->releaseFramesDone(); const float desired = desiredReleaseFrames(); for( fpp_t f = 0; f < frames; ++f ) { const float fac = ( done+f < desired ) ? ( 1.0f - ( ( done+f ) / desired ) ) : 0; _working_buffer[f+offset][0] *= fac; _working_buffer[f+offset][1] *= fac; } } instrumentTrack()->processAudioBuffer( _working_buffer, frames + offset, _n ); }
void lb303Synth::playNote( NotePlayHandle * _n, sampleFrame * _working_buffer ) { if( _n->arpBaseNote() ) { //return; } // 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; bool decay_note = false; release_frame = _n->framesLeft() - desiredReleaseFrames(); if(deadToggle.value() == 0 && decay_note) { } /// Start a new note. else if( _n->totalFramesPlayed() == 0 ) { new_freq = _n->unpitchedFrequency(); true_freq = _n->frequency(); _n->m_pluginData = this; } // Check for slide if( _n->unpitchedFrequency() == current_freq ) { true_freq = _n->frequency(); if( slideToggle.value() ) { vco_slidebase = GET_INC( true_freq ); // The REAL frequency } else { vco_inc = GET_INC( true_freq ); } } }