Base class for audio plugins
audioPlugin is the base class for audio plugins.
In your class definition file, you must subclass your object from
this base class or from the
which inherits from
audioPlugin. Subclassing enables
you to inherit the attributes necessary to generate plugins and access Audio System
To inherit from the
audioPlugin base class
directly, type this syntax as the first line of your class definition
classdef myAudioPlugin < audioPlugin
myAudioPluginis the name of your object.
For a tutorial on designing audio plugins, see Design an Audio Plugin.
|getSampleRate||Get sample rate at which the plugin is run|
|setSampleRate||Set sample rate at which the plugin is run|
Handle. To learn how handle classes affect copy operations, see Object Behavior (MATLAB) in the MATLAB® documentation.
Design a valid basic audio plugin class
A valid audio plugin is one that can be deployed in
a digital audio workstation (DAW) environment. To validate it, use
validateAudioPlugin function. To generate
it, use the
A basic audio plugin inherits from the
but not the
Define a basic audio plugin class that inherits from
classdef myAudioPlugin < audioPlugin end
Add a processing function to your plugin class.
All valid audio plugins include a processing function. For basic
audio plugins, the processing function is named
The processing function is where audio processing occurs. It always
has an output.
classdef myAudioPlugin < audioPlugin methods function out = process(~,in) out = in; end end end
audioPlugin class that uses the
to get the sample rate at which the plugin is run. The plugin in this
simpleStrobe, uses the sample rate to
determine a constant 50 ms strobe period.
classdef simpleStrobe < audioPlugin % simpleStrobe Add audio strobe effect % Add a strobe effect by gain switching between 0 and 1 in % 50 ms increments. Although the input sample rate can change, % the strobe period remains constant. % % simpleStrobe properties: % period - Number of samples between gain switches % gain - Gain multiplier, one or zero % count - Number of samples since last gain switch % % % simpleStrobe methods: % process - Multiply input frame by gain, element by element % reset - Reset count and gain to initial conditions % and get sample rate properties Period = 44100*0.05; Gain = 1; end properties (Access = private) Count = 1; end methods function out = process(plugin,in) for i = 1:size(in,1) if plugin.Count == plugin.Period plugin.Gain = 1 - plugin.Gain; plugin.Count = 1; end in(i,:) = in(i,:)*plugin.Gain; plugin.Count = plugin.Count + 1; end out = in; end function reset(plugin) plugin.Period = floor( getSampleRate(plugin)*0.05 ); plugin.Count = 1; plugin.Gain = 1; end end end