SynthLab SDK
|
The SynthLab::SynthFilter 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.
You will need to add the following files for the SynthFilter
Follow the same pattern and start with the class documentation. The SynthFilter:
We'll choose the VACore object (index = 0, see docs for SynthFilter class) and jump to its documentation. There we can find the module strings and mod knob assignments. The ModuleStrings are the two implemented filter types. We'll choose the 2nd order state-variable lowpass filter (SVFLPF2)
Module Strings, zero-indexed for your GUI Control:
We will choose the SVF_LP, which as a zero-indexed string entry is [4]. Next, look at the documentation to find the output data (render) location
From the docs on VAFilterCore:
The SynthFilter processes audio samples rather than rendering them. For the sample code here, we are going to use the wavetable oscillator's output buffer as input samples for the filter. To do this, you will use a helper function form synthfunctions.h that does fast memcpy( ) operations on bulk memory chunks to transfer the audio data from the oscillator output to the filter input. These functions take the following channel count constants:
They use the following constants that you can also use for your buffer access code for better readability:
There are more of these fast-copy helper functions:
Function | Copies Block |
---|---|
copyOutputToInput | from an AudioBuffer output to an AudioBuffer input |
copyInputToOutput | from an AudioBuffer input to an AudioBuffer output |
copyOutputToOutput | from an AudioBuffer output to an AudioBuffer output |
copyOutputToOutput | from an AudioBuffer output to a SynthProcessInfo output (see SynthVoice) |
copyAudioBufferOutputToSynthOutput | from an AudioBuffer output to a SynthProcessInfo output (see SynthEngine) |
copyBufferToInput | same as copyOutputToInput, used with mix buffers and other temporary buffers |
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 filter.
So, we will do the following:
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):
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;
From here you can keep rendering until the note-off message arrives.
Now, experiment with changing the filter parameters (see the FilterParameter documentation to see what you can change). Also, try experimenting with the mod knobs (see SynthLFO tutorial above)