ASPiK SDK
Loading...
Searching...
No Matches
AUSynthPlugin Class Reference

The AUSynthPlugin is the ASPiK plugin shell for Audio Units synth plugins. It contains the plugin kernel and all necessary intefaces, implemented as separate C++ obejcts. More...

#include <ausynthplugin.h>

Inheritance diagram for AUSynthPlugin:

Public Member Functions

 AUSynthPlugin (AudioUnit component)
 constructor for plugin object
 
 ~AUSynthPlugin ()
 destructor for plugin object
 
virtual OSStatus Version ()
 
virtual OSStatus Initialize () override
 the AU init function
 
virtual OSStatus GetPropertyInfo (AudioUnitPropertyID inID, AudioUnitScope nScope, AudioUnitElement inElement, UInt32 &outDataSize, bool &outWritable) override
 queries from host about plugin properties
 
virtual OSStatus GetProperty (AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, void *outData) override
 queries from host to get property information
 
virtual OSStatus SetProperty (AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, const void *inData, UInt32 inDataSize) override
 open and close the GUI object
 
virtual OSStatus GetParameterInfo (AudioUnitScope inScope, AudioUnitParameterID inParameterID, AudioUnitParameterInfo &outParameterInfo) override
 get information about each AU parameter that was initialized
 
virtual OSStatus GetPresets (CFArrayRef *outData) const override
 return a static array of preset information structures
 
virtual OSStatus NewFactoryPresetSet (const AUPreset &inNewFactoryPreset) override
 user has selected a new preset
 
virtual bool SupportsTail () override
 
virtual Float64 GetTailTime () override
 
virtual Float64 GetLatency () override
 
virtual OSStatus SetParameter (AudioUnitParameterID inID, AudioUnitScope inScope, AudioUnitElement inElement, AudioUnitParameterValue inValue, UInt32 inBufferOffsetInFrames) override
 this just calls base class
 
virtual OSStatus Render (AudioUnitRenderActionFlags &ioActionFlags, const AudioTimeStamp &inTimeStamp, UInt32 inNumberFrames) override
 first function to be called during buffer process cycle
 
virtual OSStatus Reset (AudioUnitScope inScope, AudioUnitElement inElement) override
 reset function for AU and core
 
virtual OSStatus GetParameterValueStrings (AudioUnitScope inScope, AudioUnitParameterID inParameterID, CFArrayRef *outStrings) override
 get parameter string-lists (for string-list params only)
 
virtual OSStatus RestoreState (CFPropertyListRef inData) override
 called when a user preset is updated; may also be called during init; note the call sequence depends on the host and AULab calls early init functions in a different order that Logic.
 
virtual UInt32 SupportedNumChannels (const AUChannelInfo **outInfo) override
 return an array of AUChannelInfo structures with input and output channel combinations
 
virtual OSStatus HandleNoteOn (UInt8 inChannel, UInt8 inNoteNumber, UInt8 inVelocity, UInt32 inStartFrame) override
 specialized MIDI handler for only this message; CURRENTLY NOT USED, see HandleMidiEvent
 
virtual OSStatus HandleNoteOff (UInt8 inChannel, UInt8 inNoteNumber, UInt8 inVelocity, UInt32 inStartFrame) override
 specialized MIDI handler for only this message; CURRENTLY NOT USED, see HandleMidiEvent
 
virtual OSStatus HandlePitchWheel (UInt8 inChannel, UInt8 inPitch1, UInt8 inPitch2, UInt32 inStartFrame) override
 specialized MIDI handler for only this message; CURRENTLY NOT USED, see HandleMidiEvent
 
virtual OSStatus HandleControlChange (UInt8 inChannel, UInt8 inController, UInt8 inValue, UInt32 inStartFrame) override
 specialized MIDI handler for only this message; CURRENTLY NOT USED, see HandleMidiEvent
 
OSStatus MIDIEvent (UInt32 inStatus, UInt32 inData1, UInt32 inData2, UInt32 inOffsetSampleFrame) override
 specialized MIDI handler to add events to the plugin's queue
 
bool StreamFormatWritable (AudioUnitScope, AudioUnitElement) override
 
bool CanScheduleParameters () const override
 
char * getMyComponentDirectory (CFStringRef bundleID)
 helper function to get a path to the location where THIS library is loaded
 
void setAUParameterChangeEvent (unsigned int controlID, double actualValue)
 safely issue a parameter change event
 
double getAUParameter (unsigned int controlID)
 safely get a parameter value
 

Public Attributes

GUIPluginConnectorguiPluginConnector = nullptr
 GUI -> Plugin interface.
 
PluginHostConnectorpluginHostConnector = nullptr
 Plugin -> Host interface.
 
AUMIDIEventQueuemidiEventQueue = nullptr
 double-buffered-queue for MIDI messaging
 

Protected Member Functions

void initAUParametersWithPluginCore ()
 setup the AU parameter list with the plugin core's parameter list
 
void updateAUParametersWithPluginCore ()
 send parameter update info (metering, output)
 
void updatePluginCoreParameters ()
 set the plugin core parameters from the AU parameters (called during each buffer process cycle)
 
void updateHostInfo (HostInfo *hostInfo)
 set the HostInfo for the core (varies by API)
 

Protected Attributes

PluginCorepluginCore = nullptr
 GUI the plugin core: alive for FULL lifecycle of shell.
 
bool hasSidechain = false
 sidechain flag
 
AudioBufferList * sidechainBufferList = nullptr
 sidechain buffers (if active)
 
int sidechainChannelCount = 0
 num sidechain channels
 
AUChannelInfo * auChannelInfo = nullptr
 the current channel information
 
float ** inputBuffers = nullptr
 de-interleaved incoming audio input buffers
 
float ** outputBuffers = nullptr
 de-interleaved outgoing audio output buffers
 
float ** sidechainInputBuffers = nullptr
 de-interleaved incoming audio sidechain buffers
 
void * presetsArrayData = nullptr
 contiguous memory block for persistent preset data
 
int currentPreset = 0
 current preset's index value
 
Float64 latencyInSeconds = 0
 au latency (seconds!)
 
VSTGUI::PluginGUIpluginGUI = nullptr
 

Detailed Description

The AUSynthPlugin is the ASPiK plugin shell for Audio Units synth plugins. It contains the plugin kernel and all necessary intefaces, implemented as separate C++ obejcts.

NOTES:

  • derived from AUMIDIEffectBase to allow MIDI input/output if desired; it is not necessary to use MIDI but it is bSCAvailable
  • however, AUMIDIEffectBase does not allow exposing a sidechain so we get around this issue by setting the AU effet type to "aufx" even though it is really "aumu" – this will only generate a warning during validation but is otherwise secure.
  • the required interfaces are implemented on member objects that handle the thread-safe transfer of parameter information
Author
Will Pirkle http://www.willpirkle.com
Remarks
This object is included in Designing Audio Effects Plugins in C++ 2nd Ed. by Will Pirkle
Version
Revision : 1.0
Date
Date : 2018 / 09 / 7

Constructor & Destructor Documentation

◆ AUSynthPlugin()

AUSynthPlugin::AUSynthPlugin ( AudioUnit  component)

constructor for plugin object

NOTES:

  • creates core
  • creates ALL ASPiK interfaces
  • sets up AU parameters
  • intitializes AU objecgt

◆ ~AUSynthPlugin()

AUSynthPlugin::~AUSynthPlugin ( )

destructor for plugin object

NOTES:

  • destory core
  • destory all buffers

Member Function Documentation

◆ getAUParameter()

double AUSynthPlugin::getAUParameter ( unsigned int  controlID)

safely get a parameter value

safely get an AU parameter's value

Parameters
controlIDthe AU parameter identifier (same as PluginParameter's controlID)
Returns
the parameter's actualValue
Parameters
controlIDthe AU parameter ID value
Returns
the actual value of the parameter

◆ GetLatency()

virtual Float64 AUSynthPlugin::GetLatency ( )
inlineoverridevirtual

AU override method

◆ getMyComponentDirectory()

char * AUSynthPlugin::getMyComponentDirectory ( CFStringRef  bundleID)
inline

helper function to get a path to the location where THIS library is loaded

Parameters
bundleIDthe bundle ID as a string
Returns
the path as a simple, naked char*

◆ GetParameterInfo()

OSStatus AUSynthPlugin::GetParameterInfo ( AudioUnitScope  inScope,
AudioUnitParameterID  inParameterID,
AudioUnitParameterInfo &  outParameterInfo 
)
overridevirtual

get information about each AU parameter that was initialized

AU override method

NOTES:

  • see Designing Audio Effects in C++ 2nd Ed. by Will Pirkle for more information and an AU Programming Guide
  • see AU SDK for more information on this function and its parameters
  • see Designing Audio Effects in C++ 2nd Ed. by Will Pirkle for more information and an AU Programming Guide
  • https://developer.apple.com/documentation/audiounit

◆ GetParameterValueStrings()

OSStatus AUSynthPlugin::GetParameterValueStrings ( AudioUnitScope  inScope,
AudioUnitParameterID  inParameterID,
CFArrayRef *  outStrings 
)
overridevirtual

get parameter string-lists (for string-list params only)

AU override method

NOTES:

◆ GetPresets()

OSStatus AUSynthPlugin::GetPresets ( CFArrayRef *  outData) const
overridevirtual

return a static array of preset information structures

AU override method

NOTES:

◆ GetProperty()

OSStatus AUSynthPlugin::GetProperty ( AudioUnitPropertyID  inID,
AudioUnitScope  inScope,
AudioUnitElement  inElement,
void *  outData 
)
overridevirtual

queries from host to get property information

AU override method

NOTES:

◆ GetPropertyInfo()

OSStatus AUSynthPlugin::GetPropertyInfo ( AudioUnitPropertyID  inID,
AudioUnitScope  inScope,
AudioUnitElement  inElement,
UInt32 &  outDataSize,
bool &  outWritable 
)
overridevirtual

queries from host about plugin properties

AU override method

NOTES:

◆ HandleControlChange()

OSStatus AUSynthPlugin::HandleControlChange ( UInt8  inChannel,
UInt8  inController,
UInt8  inValue,
UInt32  inStartFrame 
)
overridevirtual

specialized MIDI handler for only this message; CURRENTLY NOT USED, see HandleMidiEvent

AU override method

NOTES:

◆ HandleNoteOff()

OSStatus AUSynthPlugin::HandleNoteOff ( UInt8  inChannel,
UInt8  inNoteNumber,
UInt8  inVelocity,
UInt32  inStartFrame 
)
overridevirtual

specialized MIDI handler for only this message; CURRENTLY NOT USED, see HandleMidiEvent

AU override method

NOTES:

◆ HandleNoteOn()

OSStatus AUSynthPlugin::HandleNoteOn ( UInt8  inChannel,
UInt8  inNoteNumber,
UInt8  inVelocity,
UInt32  inStartFrame 
)
overridevirtual

specialized MIDI handler for only this message; CURRENTLY NOT USED, see HandleMidiEvent

AU override method

NOTES:

◆ HandlePitchWheel()

OSStatus AUSynthPlugin::HandlePitchWheel ( UInt8  inChannel,
UInt8  inPitch1,
UInt8  inPitch2,
UInt32  inStartFrame 
)
overridevirtual

specialized MIDI handler for only this message; CURRENTLY NOT USED, see HandleMidiEvent

AU override method

NOTES:

◆ initAUParametersWithPluginCore()

void AUSynthPlugin::initAUParametersWithPluginCore ( )
protected

setup the AU parameter list with the plugin core's parameter list

set up all AU parameters at once using plugin core's parameters; performed only once

◆ Initialize()

OSStatus AUSynthPlugin::Initialize ( )
overridevirtual

the AU init function

AU override method

NOTES:

  • set the plugin sample rate and bit depth
  • set and store the plugin latency in seconds for AU host queries
  • see Designing Audio Effects in C++ 2nd Ed. by Will Pirkle for more information and an AU Programming Guide
  • see AU SDK for more information on this function and its parameters
  • https://developer.apple.com/documentation/audiounit
Returns
the number of AUChannelInfo structures in the array

◆ MIDIEvent()

OSStatus AUSynthPlugin::MIDIEvent ( UInt32  inStatus,
UInt32  inData1,
UInt32  inData2,
UInt32  inOffsetSampleFrame 
)
override

specialized MIDI handler to add events to the plugin's queue

AU override method

NOTES:

◆ NewFactoryPresetSet()

OSStatus AUSynthPlugin::NewFactoryPresetSet ( const AUPreset &  inNewFactoryPreset)
overridevirtual

user has selected a new preset

AU override method

NOTES:

◆ Render()

OSStatus AUSynthPlugin::Render ( AudioUnitRenderActionFlags &  ioActionFlags,
const AudioTimeStamp &  inTimeStamp,
UInt32  inNumberFrames 
)
overridevirtual

first function to be called during buffer process cycle

AU override method

NOTES:

◆ Reset()

OSStatus AUSynthPlugin::Reset ( AudioUnitScope  inScope,
AudioUnitElement  inElement 
)
overridevirtual

reset function for AU and core

AU override method

NOTES:

  • call base class
  • reset core
  • see Designing Audio Effects in C++ 2nd Ed. by Will Pirkle for more information and an AU Programming Guide
  • see AU SDK for more information on this function and its parameters
  • https://developer.apple.com/documentation/audiounit

◆ RestoreState()

OSStatus AUSynthPlugin::RestoreState ( CFPropertyListRef  inData)
overridevirtual

called when a user preset is updated; may also be called during init; note the call sequence depends on the host and AULab calls early init functions in a different order that Logic.

AU override method

NOTES:

  • just calls base class; additions reserved for future
  • see Designing Audio Effects in C++ 2nd Ed. by Will Pirkle for more information and an AU Programming Guide
  • see AU SDK for more information on this function and its parameters
  • https://developer.apple.com/documentation/audiounit

◆ setAUParameterChangeEvent()

void AUSynthPlugin::setAUParameterChangeEvent ( unsigned int  controlID,
double  actualValue 
)

safely issue a parameter change event

safely set an AU parameter change event

Parameters
controlIDthe AU parameter identifier (same as PluginParameter's controlID)
actualValuethe value to set

NOTES:

◆ SetParameter()

OSStatus AUSynthPlugin::SetParameter ( AudioUnitParameterID  inID,
AudioUnitScope  inScope,
AudioUnitElement  inElement,
AudioUnitParameterValue  inValue,
UInt32  inBufferOffsetInFrames 
)
overridevirtual

this just calls base class

AU override method

NOTES:

  • do not be tempted into using this for plugin core sync; this function should not be modified
  • see Designing Audio Effects in C++ 2nd Ed. by Will Pirkle for more information and an AU Programming Guide
  • see AU SDK for more information on this function and its parameters
  • https://developer.apple.com/documentation/audiounit

◆ SetProperty()

OSStatus AUSynthPlugin::SetProperty ( AudioUnitPropertyID  inID,
AudioUnitScope  inScope,
AudioUnitElement  inElement,
const void *  inData,
UInt32  inDataSize 
)
overridevirtual

open and close the GUI object

AU override method

NOTES:

◆ SupportedNumChannels()

UInt32 AUSynthPlugin::SupportedNumChannels ( const AUChannelInfo **  outInfo)
overridevirtual

return an array of AUChannelInfo structures with input and output channel combinations

AU override method

NOTES:

Returns
the number of AUChannelInfo structures in the array

◆ SupportsTail()

virtual bool AUSynthPlugin::SupportsTail ( )
inlineoverridevirtual

AU override method reply to host query

Returns
TRUE if plugin core wants a tail

◆ updateAUParametersWithPluginCore()

void AUSynthPlugin::updateAUParametersWithPluginCore ( )
protected

send parameter update info (metering, output)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

outoing transfer AU parameter changes (meter data) from the Core

◆ updateHostInfo()

void AUSynthPlugin::updateHostInfo ( HostInfo hostInfo)
protected

set the HostInfo for the core (varies by API)

update this buffer run's incoming host data (BPM, etc...)

Parameters
hostInfoa HostInfo structure to fill with incoming data

◆ updatePluginCoreParameters()

void AUSynthPlugin::updatePluginCoreParameters ( )
protected

set the plugin core parameters from the AU parameters (called during each buffer process cycle)

safely transfer AU parameter changes into the Core

◆ Version()

virtual OSStatus AUSynthPlugin::Version ( )
inlinevirtual

AU override method

Member Data Documentation

◆ latencyInSeconds

Float64 AUSynthPlugin::latencyInSeconds = 0
protected

au latency (seconds!)

VSTGUI4 Editor NOTE: this is only used to open and close the GUI


The documentation for this class was generated from the following files: