The audio thread, timers and other threads


#1

I'm re-architecting my code here for a smoother UI on low power devices. I currently have a FIFO being filled on an `audioDeviceIOCallback`. I also have a Timer which calls a method that analyses the audio for pitch estimation. This timer also updates the GUI. I've realised the GUI update needs to run on a different thread, or vice versa, as currently its waiting for the calculations to finish which is longer than the frame rate on low power devices (it applies smoothing so that it looks smooth even if it doesnt get a new value every frame).

So I'm wondering how best to split things up:

Create another Thread class which performs the calculations, which can then be read by the Timer that updates the GUI.

or do the calculations on the audio thread, performing calculations when there are enough samples in the buffer and then clear and start again, updating the GUI with the Timer (this is what I had going on previously)

 

 

 

 

 


#2

Depends if you need to process all your audio data or if you just want to sample separate intervals. If the latter, then another thread is a good idea.


#3

Yeh definately don't need all the samples, just enough to fill the buffer at each interval to get the pitch estimation for that slice of time... 

Thanks, just wanted to check if I was on the right track.