![]() |
fsh::stk
fantastic spatial holophonic synthesis toolkit
|
The base class for all fsh::stk plugins. More...
#include <Processor.h>
Classes | |
struct | Config |
The input/output configuration struct for the plugin. This is passed to the constructor. More... | |
Public Member Functions | |
Processor (const Config &conf) | |
Construct a plugin instance. | |
bool | isBusesLayoutSupported (const BusesLayout &layouts) const override |
Used to tell the DAW whether a given channel layout is supported by the plugin. | |
void | prepareToPlay (double sampleRate, int maxSamplesPerBlock) override |
Called by the DAW when the user starts playback. | |
void | releaseResources () override |
Called by the DAW when the user stops playback. | |
const juce::String | getName () const override |
Get the plugin name (as specified in the JUCE project settings) | |
double | getTailLengthSeconds () const override |
Return the plugin's audio tail length. The default implementation returns 0.0. | |
bool | hasEditor () const override |
Returns whether the plugin has an editor. (It does, by default.) | |
virtual std::unique_ptr< juce::AudioProcessorEditor > | customEditor () |
Provide custom editor instead of GenericAudioProcessorEditor. | |
bool | acceptsMidi () const override |
Returns whether the plugin accepts MIDI input (as specified in the JUCE project settings) | |
bool | producesMidi () const override |
Returns whether the plugin produces MIDI output (as specified in the JUCE project settings) | |
bool | isMidiEffect () const override |
Returns whether the plugin is a MIDI effect (as specified in the JUCE project settings) | |
int | getNumPrograms () override |
Returns the number of programs (presets) supported by the plugin. | |
int | getCurrentProgram () override |
Returns the index of the current program (preset). | |
const juce::String | getProgramName (int) override |
Returns the name of the program at the given index. | |
void | setCurrentProgram (int) override |
Returns the name of the current program (preset). | |
void | changeProgramName (int, const juce::String &) override |
Renames the program at the given index. | |
void | getStateInformation (juce::MemoryBlock &destData) override |
Saves the entire plugin state to a binary blob. | |
void | setStateInformation (const void *data, int sizeInBytes) override |
Recalls the entire plugin state from a (valid) binary blob. | |
Protected Attributes | |
StateManager | _params |
Use this to access the plugin's parameters. | |
The base class for all fsh::stk plugins.
PluginBase provides a default implementation for all methods of juce::AudioProcessor, except processBlock(), which is always required for a plugin to work. It also provides a default implementation for getStateInformation() and setStateInformation(), so plugins can save/recall state and presets out of the box, and provides a default GUI editor.
To create a plugin, all you have to do is create two classes and override one method:
PluginState
class that inherits from StateManager,PluginProcessor
class that inherits from Processor<PluginState>
.You will need to specify the number of outputs (and optionally inputs) in the constructor. Do this inside your child class constructor, so your own class can have a default constructor with no parameters.
processBlock()
method in the child class, andmain.cpp
file with a boilerplate main function (see existing plugins).That's it!
In many cases you will need to override additional methods, such as prepareToPlay() if you have components that need to know the sample rate or buffer size.
The default implementation creates a juce::GenericAudioProcessorEditor
, which will display an unstyled list of your plugin's parameters. This is good enough to start, but if you want to create a custom editor, you will need to override customEditor(), e.g.:
The JUCE tutorials/docs describe how editors work in detail.
|
inlineoverride |
Renames the program at the given index.
The default implementation has no effect, as no programs are implemented.
|
inlinevirtual |
Provide custom editor instead of GenericAudioProcessorEditor.
Override this if you have a custom editor. It will get passed to the base class's createEditor() method. This wrapper is here to prevent accidental memory leaks.
|
inlineoverride |
Returns the index of the current program (preset).
The default implementation returns 0, as no programs are implemented.
|
inlineoverride |
Returns the number of programs (presets) supported by the plugin.
The default implementation returns 1, even though no presets are impleneted, since some DAWs don't like it when you return 0 (or so the JUCE documentation says).
|
inlineoverride |
Returns the name of the program at the given index.
The default implementation returns "unnamed". (Some plugin validators will complain if we return an empty string.)
|
inlineoverride |
Saves the entire plugin state to a binary blob.
You will not need to override this method, or call it directly. This method is called by the DAW when the user saves a project or preset.
|
inlineoverride |
Used to tell the DAW whether a given channel layout is supported by the plugin.
The default implementation checks whether the number of inputs/outputs matches the configuration passed to it, but you may choose to override this if you have a more complex setup.
|
inlineoverride |
Called by the DAW when the user starts playback.
The default implementation does nothing, but you may choose to override this if you have components that need to know the sample rate or buffer size. Note that maxSamplesPerBlock is the maximum number of samples that can be passed to your processBlock() method, but the actual number of samples may be less. Logic Pro, for example, always returns 1024 samples, even if the actual buffer size is less. The only reliable way to know the actual number of samples is to check the size of the AudioBuffer object in processBlock().
|
inlineoverride |
Called by the DAW when the user stops playback.
The default implementation does nothing, but you may choose to override this if you have components that need to release resources at the end of a playback cycle.
|
inlineoverride |
Returns the name of the current program (preset).
The default implementation has no effect, as no programs are implemented.
|
inlineoverride |
Recalls the entire plugin state from a (valid) binary blob.
You will not need to override this method, or call it directly. This method is called by the DAW when the user recalls a project or preset.
|
protected |
Use this to access the plugin's parameters.
This is an instance of the PluginState object that is passed as a template parameter to PluginBase.