Piano: Fix roll playback at startup

This is not a bug currently, since the first column immediately starts
playing at startup and leaves no time for the user to put notes in it.
However, this is needed for exporting.
This commit is contained in:
William McPherson 2020-02-06 22:55:38 +11:00 committed by Andreas Kling
parent 9a05bbaace
commit 5dc014b261
2 changed files with 7 additions and 0 deletions

View file

@ -45,6 +45,9 @@ void AudioEngine::fill_buffer(FixedArray<Sample>& buffer)
{
memset(buffer.data(), 0, buffer_size);
if (m_time == 0)
set_notes_from_roll();
for (size_t i = 0; i < buffer.size(); ++i) {
for (size_t note = 0; note < note_count; ++note) {
switch (m_envelope[note]) {
@ -224,7 +227,10 @@ void AudioEngine::update_roll()
m_current_column = 0;
if (++m_previous_column == horizontal_notes)
m_previous_column = 0;
}
void AudioEngine::set_notes_from_roll()
{
for (int note = 0; note < note_count; ++note) {
if (m_roll_notes[note][m_previous_column] == On)
set_note((note_count - 1) - note, Off);

View file

@ -74,6 +74,7 @@ private:
double noise() const;
void update_roll();
void set_notes_from_roll();
void set_sustain_impl(int sustain);