TFruityPlugHost

Declared in : FP_PlugClass (.pas / .h)

This is the class used by the plugin to access the host.
In the following tables, datatypes are represented as follows : (Delphi datatype / C++ datatype).

Methods
Members

Methods

AddWave_32FM_32FS_Ramp This function adds a 32bit floating point mono buffer to a 32bit floating point stereo buffer, with level adjustment and ramping (if necessary). For the LastLVol and LastRVol parameters, declare two floating point variables that are initially set to respectively LVol and RVol. After the first call to this function, you shouldn't change these variables anymore.
Parameters :
        SourceBuffer (pointer / void *) : The mono buffer containing the samples to be added to the destination buffer
        DestBuffer (pointer / void *) : The stereo buffer into which the samples from the source buffer need to be added
        Length (integer / int) : The number of samples in the buffers
        LVol (single / float) : The current volume for the left channel (0..1 or higher)
        RVol (single / float) : The current volume for the right channel (0..1 or higher)
        LastLVol (var single / float &) : The volume will be ramped from this value to LVol.
        LastRVol (var single / float &) : The volume will be ramped from this value to RVol.
Result : none
AddWave_32FS_32FS_Ramp This function adds a 32bit floating point stereo buffer to a 32bit floating point stereo buffer, with level adjustment and ramping (if necessary). For the LastLVol and LastRVol parameters, declare two floating point variables that are initially set to respectively LVol and RVol. After the first call to this function, you shouldn't change these variables anymore.
Parameters :
        SourceBuffer (pointer / void *) : The stereo buffer containing the samples to be added to the destination buffer
        DestBuffer (pointer / void *) : The stereo buffer into which the samples from the source buffer need to be added
        Length (integer / int) : The number of samples in the buffers
        LVol (single / float) : The current volume for the left channel (0..1 or higher)
        RVol (single / float) : The current volume for the right channel (0..1 or higher)
        LastLVol (var single / float &) : The volume will be ramped from this value to LVol.
        LastRVol (var single / float &) : The volume will be ramped from this value to RVol.
Result : none
CloseSample This function closes a sample that was previously opened with LoadSample.
Parameters :
        Handle (TSampleHandle) : The handle of the sample to be closed
Result : none
ComputeLRVol Call this if you want to calculate the left and right channel volume from a pan and volume value
Parameters :
        LVol (var single / float &) : This variable will hold the left channel volume on return
        RVol (var single / float &) : This variable will hold the right channel volume on return
        Pan (single / float) : The pan to be applied to the volume
        Volume (single / float) : The volume which you want the pan to be applied to
Result : none
ComputeLRVol_Old This function has been replaced by ComputeLRVol and shouldn't be used.
Dispatcher Call this to send a message to the host
Parameters :
        Sender (integer / int) : The identification of the plugin to the host. This has to be set to the plugin's HostTag
        ID (integer / int) : The message identification (see Host Dispatcher IDs).
        Index (integer / int)
        Value (integer / int)
Result (integer / int)
DistWave_32FM
This allows a plugin to use the same distortion that's used by the TS404
Parameters :
        DistType (integer/int) : 0 (mono) or 1 (stereo)
        DistThres (integer/int) : 0..10
        SourceBuffer (pointer/void *) : a pointer to the buffer to process
        Length (integer/int) : the number of samples in the buffer (for one channel if stereo)
        DryVol (single/float) : the dry level (0..1)
        WetVol (single/float) : the wet level (0..1)
        Mul (single/float)
Result : none
GetInsBuffer Retrieve a pointer to the insert buffer following the buffer a generator is currently processing in. This function is reserved for the Fruity wrapper (so it may change in the future). Use only from inside Gen_Render.
Parameters :
        Ofs (integer/int) : the offset to the current buffer. 0 means the same buffer as passed to Gen_Render, +1 means next insert track
Result (pointer/void *): a pointer to the buffer
GetMixBuffer Call this to get a pointer to one of the send buffers (like GetSendBuffer). This function can be used by generators ONLY, & only while processing.
Parameters :
        Num (integer/int): an offset to the mixer track assigned to the generator, like +1 or +2. If Num is 0, the function will return the current rendering buffer.
Result (pointer/void *) : a pointer to the buffer, which can be typecast to a PWAV32FS
GetSampleData Retrieves a pointer to the sample data.
Parameters :
        Handle (TSampleHandle) : The handle of the sample (obtained with LoadSample)
        Length (var int / int &) : The number of samples in the sample data buffer
Result (pointer / void *) : a pointer to the sample data
GetSendBuffer Call this to get a pointer to one of the send buffers (see FPD_SetNumSends). Those pointers are variable, please read & use while rendering only. The size of those buffers is the same as the size of the rendering buffer requested to be rendered.
Parameters :
        Num (integer / int) : the index of the send buffer
Result (pointer / void *) : a pointer to the buffer, which can be typecast to a PWAV32FS
GetSampleInfo You can call this method to obtain more information about a certain sample.
Parameters :
        Handle (TSampleHandle) : the handle of the sample to get info for
        Info (PSampleInfo) : a pointer to a structure that will receive the information requested. Don't forget to set the structure's Size member to the size of the structure!
Result : none
GetSampleRegion Get information about a region in a sample.
Parameters :
        Handle (TSampleHandle) : the handle of the sample to get the region information for
        RegionNum (integer / int) : the index of the region, starting from zero
        Region (PSampleRegion) : a record/structure that will hold the region information. Don't forget to set the Size field to a valid value first!
Result : none
GetSongMixingTime Retrieve the current mixing time, in ticks
Result (integer / int) : the current time
GetSongMixingTime_A Get the current mixing time, in ticks. This version is more accurate, with decimals.
Result (double) : the current time
GetSongPlayingTime Ask the host for the current playing time, in ticks (with decimals)
Result (double) : the current playing time
LoadSample Load a sample from file
Parameters :
        Handle (var TSampleHandle / TSampleHandle &) : On return, this will hold the handle for the sample that was just loaded
        FileName (pchar / char *) : The filename of the sample to load. This buffer should be big enough to hold 256 characters (and the trailing zero). On return, the filename that was loaded has been filled in by the host. For example, this could be the filename that the user selected when the FHLS_ShowDialog opcode was sent to the host.
        NeededFormat (PWaveFormatExtensible) : The format you'd like the loaded wave to be. At the moment, only 16bit, 44.1KHz is supported, but fill it in correctly anyway. On return, it will hold the actual format of the loaded wave.
        Flags (integer / int) :
Result (boolean / bool) : If true, the sample has been loaded correctly. If false, the function failed
LockMix This is a function for thread synchronization. When this is called, no more voices shall be created and there will be no more rendering until UnlockMix has been called
Parameters :
Result : none
LockMix_Shared (FL 7.0) Call this to protect processing code to be protected from being processed in multiple threads.
Parameters : none
Result : none
LockPlugin This is an alternative to LockMix. It won't freeze the audio. This function can only be called from the GUI thread! Warning: this function is not very performant, so avoid using it if possible.
Parameters : none
        Sender (integer / int) : the HostTag value for this plugin
Result : none
MIDIOut Send a MIDI out message. Unlike MIDIOut_Delayed, this function immediately sends the message.
Parameters :
        Sender (integer / int) : The identification of the plugin to the host. This has to be set to the plugin's HostTag
        Msg (integer / int) : The midi paramaters and the port. See TMIDIOutMsg for an easier way to work with these. You can cast a TMIDIOutMsg as an integer for this parameter.
Result : none
MIDIOut_Delayed Send a delayed MIDI out message. This message will actually be sent when the MIDI tick has reached the current mixer tick.
Parameters :
        Sender (integer / int) : The identification of the plugin to the host. This has to be set to the plugin's HostTag
        Msg (integer / int) : The midi paramaters and the port. See TMIDIOutMsg for an easier way to work with these. You can cast a TMIDIOutMsg as an integer for this parameter.
Result : none
OnControllerChanged This will be called by an event controller plugin when a controller has changed.
Parameters :
        Sender (integer / int) : The plugin's HostTag member
        Index (integer / int) : The index of the controller that has changed
        Value : The new value for this controller
Result : none
OnHint Let the host show a hint, as specified by the parameters
Parameters :
        Sender (integer / int) : The identification of the plugin to the host. This has to be set to the plugin's HostTag
        Text (pchar / char *) : The text to show as a hint. The plugin is responsible for the memory that holds this text. If your parameter is recordable and/or can be linked to a midi controller, you can add this to the hint. The way to do this is include either or both of "^a" (can link to a midi controller) and "^b" (is recordable) at the beginning of the message. FL Studio then shows one or more icons.
Result : none
OnParamChanged Notify the host that a parameter value has changed
Parameters :
        Sender (integer / int) : The identification of the plugin to the host. This has to be set to the plugin's HostTag
        Index (integer / int) : The parameter index
        Value (integer / int) : The new parameter value.
Result : none
PlugMsg_Delayed Ask for a message to be dispatched to itself when the current mixing tick will be played (to synchronize stuff) (see MsgIn). The message is guaranteed to be dispatched, however it could be sent immediately if it couldn't be buffered (it's only buffered when playing).
Parameters :
        Sender (integer / int) : the plugin's HostTag
        Msg (integer / int) : the message to be sent
Result : none
PlugMsg_Kill Remove a buffered message, so that it will never be dispatched.
Parameters :
        Sender (integer / int) : the plugin's HostTag
        Msg (integer / int) : the previously sent message to be killed
Result : none
PromptEdit

Ask the host to prompt the user for a piece of text.
Parameters :
        x (integer / int) : the horizontal position of the popup window. Set to -1 to have the popup centered horizontally.
        y (integer / int) : the vertical position of the popup window. Set to -1 to have the popup centered vertically.
        SetCaption (pchar / char *) : the caption of the popup window
        s (pchar / char *) : the text typed in by the user will be copied into this string. Set this to a valid string value (like an empty string) when calling the function. It should have room for 256 characters.
        c (var integer / int &) : the user can select a color, which will be returned in this parameter. Set it to -1 if you don't want the user to select a color.
Result (boolean / bool) : if true, the user closed the popup window by clicking OK, else he clicked Cancel (ignore the results in this case).

ResumeOutput Unlocks the mixer thread if it was previously locked with ResumeOutput.
Parameters : none
Result : none
SuspendOutput This is a function for thread synchronization. When this is called, no more voices shall be created and there will be no more rendering until ResumeOutput has been called. Unlike LockMix, this function also stops all sound.
Parameters : none
Result : none
Voice_Release Tell the host the specified voice should be silent (Note Off)
Parameters :
        Sender (integer / int) : The voice tag
Result : none
Voice_Kill Tell the host that the specified voice can be killed (freed from memory)
Parameters :
        Sender (integer / int) : The voice tag
        KillHandle (longbool / BOOL) : if True, it forces Fruity to ask the plugin to destroy its voice, in case the plugin is still using that voice handle. Use False if the handle has been destroyed already by the plugin
Result : none
Voice_ProcessEvent Tell the host that some event has happened concerning the specified voice
Parameters :
        Sender (integer / int) : The voice tag
        EventID (integer / int) : The identification of the event that occurred (see Voice Event ID constants)
        EventValue (integer / int)
        Flags (integer / int)
Result (integer / int)
UnlockMix Unlocks the mix thread if it was previously locked with LockMix
Parameters : none
Result : none
UnlockMix_Shared (FL 7.0) Call this to unlock processing code after a previous call to LockMix_Shared
Parameters : none
Result : none
UnlockPlugin Unlocks the mix thread if it was previously locked with LockPlugin. Warning: this function is not very performant, so avoid using it if possible.
Parameters :
        Sender (integer / int) : the HostTag value for this plugin
Result : none

Members

HostVersion (integer / int) : The version of FL Studio. It is stored in one integer. If the version of FL Studio would be 1.2.3 for example, HostVersion would be 1002003
Flags (integer / int) (not used yet)
AppHandle (THandle / HANDLE) : The handle of the application, to be used when creating windows
WaveTables (array[0..9] of PWaveT / PWaveT[10]) : These are maximum 10 predefined wavetables. For the moment there are only five (sine, triangle, square, saw, analog saw). Each wavetable contains 16384 samples in the range -1.0 to +1.0
Note: these pointers are fixed
TempBuffers

This is an array that holds pointers to temporary mixing buffers. These can be used freely by the plugin when it needs a buffer at some point during mixing. They are guaranteed to hold as many samples as are being processed.
Note : for hybrid generators, the first buffer may be in use already, so only use the others.
Note 2 : these buffers are to be used only during rendering, not to hold data between rendering slices
Note 3: these buffers are contiguous, so you can see TempBuffer[0] as a huge buffer