How to add processing to the output of a synth


#1

I am a beginner struggling to understand how to apply processing to my synth after completing this tutorial: Tutorial: Build a MIDI synthesiser

I followed another tutorial and managed to load a VST plugin. I understand that this gives me an AudioProcessor instance and I should make connections using an AudioProcessorGraph.

My Synth is made of an AudioSource and an AudioSourcePlayer. How can I feed it into the AudioProcessorGraph ?

Are there any examples or docs which cover this scenario?

Edit:
It looks like this scenario is covered by this tutorial Tutorial: Introduction to DSP


#2

If you want the effect applied to your synth output, I would simply load the AudioProcessor in the AudioSource and call processBlock in the AudioSource::getNextAudioBlock() like:

MySynth::getNextAudioBlock (const AudioSourceChannelInfo& info)
{
    // generate your signal
    // ...
    AudioBuffer<float> procBuf (info.buffer->getArrayOfWritePointers(), 
                                info.buffer->getNumChannels(),
                                info.startSample,
                                info.numSamples);
    MidiBuffer midi;
    processor->processBlock (procBuf, midi);
}

And don’t forget to call prepareToPlay and releaseResources…

Caveat: AudioSource and AudioProcessor have the sampleRate and samplesPerBlockExpected in reverse order for no known reason (at least to me).

HTH


#3

It worked! Thank you very much. I do get some audible artefacts (kind of a buzzing) but it does work!


#4

Glad it works…
Buzzing sounds normally hint discontinuities in the signal, either missing samples due to buffer offset errors or worst case that the audio thread didn’t finish in time.
Sometimes debug and release versions can also make a difference, since the optimiser can make up for the missing performance. But if that’s the case it is safe to assume, that in real life setups there will still be problems, since you can never know how good or bad your users systems are…


#5

I figured that that crackling is specific to the “mdaShepard” plugin which I used for testing, you could hear it even when run inside the AudioPluginHost application.
It seems fine with other plug-ins.

Thank you so much for the quick help daniel, it’s greatly appreciated. I am super excited about JUCE now. I plan to build a drum-machine kind of sequencer/sample player.