commit c0a33cd2aebd6562cbde57938de7208055556581
parent 0db6089bcb75022bf4b044792b4cf115382002b9
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date: Tue, 8 Oct 2024 20:52:44 +0200
read midi output in esai callback because it might affect peripheral processing rate from another thread, making results unpredictable
Diffstat:
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/source/virusConsoleLib/consoleApp.cpp b/source/virusConsoleLib/consoleApp.cpp
@@ -236,6 +236,8 @@ void ConsoleApp::run(const std::string& _audioOutputFilename, uint32_t _maxSampl
auto& esai = m_dsp1->getAudio();
int32_t notifyTimeout = 0;
+ std::vector<synthLib::SMidiEvent> midiEvents;
+
esai.setCallback([&](dsp56k::Audio*)
{
// Reduce thread contention by waiting until we have nearly enough audio output data available.
@@ -256,7 +258,10 @@ void ConsoleApp::run(const std::string& _audioOutputFilename, uint32_t _maxSampl
callbackCount++;
if((callbackCount & 0x3) == 0)
+ {
+ m_uc->readMidiOut(midiEvents);
audioCallback(callbackCount>>2);
+ }
}, 0);
bootDSP(_createDebugger);
@@ -272,15 +277,12 @@ void ConsoleApp::run(const std::string& _audioOutputFilename, uint32_t _maxSampl
mem.saveAssembly((romFile + "_P.asm").c_str(), 0, mem.sizeP(), true, false, m_dsp1->getDSP().getPeriph(0), m_dsp1->getDSP().getPeriph(1));
}
- std::vector<synthLib::SMidiEvent> midiEvents;
-
AudioProcessor proc(m_rom.getSamplerate(), _audioOutputFilename, m_demo != nullptr, _maxSampleCount, m_dsp1.get(), m_dsp2);
while(!proc.finished())
{
sem.wait();
proc.processBlock(blockSize);
- m_uc->readMidiOut(midiEvents);
midiEvents.clear();
}