Developing audio plugin with integrated file player in JUCE

poornima narasimhan
3 min readNov 21, 2019

JUCE is open source (partially) cross platform C++ application framework used for the development of desktop and mobile applications. JUCE is used in particular for the feature rich GUI and plugins. JUCE offers a large set of audio functionality making it a popular framework compared to other similar frameworks. JUCE has support for audio devices ( such as CoreAudio, ASIO, ALSA, JACK, WASAPI, DirectSound), MIDI playback, built-in readers for common audio file formats ( such as WAV, AIFF, FLAC, MP3 and Vorbis). This also provides wrappers for building various types of audio plugin such as VST effects and instruments. You can build VST, VST3, AU, RTAS and AAX format plugins with ease, and host VST and AU plugins inside your own applications

As i write this I would like to thank https://theaudioprogrammer.com/ and JUCE tutorials for providing immense insight into the architecture and development in JUCE.

Interestingly when i was trying to explore JUCE framework and develop audio plugins my intent was to create a standalone plugin in which i can read an audio file, perform some filtering on the same and playback the file. This has to happen in real time and I did not find sufficient example or tutorial encapsulating the same. As i struggled for sometime to get this pipe working I would like to share my learning through this article.The https://theaudioprogrammer.com/ suggest to using https://github.com/jonathonracz/AudioFilePlayerPlugin for audio playback and then connect them using “AudioPluginHost” with the DSP Audio plugin that we create.

Installation and project creation in windows

  • Step 1. I used Visual Studio 2017 for development using JUCE framework.
  • Step 2. Download JUCE 5.4.5 from here and setup JUCE
  • Step 3. Open Projucer and create “Audio Plugin”
  • Step 4. Open your project in Visual Studio and start implementing the same as shown in figure.
  • Step 5. Include “juce_dsp” module in modules section as we will be passing audio through the dsp filter in this example

Create a project “Audio Plugin” with Projucer

https://juce.com/ has detailed tutorials for creating projects with projucer and configuring the same.

ProJucer — JUCE

As we decided to build plugin with DSP filter functionality, add “JUCE_DSP” modules also to the project as shown

Once the project is created there will be 4 files created namely, PluginEditor.h, PluginEditor.cpp, PluginProcessor.h, PluginProcessor.cpp. The UI customisations can be added to PluginEditor.cpp and PluginEditor.h files. I used https://docs.juce.com/master/tutorial_playing_sound_files.html build a simple audio player for opening a wav file, playing audio and stopping playback. This works well and i was able to open audio, play and stop appropriately. The “AudioFormatReaderSource” object connected to “AudioTransportSource” object was used to play the sound. We can loop the file playing as well. All the logic was implemented in “PluginEditor” files.

Audio Player

Now i was interested in feeding this read audio samples to the “DSP module” and was finding ways to do the same. So in the process block of “PluginProcessor” i need to get the samples of audio. The following snippet helped me in achieving the same

void AudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages)

{

auto totalNumInputChannels = getTotalNumInputChannels();

auto totalNumOutputChannels = getTotalNumOutputChannels();

for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)

buffer.clear(i, 0, buffer.getNumSamples());

transportSource.getNextAudioBlock(AudioSourceChannelInfo(buffer));

for (int channel = 0; channel < totalNumInputChannels; ++channel)

{

//DSP Filtering code comes here

}

}

The standalone plugin looks like the following.

Audio Plugin with Integrated File Reader

--

--