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
16 changes: 10 additions & 6 deletions plugins/stk/mallets/mallets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,15 @@ void malletsInstrument::playNote( NotePlayHandle * _n,
Engine::mixer()->processingSampleRate() );
}
m.unlock();
static_cast<malletsSynth *>(_n->m_pluginData)->setPresetIndex(p);
}

const fpp_t frames = _n->framesLeftForCurrentPeriod();
const f_cnt_t offset = _n->noteOffset();

malletsSynth * ps = static_cast<malletsSynth *>( _n->m_pluginData );
ps->setFrequency( freq );
p = ps->presetIndex();

sample_t add_scale = 0.0f;
if( p == 10 && m_isOldVersionModel.value() == true )
Expand All @@ -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 );
Expand Down Expand Up @@ -579,7 +581,6 @@ void malletsInstrumentView::modelChanged()
void malletsInstrumentView::changePreset()
{
malletsInstrument * inst = castModel<malletsInstrument>();
inst->instrumentTrack()->silenceAllNotes();
int _preset = inst->m_presetsModel.value();

if( _preset < 9 )
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
Expand Down
11 changes: 11 additions & 0 deletions plugins/stk/mallets/mallets.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions src/tracks/InstrumentTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -455,7 +455,7 @@ void InstrumentTrack::silenceAllNotes( bool removeIPH )
flags |= PlayHandle::TypeInstrumentPlayHandle;
}
Engine::mixer()->removePlayHandlesOfTypes( this, flags );
unlock();
Engine::mixer()->doneChangeInModel();
}


Expand Down Expand Up @@ -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();
}


Expand Down