Mallets - Some small fixes (#6913)
* Fix issue with knob range * Randomness for BandedWG * Implement Tubular Bells ADSR * LFO - update values on change while playing * coding style * Vibrato Gain - update
This commit is contained in:
@@ -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<float>(fast_rand() % 128) - 64.0;
|
||||
hardness += random * (static_cast<float>(fast_rand() % 128) - 64.0);
|
||||
hardness = std::clamp(hardness, 0.0f, 128.0f);
|
||||
|
||||
position += random * static_cast<float>(fast_rand() % 64) - 32.0;
|
||||
position += random * (static_cast<float>(fast_rand() % 64) - 32.0);
|
||||
position = std::clamp(position, 0.0f, 64.0f);
|
||||
}
|
||||
else if (p == 9)
|
||||
{
|
||||
modulator += random * static_cast<float>(fast_rand() % 128) - 64.0;
|
||||
modulator += random * (static_cast<float>(fast_rand() % 128) - 64.0);
|
||||
modulator = std::clamp(modulator, 0.0f, 128.0f);
|
||||
|
||||
crossfade += random * static_cast<float>(fast_rand() % 128) - 64.0;
|
||||
crossfade += random * (static_cast<float>(fast_rand() % 128) - 64.0);
|
||||
crossfade = std::clamp(crossfade, 0.0f, 128.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
pressure += random * (static_cast<float>(fast_rand() % 128) - 64.0);
|
||||
pressure = std::clamp(pressure, 0.0f, 128.0f);
|
||||
|
||||
speed += random * (static_cast<float>(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<MalletsSynth*>(_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 )
|
||||
|
||||
@@ -124,12 +124,38 @@ public:
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user