Issues implementing filter plugins with Sampler application


#1

Hey All,

I'm a longtime 3rd party developer for Kontakt, now making my own sampler. I'm a little bit stuck as to how I'm supposed to implement insert FX for the Sampler.

My sampler needs to have the ability to have different FX on different sample groups. I've managed to get playback working well using the SamplerSound, SamplerVoice, and Synthesiser types, but whenever I try to plug in the basic IIR filter, I get a bunch of glitches/distortion in the sound.

In my AudioSource's getNextAudioBlock() function, I've attempted to apply the filter like so:

for (int i=0; i<bufferToFill.buffer->getNumChannels(); i++){
        filter.processSamples(bufferToFill.buffer->getWritePointer(i), bufferToFill.buffer->getNumSamples());
}

I did see in the documentation that one shouldn't do a bunch of processing in this function, and that doing so will cause glitches. Then where do I apply my processing? I tried subclassing SamplerVoice and implementing it in its renderNextBlock() function, but seeing as how this function is called from the getNextAudioBlock's thread, I am getting the same glitches. 

I was looking into the AudioProcessor API, but I don't understand how I'm supposed to connect my SamplerSounds with the AudioProcessor.

Would anyone care to share some insight?

 


#2

I did see in the documentation that one shouldn't do a bunch of processing in this function, and that doing so will cause glitches.

No, you're misunderstanding that.

It is the right place to do your real-time audio processing, but you mustn't do anything that may block. So avoid locks, memory allocations, GUI code, file access, making any OS calls, etc.. Avoid anything that may take an unpredictable length of time to complete, because that's how glitches happen.


#3

Thanks for setting me straight! After further investigation, the problem was actually more or less detailed in this other thread:

http://www.juce.com/forum/topic/iirfilter-help

I made a separate filter per channel and voila! Thanks for your help.

By the way, although I'm new to developing my own plugins, I'm very experienced with other desktop application frameworks like Qt and GTK, and I have to say that Juce in this regard is by far the most intuitive to me!

Cheers.

 

 


#4

Thanks, glad you're enjoying it!


#5

I was looking into the AudioProcessor API, but I don't understand how I'm supposed to connect my SamplerSounds with the AudioProcessor.

Would anyone care to share some insight?

Take a look at the PluginDemo, it's all there. The sampler instance (= subclass of Synthesiser) should be a member of the AudioProcessor and you simply call its renderNextBlock method from the renderNextBlock() method of the AudioProcessor.