Thread communication between ProcessSample/UI

Post Reply
arbuxMusic
Posts: 49
Joined: Sun Aug 25, 2019 10:26 am

Thread communication between ProcessSample/UI

Post by arbuxMusic »

The UI update and SampleProcess calls are documented as performing on different threads. However, the sample modules in the developer kit don't provide any explicit synchronisation of variables for inter-thread communication.

On the one hand, that's great for performance. On the other hand, presumably it may lead to concurrency issues (particularly given that double/long are guaranteed to be updated atomically).

For example, if I want to display a near-realtime waveform buffer screen update based on sample input, is there any recommended good practice on how to write to the buffer (ProcessSample without blocking) and read the waveform (from the UI thread every N milliseconds - hence the need for a buffer rather than a single value)? The closest I could see was the Oscilloscope demo module, but that code doesn't explicitly synchronise the values between the threads (aka make sure that the buffer is guaranteed to be written to memory prior to the Gui thread picking it up).

... or is it that I am missing something fundamental in the Modules architecture? :D
Post Reply

Return to “Module Designer”