diff --git a/plugins/stk/mallets/mallets.cpp b/plugins/stk/mallets/mallets.cpp index 29b6aeb20c1..22880484fb4 100644 --- a/plugins/stk/mallets/mallets.cpp +++ b/plugins/stk/mallets/mallets.cpp @@ -338,6 +338,7 @@ void malletsInstrument::playNote( NotePlayHandle * _n, Engine::mixer()->processingSampleRate() ); } m.unlock(); + static_cast(_n->m_pluginData)->setPresetIndex(p); } const fpp_t frames = _n->framesLeftForCurrentPeriod(); @@ -345,6 +346,7 @@ void malletsInstrument::playNote( NotePlayHandle * _n, malletsSynth * ps = static_cast( _n->m_pluginData ); ps->setFrequency( freq ); + p = ps->presetIndex(); sample_t add_scale = 0.0f; if( p == 10 && m_isOldVersionModel.value() == true ) @@ -355,9 +357,9 @@ void malletsInstrument::playNote( NotePlayHandle * _n, for( fpp_t frame = offset; frame < frames + offset; ++frame ) { _working_buffer[frame][0] = ps->nextSampleLeft() * - ( m_scalers[m_presetsModel.value()] + add_scale ); + ( m_scalers[p] + add_scale ); _working_buffer[frame][1] = ps->nextSampleRight() * - ( m_scalers[m_presetsModel.value()] + add_scale ); + ( m_scalers[p] + add_scale ); } instrumentTrack()->processAudioBuffer( _working_buffer, frames + offset, _n ); @@ -579,7 +581,6 @@ void malletsInstrumentView::modelChanged() void malletsInstrumentView::changePreset() { malletsInstrument * inst = castModel(); - inst->instrumentTrack()->silenceAllNotes(); int _preset = inst->m_presetsModel.value(); if( _preset < 9 ) @@ -614,7 +615,8 @@ malletsSynth::malletsSynth( const StkFloat _pitch, const StkFloat _control11, const int _control16, const uint8_t _delay, - const sample_rate_t _sample_rate ) + const sample_rate_t _sample_rate ) : + m_presetIndex(0) { try { @@ -664,7 +666,8 @@ malletsSynth::malletsSynth( const StkFloat _pitch, const StkFloat _control11, const StkFloat _control128, const uint8_t _delay, - const sample_rate_t _sample_rate ) + const sample_rate_t _sample_rate ) : + m_presetIndex(0) { try { @@ -712,7 +715,8 @@ malletsSynth::malletsSynth( const StkFloat _pitch, const StkFloat _control64, const StkFloat _control128, const uint8_t _delay, - const sample_rate_t _sample_rate ) + const sample_rate_t _sample_rate ) : + m_presetIndex(0) { try { diff --git a/plugins/stk/mallets/mallets.h b/plugins/stk/mallets/mallets.h index 3928c531c5c..c8f5e7a47bc 100644 --- a/plugins/stk/mallets/mallets.h +++ b/plugins/stk/mallets/mallets.h @@ -120,8 +120,19 @@ class malletsSynth } } + inline int presetIndex() + { + return m_presetIndex; + } + + inline void setPresetIndex(int presetIndex) + { + m_presetIndex = presetIndex; + } + protected: + int m_presetIndex; Instrmnt * m_voice; StkFloat * m_delay; diff --git a/src/tracks/InstrumentTrack.cpp b/src/tracks/InstrumentTrack.cpp index 3f0c59b7d18..7caf8e2fc16 100644 --- a/src/tracks/InstrumentTrack.cpp +++ b/src/tracks/InstrumentTrack.cpp @@ -445,7 +445,7 @@ void InstrumentTrack::silenceAllNotes( bool removeIPH ) } m_midiNotesMutex.unlock(); - lock(); + Engine::mixer()->requestChangeInModel(); // invalidate all NotePlayHandles and PresetPreviewHandles linked to this track m_processHandles.clear(); @@ -455,7 +455,7 @@ void InstrumentTrack::silenceAllNotes( bool removeIPH ) flags |= PlayHandle::TypeInstrumentPlayHandle; } Engine::mixer()->removePlayHandlesOfTypes( this, flags ); - unlock(); + Engine::mixer()->doneChangeInModel(); } @@ -544,11 +544,13 @@ void InstrumentTrack::setName( const QString & _new_name ) void InstrumentTrack::updateBaseNote() { + Engine::mixer()->requestChangeInModel(); for( NotePlayHandleList::Iterator it = m_processHandles.begin(); it != m_processHandles.end(); ++it ) { ( *it )->setFrequencyUpdate(); } + Engine::mixer()->doneChangeInModel(); }