| 119 | } |
| 120 | |
| 121 | void NoteOutput::Flush(double time) |
| 122 | { |
| 123 | if (!IsAudioThread()) |
| 124 | { |
| 125 | TheSynth->GetNoteOutputQueue()->QueueFlush(this, time + TheTransport->GetEventLookaheadMs() + gBufferSizeMs); //include event lookahead, and make it 1 buffer later, to make sure notes get cleared |
| 126 | return; |
| 127 | } |
| 128 | |
| 129 | bool flushed = false; |
| 130 | |
| 131 | for (int i = 0; i < 128; ++i) |
| 132 | { |
| 133 | if (mNotes[i]) |
| 134 | { |
| 135 | for (auto noteReceiver : mNoteSource->GetPatchCableSource()->GetNoteReceivers()) |
| 136 | { |
| 137 | noteReceiver->PlayNote(time, i, 0); |
| 138 | noteReceiver->PlayNote(time + Transport::sEventEarlyMs, i, 0); |
| 139 | } |
| 140 | flushed = true; |
| 141 | mNotes[i] = false; |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | if (flushed) |
| 146 | mNoteSource->GetPatchCableSource()->AddHistoryEvent(time, false); |
| 147 | } |
| 148 | |
| 149 | void INoteSource::PlayNoteOutput(double time, int pitch, int velocity, int voiceIdx, ModulationParameters modulation, bool isFromMainThreadAndScheduled) |
| 150 | { |