Hello!
I’m looking for some advice for the design of an audio plugin, essentially some indications on what classes would be most appropriate for the few things I have left to implement.
I’m building a plugin that loads an audio clip and shows it in an AudioThumbnail, where I can save subsections within the audio clip. I have the start and end times of every subsection stored in a ValueTree. Here are the main objects, taken from tutorials, that I currently use for audio file loading, visualization and playback:
SamplerAudioProcessor& processor;
AudioDeviceManager& deviceManager;
AudioFormatManager formatManager;
TimeSliceThread thread { "audio file preview" };
File currentAudioFile;
AudioSourcePlayer& sourcePlayer;
AudioTransportSource& transportSource;
std::unique_ptr<AudioFormatReaderSource> currentAudioFileSource;
std::unique_ptr<SamplerThumbnail> thumbnail;
Here’s some of the things I want to have:
- playback of subsections triggered by MIDI notes. For now, I have a “triggerNote” field in the subsection struct, but I haven’t found a way to map it to play the subsection on MIDI events.
- two playback modes: one shot playback, where a noteOn event triggers the playback of the whole subsection; ADSR playback, where, for example, a noteOn event starts the playback of a subsection and a noteOff event cuts it off.
- two interference modes: cut the playback of subsections when subsections are played (exclusive playback), and having subsections play over each other (non exclusive playback).
- use the plugin as an instrument, in order to arrange sequences of subsections in a DAW’s playlist.
I have thought of using an AudioSubsectionReader per subsection. I would have the one AudioFormatReader that holds the initial audio clip, and as many AudioSubsectionReaders reading from the AudioFormatReader as there are subsections. I haven’t thought of the exclusive playback mode yet, but I think a MixerAudioSource that takes a number of AudioTransportSources might be feasible for non exclusive playback. I believe this idea leads to having the subsection & its AudioSubsectionReader being read by an AudioFormatReaderSource being read by an AudioTransportSource being managed by a MixerAudioSource, which seems a little complex.