Loading Wavs into plugin while its processing

Hi,
I built a simple convolution plugin, but I’m trying to change the impulse response (that is in a wav file) while it its running. But I’m having synchronization issues between the processor thread and the editor, I’m opening a file chooser in the editor thread and calling a function in the processor to load the new impulse. What is the best way to do this? I tried using locks and flags without success.

You will have to do this on a background thread. Prepare everything in memory, until it is ready to use. Then you set a flag for the processor, which can then hot-swap in processBlock from the old to the new convolution.
It’s best to write it a way, that you can apply the old and the new convolution separately, so you can crossfade the old and the new signal.
HTH

1 Like

Thanks!!! it worked like a charm.

Hi,
First of all, I’m completely new to juce and c++ and this is my first project.
I’m also programming a Convolution Processor and I’m struggling to get the ImpulseResponse (object of class File) I created with the file chooser (in the editor) to use in the Processor. I tried programming a “File getImpulseResponse()” method but I can’t use it in the processor :confused:
Thanks in advance!

You should do it the other way : make your GUI editor call a method on your AudioProcessor subclass which then takes care of switching the file. (Your AudioProcessorEditor should have the member “processor” which you can use to call the audio processor methods.)

An example from an AudioProcessorEditor of mine :

    m_but_import_file.onClick=[this]()
    {

		File initialloc{"C:\\MusicAudio\\sourcesamples"};
		FileChooser chooser("Choose file",initialloc,processor.supportedAudioFormatsFilter());
        if (chooser.browseForFileToOpen())
        {
			processor.setAudioFile(0, chooser.getResult());
       	}
    };

Thank you very much! Seems to work.