MIDI Synthesiser in plugin (not App)

This is probably a noob question. I’ve been using JUCE for a little while and made a few small plugins. I’ve done the Sine Wave Synth and MIDI Synth tutorials - What I really am trying to build is a plugin synth (not an App, no keyboard).

Most of the classes are the same. The sticky bit is in processBlock where the MIDI input needs to get to the AudioSource (actually the Synthesiser inside it), then the audio comes back.

I did a crude hack which seems to work, but there is probably a better way.
I added a method to [My]AudioSource which temporarily saves a pointer to a MidiBuffer. So,

  • processBlock creates AudioSourceChannelInfo from its parameters
  • processBlock calls the [My]AudioSource save method with MidiBuffer
  • processBlock calls [My]AudioSource.getNextAudioBlock(), which uses its saved MidiBuffer and updates the AudioSourceChannelInfo.

Any thoughts welcome.

1 Like

You don’t need the AudioSource intermediary class at all in a plugin. Your AudioProcessor subclass can just directly have the Synthesiser object and pass the audio and MIDI buffers into it from processBlock. I am actually a bit perplexed why even the stand alone based tutorials have the seemingly redundant AudioSource class involved.


Makes sense to me. I will try it. Thanks.

1 Like

Works perfectly, of course. Much cleaner and simpler.

1 Like

Just got my very simple drawbar organ VST3 plugin working!