TFruityPlug

Declared in : FP_PlugClass (.pas / .h)

TFruityPlug is the plugin. It has some methods and members that are used by the host to do some stuff, such as rendering a voice, retrieving parameter names etc.
In the following tables, datatypes are represented as follows : (Delphi datatype / C++ datatype).

Symbol explanation
(G) called from GUI thread
(M) called from mixer thread
(GM) both GUI and mixer thread
(S) called from MIDI synchronization thread

(GM) calls are normally thread-safe

Methods
Members

Methods

DestroyObject
(G)
This gets called when the host wants to destroy the plugin. You can override it to clean up at that time.
Parameters : none
Result : none
Dispatcher
(GM)
The host calls this function to request something that isn't done in a specialized function.
Parameters :
        ID (integer / int) : the identifier of what the host wants to do (see Dispatcher IDs)
        Index (integer / int)
        Value (integer / int)
Result (integer / int)
Idle
(G)
This gets called by the host when the user isn't doing anything.
Parameters : none
Result : none
SaveRestoreState
(G)
Called to save or restore the state of the plugin. What the state of the plugin is, is up to the plugin developer.
Parameters :
        Stream (IStream / IStream *) : The memory object that is used to save or restore the state
        Save (longbool / BOOL) : If true, the plugin needs to save its state to the stream. If false, the plugin can load its state from the stream.
Result : none
GetName
(GM)
This is called when the host wants to know a text representation of some value.
Parameters :
        Section (integer / int) : See GetName constants
        Index (integer / int) : the index of the parameter
        Value (integer / int)
        Name (pchar / char *) : A pointer to the string that will receive the text representation
Result : none
MIDIIn
(GM)
The host will call this when there's new MIDI data available. This function is only called when the plugin has called the Dispatcher of PlugHost with the id FHD_WantMIDIInput and value 1.
Parameters :
        Msg (var integer / int &) : This is the midi message, encoded into one integer. So from the least significant byte to the most significant byte, the Status, Data byte 1, Data byte 2 and Port values are present. Msg can be typecast into a TMIDIOutMsg to make it easier to work with. To remove the port value from MSG, you can AND Msg with the MIDIMsg_PortMask constant (also see Working with bitfields). If you want to kill the midi message (so it won't be sent any further), set it to MIDI_MsgNull.
Result : none
MIDITick
(S)
This is called before a new midi tick is played (not mixed), if the plugin specified FPF_WantMidiTick in its flags
Parameters : none
Result : none
MsgIn
(S)
This gets called with a new buffered message to the plugin itself.
Parameters:
         Msg (integer / int) :
Result: none
NewTick
(M)
Gets called before a new tick is mixed (not played), if the plugin specified FPF_WantNewTick in its info structure
Parameters : none
Result : none
ProcessEvent
(GM)
Process an event sent by the host
Parameters :
        EventID (integer / int) : The kind of event to be processed (See the Event ID constants)
        EventValue (integer / int)
        Flags (integer / int)
Result (integer / int)
ProcessParam
(GM)
Something has to be done concerning a parameter. What exactly has to be done is explained by the RECFlags parameter.
Parameters :
        Index (integer / int) : The index of the parameter
        Value (integer / int) : The (new) value of the parameter
        RECFlags (integer / int) : Describes what needs to be done to the parameter. It can be a combination of several flags (see ProcessParam flags)
Result (integer / int) : If REC_GetValue is specified in RECFlags, the result has to be the value of the parameter
Eff_Render
(M)
Called by the host to apply an effect to some audio data if the plugin is an effect (FPF_Generator was not specified). The buffers hold the data in interlaced format : left sample 1, then right sample 1, left sample 2, right sample 2, and so on
Parameters :
        SourceBuffer (PWAV32FS) : The buffer that contains the audio data provided by the host
        DestBuffer (PWAV32FS) : The buffer that the plugin places the data in when the effect has been applied to it
        Length (integer / int) : The number of samples in the buffers
Result : none
Gen_Render
(M)
Called by the host to generate a voice for a full generator (FPF_UseSampler was not specified). The buffer hold the data in interlaced format : left sample 1, then right sample 1, left sample 2, right sample 2, and so on
Parameters :
        DestBuffer (PWAV32FS) : The buffer that the plugin places the generated audio data in
        Length (var integer / int &) : The number of samples in the buffers. If the generator creates less samples than this, it needs to set Length to the amount of samples it actually created.
Result : none
TriggerVoice
(GM)
The host calls this to let the host create a voice.
Parameters :
       VoiceParams (PVoiceParams) : A pointer tot the parameters of this voice (see TVoiceParams)
        SetTag (integer / int) : An identifier the host uses to identify the voice
Result (TVoiceHandle) : The function has to return a handle for the voice it has just created. This has to be unique to the plugin. It could be a pointer to a structure that the plugin uses to work with the voice, for example
Voice_Release
(GM)
This gets called by the host when the voice enters the envelope release state (note off)
Parameters :
        Handle (TVoiceHandle) : The voice handle
Result : none
Voice_Kill
(GM)
Called when the voice has to be discarded. The plugin had to release any memory associated with the voice
Parameters :
        Handle (TVoiceHandle) : The voice handle
Result : none
Voice_ProcessEvent
(GM)

Process a voice event (not used yet)
Parameters :
        Handle (TVoiceHandle) : The voice handle
        EventID (integer / int) : The type of voice event (See the Voice Event ID constants)
        EventValue (integer / int)
        Flags (integer / int)
Result (integer / int)

Voice_Render
(GM)
Render a voice (only called when FPF_UseSampler was specified in the info structure)
Parameters :
        Handle (TVoiceHandle) : The voice handle
        DestBuffer (PWAV32FS) : The buffer that the plugin has to put the generated voice data into
        Length (var integer / int &) : The number of samples in the buffer. If the generator creates less samples than this, it needs to set Length to the amount of samples it actually created.
Result (integer / int) : see Voice_Render Function Results

Members

HostTag (integer / int) Free for the host to use (parent object reference, ...). The plugin has to assign the parameter Tag from CreatePlugInstance to it in the constructor of the plugin. When calling host functions (in TFruityPlugHost), this value has to be passed on as "Sender"
Info (PFruityPlugInfo) This has to be set so it points to a valid TFruityPlugInfo structure. This needs to be done before CreatePlugInstance returns, so probably in the constructor of the plugin class.
EditorHandle (HWND) You can set this to the handle of your editor window
MonoRender (not used yet) (LongBool / BOOL) Last rendered voice rendered mono data