The SynthLab::DCA object processes audio samples from its AudioBuffer input array to its AudioBuffer output array. It also reads its modulation input array during the update( ) phase to allow parameter modulation. It is the simplest of the objects in SynthLab and has no cores.
You will need to add the following files for the SynthFilter
Follow the same pattern and start with the class documentation. The DCA:
- uses a DCAParameters structure for control, both GUI and programatically
- reads values from its own AudioBuffer input
- renders values into its own AudioBuffer output
- has no cores - it is too simple an object to warrant it
From the docs on DCA:
- reads from the input buffer
- renders into the output buffer
- renders one block of audio per render cycle
Note that the SynthFilter documentation also shows you how to create the object in standalone mode, we can use this code verbatim because we will setup a blocksize of 64 for this DCA.
DCA(nullptr, nullptr, 64);
So, we will do the following:
- create the DCA and pass nullptr for the MIDI input and parameters arguments
- reset it with the sample rate
- create a MIDI event and call the note-on handler
- use getParameters: set the output gain to +3dB and the pan value to +0.25 (1/4 to the right)
- transfer audio from the filter to the DCA
- call the render function to process the data (send that to your plugin framework output buffer)
- call the note-off handler when note event is done
std::unique_ptr<SynthLab::DCA> dca = nullptr;
nullptr,
64));
dca->reset(44100.0);
std::shared_ptr<SynthLab::DCAParameters> dcaParameters = dca->getParameters();
if (dcaParameters)
{
dcaParameters->gainValue_dB = +3.0;
dcaParameters->panValue = 0.25;
dca->update();
}
Now, in response to a MIDI note-on message, we setup a MIDIEvent structure (NOTE: we added the call to the pitch calculaton prior to the note-on function call):
wtOsc->doNoteOn(midiEvent);
filter->doNoteOn(midiEvent);
dca->doNoteOn(midiEvent);
Now you render values from the oscillator and send them to the filter. Once rendered, you may send the block of data to your plugin framework's output buffers;
wtOsc->render(64);
filter->getAudioBuffers(),
SynthLab::STEREO_TO_STEREO,
64);
filter->render(64);
dca->getAudioBuffers(),
SynthLab::STEREO_TO_STEREO,
64);
dca->render(64);
float* leftOutBuffer = dca->getAudioBuffer()->getOutputBuffer(SynthLab::LEFT_CHANNEL);
float* rightOutBuffer = dca->getAudioBuffer()->getOutputBuffer(SynthLab::RIGHT_CHANNEL);
for (uint32_t i = 0; i < 64; i++)
{
float leftSample = leftOutBuffer[i];
float rightSample = rightOutBuffer[i];
}
From here you can keep rendering until the note-off message arrives.
dca->doNoteOff(midiEvent);
Now, experiment with changing the DCA parameters (see the DCAParameter documentation to see what you can change). Also, try experimenting with the mod knobs (see SynthLFO tutorial above)