diff --git a/plugins/Stk/Mallets/Mallets.cpp b/plugins/Stk/Mallets/Mallets.cpp index 1bca0d40f09..dd3b094940f 100644 --- a/plugins/Stk/Mallets/Mallets.cpp +++ b/plugins/Stk/Mallets/Mallets.cpp @@ -301,23 +301,33 @@ void MalletsInstrument::playNote( NotePlayHandle * _n, float position = m_positionModel.value(); float modulator = m_modulatorModel.value(); float crossfade = m_crossfadeModel.value(); + float pressure = m_pressureModel.value(); + float speed = m_velocityModel.value(); if (p < 9) { - hardness += random * static_cast(fast_rand() % 128) - 64.0; + hardness += random * (static_cast(fast_rand() % 128) - 64.0); hardness = std::clamp(hardness, 0.0f, 128.0f); - position += random * static_cast(fast_rand() % 64) - 32.0; + position += random * (static_cast(fast_rand() % 64) - 32.0); position = std::clamp(position, 0.0f, 64.0f); } else if (p == 9) { - modulator += random * static_cast(fast_rand() % 128) - 64.0; + modulator += random * (static_cast(fast_rand() % 128) - 64.0); modulator = std::clamp(modulator, 0.0f, 128.0f); - crossfade += random * static_cast(fast_rand() % 128) - 64.0; + crossfade += random * (static_cast(fast_rand() % 128) - 64.0); crossfade = std::clamp(crossfade, 0.0f, 128.0f); } + else + { + pressure += random * (static_cast(fast_rand() % 128) - 64.0); + pressure = std::clamp(pressure, 0.0f, 128.0f); + + speed += random * (static_cast(fast_rand() % 128) - 64.0); + speed = std::clamp(speed, 0.0f, 128.0f); + } // critical section as STK is not thread-safe static QMutex m; @@ -352,12 +362,12 @@ void MalletsInstrument::playNote( NotePlayHandle * _n, { _n->m_pluginData = new MalletsSynth( freq, vel, - m_pressureModel.value(), + pressure, m_motionModel.value(), m_vibratoModel.value(), p - 10, m_strikeModel.value() * 128.0, - m_velocityModel.value(), + speed, (uint8_t) m_spreadModel.value(), Engine::audioEngine()->processingSampleRate() ); } @@ -369,8 +379,20 @@ void MalletsInstrument::playNote( NotePlayHandle * _n, const f_cnt_t offset = _n->noteOffset(); auto ps = static_cast(_n->m_pluginData); - ps->setFrequency( freq ); + ps->setFrequency(freq); + p = ps->presetIndex(); + if (p < 9) // ModalBar updates + { + ps->setVibratoGain(m_vibratoGainModel.value()); + ps->setVibratoFreq(m_vibratoFreqModel.value()); + } + else if (p == 9) // Tubular Bells updates + { + ps->setADSR(m_adsrModel.value()); + ps->setLFODepth(m_lfoDepthModel.value()); + ps->setLFOSpeed(m_lfoSpeedModel.value()); + } sample_t add_scale = 0.0f; if( p == 10 && m_isOldVersionModel.value() == true ) diff --git a/plugins/Stk/Mallets/Mallets.h b/plugins/Stk/Mallets/Mallets.h index 657d1538a95..91e2dfce140 100644 --- a/plugins/Stk/Mallets/Mallets.h +++ b/plugins/Stk/Mallets/Mallets.h @@ -124,12 +124,38 @@ class MalletsSynth return( s ); } - inline void setFrequency( const StkFloat _pitch ) + inline void setFrequency(const StkFloat _pitch) { - if( m_voice ) - { - m_voice->setFrequency( _pitch ); - } + if (m_voice) { m_voice->setFrequency(_pitch); } + } + + // ModalBar updates + inline void setVibratoGain(const StkFloat _control8) + { + // bug in stk, Control Number 8 and 1 swapped in ModalBar + // we send the control number for stick direct mix instead + if (m_voice) { m_voice->controlChange(8, _control8); } + } + + inline void setVibratoFreq(const StkFloat _control11) + { + if (m_voice) { m_voice->controlChange(11, _control11); } + } + + // Tubular Bells updates + inline void setADSR(const StkFloat _control128) + { + if (m_voice) { m_voice->controlChange(128, _control128); } + } + + inline void setLFODepth(const StkFloat _control1) + { + if (m_voice) { m_voice->controlChange(1, _control1); } + } + + inline void setLFOSpeed(const StkFloat _control11) + { + if (m_voice) { m_voice->controlChange(11, _control11); } } inline int presetIndex()