Fix unwanted cutoff bug

This commit is contained in:
Jack Andersen 2019-01-22 21:52:00 -10:00
parent 7719459ac7
commit d80f1346bb
3 changed files with 13 additions and 3 deletions

View File

@ -27,7 +27,7 @@ public:
void keyOff();
float advance(double dt, const Voice& vox);
float advance(double dt);
bool isComplete() const { return m_phase == State::Complete; }
bool isComplete(const Voice& vox) const;
bool isAdsrSet() const { return m_adsrSet; }
};
} // namespace amuse

View File

@ -51,6 +51,9 @@ void Envelope::keyOff() {
}
float Envelope::advance(double dt, const Voice& vox) {
if (!m_adsrSet && !vox.m_state.m_useAdsrControllers)
return 1.f;
double thisTime = m_curTime;
m_curTime += dt;
@ -131,6 +134,9 @@ float Envelope::advance(double dt, const Voice& vox) {
}
float Envelope::advance(double dt) {
if (!m_adsrSet)
return 1.f;
double thisTime = m_curTime;
m_curTime += dt;
@ -196,4 +202,8 @@ float Envelope::advance(double dt) {
return 0.f;
}
}
bool Envelope::isComplete(const Voice& vox) const {
return (m_adsrSet || vox.m_state.m_useAdsrControllers) && m_phase == State::Complete;
}
} // namespace amuse

View File

@ -87,7 +87,7 @@ bool Voice::_checkSamplePos(bool& looped) {
}
/* Looped samples issue sample end when ADSR envelope complete */
if (m_volAdsr.isComplete()) {
if (m_volAdsr.isComplete(*this)) {
_macroSampleEnd();
m_curSample = nullptr;
return true;
@ -456,7 +456,7 @@ void Voice::preSupplyAudio(double dt) {
}
if (dead && (!m_curSample || m_voxState == VoiceState::KeyOff) && m_sampleEndTrap.macroId == 0xffff &&
m_messageTrap.macroId == 0xffff && (!m_curSample || (m_curSample && m_volAdsr.isComplete()))) {
m_messageTrap.macroId == 0xffff && (!m_curSample || (m_curSample && m_volAdsr.isComplete(*this)))) {
m_voxState = VoiceState::Dead;
m_backendVoice->stop();
}