diff --git a/lib/SoundMacroState.cpp b/lib/SoundMacroState.cpp index a0c5e7e..42997cc 100644 --- a/lib/SoundMacroState.cpp +++ b/lib/SoundMacroState.cpp @@ -572,7 +572,11 @@ bool SoundMacroState::advance(Voice& vox, double dt) noteLo *= 100; noteHi *= 100; - m_curPitch = vox.getEngine().nextRandom() % ((noteHi - noteLo) + noteLo); + if (noteHi == noteLo) + m_curPitch = noteHi; + else + m_curPitch = (vox.getEngine().nextRandom() % (noteHi - noteLo)) + noteLo; + if (!free) m_curPitch = m_curPitch / 100 * 100 + detune; diff --git a/lib/Voice.cpp b/lib/Voice.cpp index b80a415..42670fd 100644 --- a/lib/Voice.cpp +++ b/lib/Voice.cpp @@ -221,7 +221,7 @@ bool Voice::_advanceSample(int16_t& samp, int32_t& newPitch) } /* Factor in ADSR envelope state */ - float totalVol = m_userVol * m_curVol * m_volAdsr.nextSample(m_sampleRate) /* (m_state.m_curVel / 127.f)*/; + float totalVol = m_userVol * m_curVol * m_volAdsr.nextSample(m_sampleRate) * (m_state.m_curVel / 127.f); /* Apply tremolo */ if (m_state.m_tremoloSel && (m_tremoloScale || m_tremoloModScale)) @@ -326,10 +326,11 @@ size_t Voice::supplyAudio(size_t samples, int16_t* data) return samples; } } + else + dead = m_state.advance(*this, samples / m_sampleRate); if (m_curSample) { - dead = m_state.advance(*this, samples / m_sampleRate); uint32_t block = m_curSamplePos / 14; uint32_t rem = m_curSamplePos % 14;