I'm developing a standalone program that sends MIDI messages from a thread (has to be very precise, midi clock, this is the only thing this thread has to do.). I used thread a thread safe circular buffer (based on abstractFifo) for getting information to this thread, but now I have a few questions.
- As I read on this forum you should make 1 audioDeviceManager top level and you don't have to make new audioDeviceManagers for each thread/class... Is it thread safe to pass a reference to the audioDeviceManager and call in my run():
if(deviceManager.getDefaultMidiOutput() != nullptr) /* SEND MIDI STUFF WITH THIS OUTPUT */
Or should i lock this when the setup changes with a changeListener? What would be the correct way to do this?
- How precise is the Thread::wait() on a high priority thread, I guess this depends on the machine but are there better ways to do this? The wait() has 1ms precision, but I store what the delta time is between the rounded int value and the more precise float value. I tried to wait untill a few milliseconds before the time where the event should happen and check Time::getCurrentMillisHighPrecision() but that took a lot of CPU (what I expected).
Thanks and sorry if I ask stupid questions!