Various engine bug fixes

This commit is contained in:
Jack Andersen 2016-05-19 01:03:38 -10:00
parent f2f11fee33
commit 3a8a9f0ef2
5 changed files with 12 additions and 5 deletions

View File

@ -205,7 +205,7 @@ struct AppCallback : boo::IApplicationCallback
m_setupId = setupId;
if (m_seq)
{
m_seq->stopSong();
m_seq->stopSong(true);
m_seq->kill();
}
m_seq = m_engine->seqPlay(m_groupId, setupId, nullptr);

View File

@ -54,7 +54,7 @@ class Sequencer : public Entity
/** Voices corresponding to currently-pressed keys in channel */
std::unordered_map<uint8_t, std::shared_ptr<Voice>> m_chanVoxs;
std::unordered_set<std::shared_ptr<Voice>> m_keyoffVoxs;
int8_t m_ctrlVals[128]; /**< MIDI controller values */
int8_t m_ctrlVals[128] = {}; /**< MIDI controller values */
float m_curPitchWheel = 0.f; /**< MIDI pitch-wheel */
int8_t m_curProgram = 0; /**< MIDI program number */
float m_curVol = 1.f; /**< Current volume of channel */

View File

@ -60,7 +60,7 @@ class Voice : public Entity
int16_t m_prev1 = 0; /**< DSPADPCM prev sample */
int16_t m_prev2 = 0; /**< DSPADPCM prev-prev sample */
double m_sampleRate = 32000.0; /**< Current sample rate computed from relative sample key or SETPITCH */
double m_voiceTime; /**< Current seconds of voice playback (per-sample resolution) */
double m_voiceTime = 0.0; /**< Current seconds of voice playback (per-sample resolution) */
VoiceState m_voxState = VoiceState::Dead; /**< Current high-level state of voice */
bool m_sustained = false; /**< Sustain pedal pressed for this voice */

View File

@ -144,7 +144,14 @@ std::shared_ptr<Voice> Sequencer::ChannelState::keyOn(uint8_t note, uint8_t velo
return {};
/* Ensure keyoff sent first */
keyOff(note, 0);
auto keySearch = m_chanVoxs.find(note);
if (keySearch != m_chanVoxs.cend())
{
keySearch->second->keyOff();
keySearch->second->setPedal(false);
m_keyoffVoxs.emplace(std::move(keySearch->second));
m_chanVoxs.erase(keySearch);
}
std::shared_ptr<Voice> ret = m_parent.m_engine._allocateVoice(m_parent.m_audioGroup,
m_parent.m_groupId, 32000.0,

View File

@ -445,7 +445,7 @@ size_t Voice::supplyAudio(size_t samples, int16_t* data)
if (dead && m_voxState == VoiceState::KeyOff &&
m_sampleEndTrap.macroId == 0xffff &&
m_messageTrap.macroId == 0xffff &&
m_volAdsr.isComplete())
(!m_curSample || (m_curSample && m_volAdsr.isComplete())))
{
m_voxState = VoiceState::Dead;
}