Calculate voice step length adjustments.

Signed-off-by: Adrian.Conlon <adrian.conlon@gmail.com>
This commit is contained in:
Adrian.Conlon 2017-09-23 00:26:06 +01:00
parent 5084d85e49
commit 210286514e
2 changed files with 13 additions and 1 deletions

View File

@ -375,6 +375,14 @@ namespace EightBit {
std::array<std::shared_ptr<AudioVoice>, 4> m_voices;
std::array<OutputChannel, 2> m_channels;
bool m_enabled;
template<class T>
static void stepLength(T* voice) {
if (voice->length() > 0) {
auto current = voice->length();
voice->setLength(--current);
}
}
};
}
}

View File

@ -47,7 +47,7 @@ void EightBit::GameBoy::Envelope::step() {
auto volume = m_volume + (m_direction == Amplify ? +1 : -1);
if (volume >= 0 || volume <= 15)
m_volume = volume;
m_position == m_period;
m_position = m_period;
}
}
}
@ -784,6 +784,10 @@ void EightBit::GameBoy::Audio::Sequencer_FrameStep(const int step) {
}
void EightBit::GameBoy::Audio::Sequencer_LengthStep(const int step) {
stepLength(voice1());
stepLength(voice2());
stepLength(voice3());
stepLength(voice4());
}
void EightBit::GameBoy::Audio::Sequencer_VolumeStep(const int step) {