So, I’ve been using JUCE for a couple of months to make an audio plug-in for my university project. It is something like an harmonizer and I have a small latency problem. Let me explain the details:
I use an open source library which is called SoundTouch for pitch shifting. The way it works is: you create a SoundTouch object (I think I should explain how it works before I ask my question), you input the sampleRate, the pitch shift factor etc. and input the audio data. It gives the output from an output buffer when it’s done with processing.
From the beggining, i had some problems with latency but I always thought it was because of Windows and when i would run it with ASIO on FL Studio, it would be better. Today, I finally could try that but unfortunately there is still some latency. (I believe I have correctly set up the ASIO drivers etc.) Today, after some debugging, I think I have an idea about why this may be.
In my processBlock, I do something like the following:
But what I noticed today is, the number of ready output samples from the SoundTouch object is always bigger than my output buffer size and sometimes even 2 or 3 times so. Of course, then i tried to put all the ready samples to the output buffer but I had an assertion error and I guess that’s not how audio buffers work
So yeah, sorry about the lengthy post. Do you have any idea about what i can do about this? Can I for example make my output buffer size larger while keeping my input buffer size the same (so that i wont have extra delay waiting for the input buffer to be full)?