I am getting a lot of distortion utilizing AudioProcessor's processBlock() function and was wondering if I could get some pointers.
Currently my processBlock() function is empty such that the AudioSampleBuffer parameter will just "pass through" as I test the latency. When timing the delta between calls of processBlock() the resulting latency times are greater than the latency times reported by AudioDeviceSelectorComponent's buffer size dropdown.
I am writing a stand-alone application that processes audio in real-time (or as close to real-time that I can get). I have derived a class from AudioProcessor, instantiated an object of AudioProcessPlayer, and set an object of my AudioProcessor class using AudioProcessorPlayer's setProcessor(). I am able to successfully process audio data coming into the processBlock() function.
I am using a USB 2.0 audio interface set to a sample rate of 48 kHz and a buffer size of 64 samples.
Utilizing the AudioDeviceSelectorComponent, I can set the application's buffer size no lower than 144. The dropdown for the 144 buffer size option displays a latency of 3 milliseconds. At this setting the audio output is heavily distorted and rather bit-smashed.
Calculating the timing delta between calls of my empty processBlock() at the above setting yields a latency of 5.002 milliseconds, which is higher than what the AudioDeviceSelectorComponent displays for the 144 buffer size setting. All of my timings show that buffer sizes from 144 to 288 (inclusive) have a greater latency than what is displayed in the AudioDeviceSelectorComponent buffer size drop down.
It isn't until I select a buffer setting of 320 or greater from within AudioDeviceSelectorComponent that the audio output sounds clear. Also the timing delta between calls of processBlock() at these settings (320 or higher) results in a latency calculation that matches what is reported by AudioDeviceSelectorComponent.
Is it safe to assume the distortion and bit-smashing is occurring due to the timing discrepancies? If so, what could be causing the timing discrepancies at these lower buffer settings (144 - 288)?
Thank you for any insight you can provide.