Open jamiegibney opened 9 months ago
after a bit of investigation, proposed fix:
replace triple buffers with an Arc<Mutex<Vec<Vec<f64>>>>
, which can be shared between the SpectrumInput
and the analyser. the input side has a write pointer so the buffer can be circular, and the analyser side just needs to average the content of the buffers whenever the next (visual) frame is due. this way, there is no need for a queue and the content of the buffers is always recent. the averaging is also a slightly simpler operation which doesn't require copying any buffers etc.
of course the audio thread cannot block... so perhaps it would be more sensible to have some kind of queue so that no FFT frames are missed. using a circular buffer like this is much faster than a channel though (about 5x in a simple test), so I'll try that for now.
after trying it, this method may not be the best approach. more testing and different techniques are needed.
FFT frames created for the spectrograms are always sent through a triple buffer to the analysers, but only the frame which is most recent for each frame is used in averaging. A queue may be better, so the averaging is still performed, but with all the most recent frames.
This could be a reason for the visual discontinuities and time-based glitches in the spectrograms.