FMOD Engine User Manual 2.03
An instance of an FMOD Studio event.
Playback Control:
Playback Properties:
3D Attributes:
Parameters:
Core:
Profiling:
Callbacks:
General:
Retrieves the 3D attributes.
FMOD_RESULT Studio::EventInstance::get3DAttributes(
FMOD_3D_ATTRIBUTES *attributes
);
See Also: Studio::EventInstance::set3DAttributes
Retrieves the core ChannelGroup.
FMOD_RESULT Studio::EventInstance::getChannelGroup(
ChannelGroup **group
);
Until the event instance has been fully created this function will return FMOD_ERR_STUDIO_NOT_LOADED.
Retrieves the event CPU usage data.
FMOD_RESULT Studio::EventInstance::getCPUUsage(
unsigned int *exclusive,
unsigned int *inclusive
);
CPU time spent processing just this unit during the last update.
CPU time spent processing this unit and all of its input during the last update.
FMOD_INIT_PROFILE_ENABLE with System::init is required to call this function.
Retrieves the event description.
FMOD_RESULT Studio::EventInstance::getDescription(
Studio::EventDescription **description
);
Retrieves the listener mask.
FMOD_RESULT Studio::EventInstance::getListenerMask(
unsigned int *mask
);
See Also: Studio::EventInstance::setListenerMask
Retrieves memory usage statistics.
FMOD_RESULT Studio::EventInstance::getMemoryUsage(
FMOD_STUDIO_MEMORY_USAGE *memoryusage
);
Memory usage statistics are only available in logging builds, in release builds memoryusage will contain zero for all values this function.
Retrieves the minimum and maximum distances for 3D attenuation.
FMOD_RESULT Studio::EventInstance::getMinMaxDistance(
float *min,
float *max
);
Minimum distance.
Maximum distance.
See Also: Studio::EventDescription::getMinMaxDistance
Retrieves a parameter value by unique identifier.
FMOD_RESULT Studio::EventInstance::getParameterByID(
FMOD_STUDIO_PARAMETER_ID id,
float *value,
float *finalvalue = nullptr
);
Automatic parameters always return value as 0 since they can never have their value set from the public API.
finalvalue is the final value of the parameter after applying adjustments due to automation, modulation, seek speed, and parameter velocity to value. This is calculated asynchronously when the Studio system updates.
See Also: Studio::EventInstance::setParameterByID
Retrieves a parameter value by name, including the path if needed.
FMOD_RESULT Studio::EventInstance::getParameterByName(
const char *name,
float *value,
float *finalvalue = nullptr
);
Automatic parameters always return value as 0 since they can never have their value set from the public API.
finalvalue is the final value of the parameter after applying adjustments due to automation, modulation, seek speed, and parameter velocity to value. This is calculated asynchronously when the Studio system updates.
See Also: Studio::EventInstance::setParameterByName
Retrieves the pause state.
FMOD_RESULT Studio::EventInstance::getPaused(
bool *paused
);
Pause state. True if the event instance is paused.
See Also: Studio::EventInstance::setPaused
Retrieves the pitch multiplier.
FMOD_RESULT Studio::EventInstance::getPitch(
float *pitch,
float *finalpitch = nullptr
);
The final combined value returned in finalpitch combines the pitch set using Studio::EventInstance::setPitch with the result of any automation or modulation. The final combined pitch is calculated asynchronously when the Studio system updates.
Retrieves the playback state.
FMOD_RESULT Studio::EventInstance::getPlaybackState(
FMOD_STUDIO_PLAYBACK_STATE *state
);
You can poll this function to track the playback state of an event instance.
If the instance is invalid, then the state will be set to FMOD_STUDIO_PLAYBACK_STOPPED.
See Also: Studio::EventInstance::start, Studio::EventInstance::stop, FMOD_STUDIO_EVENT_CALLBACK_TYPE
Retrieves the value of a built-in property.
FMOD_RESULT Studio::EventInstance::getProperty(
FMOD_STUDIO_EVENT_PROPERTY index,
float *value
);
A default FMOD_STUDIO_EVENT_PROPERTY value means that the Instance is using the value set in Studio and it has not been overridden using Studio::EventInstance::setProperty. Access the default property values through the Studio::EventDescription.
Retrieves the core reverb send level.
FMOD_RESULT Studio::EventInstance::getReverbLevel(
int index,
float *level
);
Core reverb instance index.
See Also: Studio::EventInstance::setReverbLevel
Retrieves the FMOD Studio System.
FMOD_RESULT Studio::EventInstance::getSystem(
Studio::System **system
);
Retrieves the timeline cursor position.
FMOD_RESULT Studio::EventInstance::getTimelinePosition(
int *position
);
See Also: Studio::EventInstance::setTimelinePosition
Retrieves the event instance user data.
FMOD_RESULT Studio::EventInstance::getUserData(
void **userdata
);
This function allows arbitrary user data to be retrieved from this object. See the User Data section of the glossary for an example of how to get and set user data.
Retrieves the volume level.
FMOD_RESULT Studio::EventInstance::getVolume(
float *volume,
float *finalvolume = nullptr
);
The final combined value returned in finalvolume combines the volume set using the public API with the result of any automation or modulation. The final combined volume is calculated asynchronously when the Studio system updates.
See Also: Studio::EventInstance::setVolume
Checks that the EventInstance reference is valid.
bool Studio::EventInstance::isValid()
Retrieves the virtualization state.
FMOD_RESULT Studio::EventInstance::isVirtual(
bool *virtualstate
);
Virtualization state. True if the event instance has been virtualized.
This function checks whether an event instance has been virtualized due to the polyphony limit being exceeded. For more information, see the Virtual Voice System section of the Managing Resources in the Core API chapter.
Allow an event to continue past a sustain point.
FMOD_RESULT Studio::EventInstance::keyOff();
Multiple sustain points may be bypassed ahead of time and the key off count will be decremented each time the timeline cursor passes a sustain point.
This function returns FMOD_ERR_EVENT_NOTFOUND if the event has no sustain points.
See Also: Studio::EventDescription::hasSustainPoint
Marks the event instance for release.
FMOD_RESULT Studio::EventInstance::release();
This function marks the event instance to be released. Event instances marked for release are destroyed by the asynchronous update when they are in the stopped state (FMOD_STUDIO_PLAYBACK_STOPPED).
Generally it is a best practice to release event instances immediately after calling Studio::EventInstance::start, unless you want to play the event instance multiple times or explicitly stop it and start it again later. It is possible to interact with the instance after falling release(), however if the sound has stopped ERR_INVALID_HANDLE will be returned.
See Also: Studio::EventInstance::stop, Studio::EventInstance::getPlaybackState
Sets the 3D attributes.
FMOD_RESULT Studio::EventInstance::set3DAttributes(
const FMOD_3D_ATTRIBUTES *attributes
);
An event's 3D attributes specify its position, velocity and orientation. The 3D attributes are used to calculate 3D panning, doppler and the values of automatic distance and angle parameters.
See Also: Studio::EventInstance::get3DAttributes
Sets the user callback.
FMOD_RESULT Studio::EventInstance::setCallback(
FMOD_STUDIO_EVENT_CALLBACK callback,
FMOD_STUDIO_EVENT_CALLBACK_TYPE callbackmask = FMOD_STUDIO_EVENT_CALLBACK_ALL
);
See Event Callbacks for more information about when callbacks occur.
See Also: Callback Behavior, Studio::EventDescription::setCallback
Sets the listener mask.
FMOD_RESULT Studio::EventInstance::setListenerMask(
unsigned int mask
);
Listener mask.
The listener mask controls which listeners are considered when calculating 3D panning and the values of listener relative automatic parameters.
To create the mask you must perform bitwise OR and shift operations, the basic form is 1 << listener_index ORd together with other required listener indices.
For example to create a mask for listener index 0 and 2 the calculation would be mask = (1 << 0) | (1 << 2), to include all listeners use the default mask of 0xFFFFFFFF.
See Also: Studio::EventInstance::getListenerMask
Sets a parameter value by unique identifier.
FMOD_RESULT Studio::EventInstance::setParameterByID(
FMOD_STUDIO_PARAMETER_ID id,
float value,
bool ignoreseekspeed = false
);
Specifies whether to ignore the parameter's seek speed and set the value immediately.
The value will be set instantly regardless of ignoreseekspeed when the Event playback state is FMOD_STUDIO_PLAYBACK_STOPPED.
If the specified parameter is read only, is an automatic parameter, or is not of type FMOD_STUDIO_PARAMETER_GAME_CONTROLLED, then FMOD_ERR_INVALID_PARAM is returned.
See Also: Studio::EventInstance::setParameterByName, Studio::EventInstance::setParametersByIDs, Studio::EventInstance::getParameterByName, Studio::EventInstance::getParameterByID
Sets a parameter value by unique identifier, looking up the value label.
FMOD_RESULT Studio::EventInstance::setParameterByIDWithLabel(
FMOD_STUDIO_PARAMETER_ID id,
const char *label,
bool ignoreseekspeed = false
);
The label will be set instantly regardless of ignoreseekspeed when the Event playback state is FMOD_STUDIO_PLAYBACK_STOPPED.
If the specified parameter is read only, is an automatic parameter or is not of type FMOD_STUDIO_PARAMETER_GAME_CONTROLLED then FMOD_ERR_INVALID_PARAM is returned.
If the specified label is not found, FMOD_ERR_EVENT_NOTFOUND is returned. This lookup is case sensitive.
See Also: Studio::EventInstance::setParameterByName, Studio::EventInstance::setParametersByIDs, Studio::EventInstance::getParameterByName, Studio::EventInstance::getParameterByID
Sets a parameter value by name, including the path if needed.
FMOD_RESULT Studio::EventInstance::setParameterByName(
const char *name,
float value,
bool ignoreseekspeed = false
);
Specifies whether to ignore the parameter's seek speed and set the value immediately.
The value will be set instantly regardless of ignoreseekspeed when the Event playback state is FMOD_STUDIO_PLAYBACK_STOPPED.
If the specified parameter is read only, is an automatic parameter or is not of type FMOD_STUDIO_PARAMETER_GAME_CONTROLLED then FMOD_ERR_INVALID_PARAM is returned.
If the event has no parameter matching name then FMOD_ERR_EVENT_NOTFOUND is returned.
See Also: Studio::EventInstance::setParameterByID, Studio::EventInstance::setParametersByIDs, Studio::EventInstance::getParameterByName, Studio::EventInstance::getParameterByID
Sets a parameter value by name, including the path if needed, looking up the value label.
FMOD_RESULT Studio::EventInstance::setParameterByNameWithLabel(
const char *name,
const char *label,
bool ignoreseekspeed = false
);
The label will be set instantly regardless of ignoreseekspeed when the Event playback state is FMOD_STUDIO_PLAYBACK_STOPPED.
If the specified parameter is read only, is an automatic parameter or is not of type FMOD_STUDIO_PARAMETER_GAME_CONTROLLED then FMOD_ERR_INVALID_PARAM is returned.
If the event has no parameter matching name then FMOD_ERR_EVENT_NOTFOUND is returned.
If the specified label is not found, FMOD_ERR_EVENT_NOTFOUND is returned. This lookup is case sensitive.
See Also: Studio::EventInstance::setParameterByID, Studio::EventInstance::setParametersByIDs, Studio::EventInstance::getParameterByName, Studio::EventInstance::getParameterByID
Sets multiple parameter values by unique identifier.
FMOD_RESULT Studio::EventInstance::setParametersByIDs(
const FMOD_STUDIO_PARAMETER_ID *ids,
float *values,
int count,
bool ignoreseekspeed = false
);
Number of items in the given arrays.
Specifies whether to ignore the parameter's seek speed and set the value immediately.
All values will be set instantly regardless of ignoreseekspeed when the Event playback state is FMOD_STUDIO_PLAYBACK_STOPPED.
If any ID is set to all zeroes then the corresponding value will be ignored.
See Also: Studio::EventInstance::setParameterByName, Studio::EventInstance::setParameterByID, Studio::EventInstance::getParameterByName, Studio::EventInstance::getParameterByID
Sets the pause state.
FMOD_RESULT Studio::EventInstance::setPaused(
bool paused
);
The desired pause state. True = paused, False = unpaused.
This function allows pausing/unpausing of an event instance.
See Also: Studio::EventInstance::getPaused
Sets the pitch multiplier.
FMOD_RESULT Studio::EventInstance::setPitch(
float pitch
);
Pitch multiplier.
The pitch multiplier is used to modulate the event instance's pitch. The pitch multiplier can be set to any value greater than or equal to zero but the final combined pitch is clamped to the range [0, 100] before being applied.
See Also: Studio::EventInstance::getPitch
Sets the value of a built-in property.
FMOD_RESULT Studio::EventInstance::setProperty(
FMOD_STUDIO_EVENT_PROPERTY index,
float value
);
This will override the value set in Studio. Using the default FMOD_STUDIO_EVENT_PROPERTY value will revert back to the default values set in Studio.
An FMOD spatializer or object spatializer may override the values set for FMOD_STUDIO_EVENT_PROPERTY_MINIMUM_DISTANCE and FMOD_STUDIO_EVENT_PROPERTY_MAXIMUM_DISTANCE.
See Also: Studio::EventInstance::getProperty
Sets the core reverb send level.
FMOD_RESULT Studio::EventInstance::setReverbLevel(
int index,
float level
);
Core reverb instance index.
Reverb send level.
This function controls the send level for the signal from the event instance to a core reverb instance.
See Also: Studio::EventInstance::getReverbLevel, Working with Reverb
Sets the timeline cursor position.
FMOD_RESULT Studio::EventInstance::setTimelinePosition(
int position
);
Timeline position.
See Also: Studio::EventInstance::getTimelinePosition
Sets the event instance user data.
FMOD_RESULT Studio::EventInstance::setUserData(
void *userdata
);
This function allows arbitrary user data to be attached to this object. See the User Data section of the glossary for an example of how to get and set user data.
See Also: Studio::EventInstance::getUserData
Sets the volume level.
FMOD_RESULT Studio::EventInstance::setVolume(
float volume
);
Volume.
This volume is applied as a scaling factor for the event volume. It does not override the volume level set in FMOD Studio, nor any internal volume automation or modulation.
See Also: Studio::EventInstance::getVolume
Starts playback.
FMOD_RESULT Studio::EventInstance::start();
If the instance was already playing then calling this function will restart the event.
Generally it is a best practice to call Studio::EventInstance::release on event instances immediately after starting them, unless you want to play the event instance multiple times or explicitly stop it and start it again later.
See Also: Studio::EventInstance::stop, Sample Data Loading
Stops playback.
FMOD_RESULT Studio::EventInstance::stop(
FMOD_STUDIO_STOP_MODE mode
);
See Also: Studio::EventInstance::start
Callback that is fired when a Studio::EventInstance changes state.
FMOD_RESULT F_CALL FMOD_STUDIO_EVENT_CALLBACK(
FMOD_STUDIO_EVENT_CALLBACK_TYPE type,
FMOD_STUDIO_EVENTINSTANCE *event,
void *parameters
);
The data passed to the callback function in the parameters argument varies based on the callback type. See FMOD_STUDIO_EVENT_CALLBACK_TYPE for more information.
Return FMOD_OK from the callback unless you wish to signal that there is an error. Select an appropriate error code from FMOD_RESULT. Returning an error will result in a warning or error message being logged.
The 'event' argument Can be cast to Studio::EventInstance *.
See Also: Callback Behavior, Studio::EventInstance::setCallback, Studio::EventDescription::setCallback, Studio::System::getSoundInfo, FMOD_STUDIO_EVENT_CALLBACK_TYPE, FMOD_STUDIO_PROGRAMMER_SOUND_PROPERTIES
Studio event callback types.
#define FMOD_STUDIO_EVENT_CALLBACK_CREATED 0x00000001
#define FMOD_STUDIO_EVENT_CALLBACK_DESTROYED 0x00000002
#define FMOD_STUDIO_EVENT_CALLBACK_STARTING 0x00000004
#define FMOD_STUDIO_EVENT_CALLBACK_STARTED 0x00000008
#define FMOD_STUDIO_EVENT_CALLBACK_RESTARTED 0x00000010
#define FMOD_STUDIO_EVENT_CALLBACK_STOPPED 0x00000020
#define FMOD_STUDIO_EVENT_CALLBACK_START_FAILED 0x00000040
#define FMOD_STUDIO_EVENT_CALLBACK_CREATE_PROGRAMMER_SOUND 0x00000080
#define FMOD_STUDIO_EVENT_CALLBACK_DESTROY_PROGRAMMER_SOUND 0x00000100
#define FMOD_STUDIO_EVENT_CALLBACK_PLUGIN_CREATED 0x00000200
#define FMOD_STUDIO_EVENT_CALLBACK_PLUGIN_DESTROYED 0x00000400
#define FMOD_STUDIO_EVENT_CALLBACK_TIMELINE_MARKER 0x00000800
#define FMOD_STUDIO_EVENT_CALLBACK_TIMELINE_BEAT 0x00001000
#define FMOD_STUDIO_EVENT_CALLBACK_SOUND_PLAYED 0x00002000
#define FMOD_STUDIO_EVENT_CALLBACK_SOUND_STOPPED 0x00004000
#define FMOD_STUDIO_EVENT_CALLBACK_REAL_TO_VIRTUAL 0x00008000
#define FMOD_STUDIO_EVENT_CALLBACK_VIRTUAL_TO_REAL 0x00010000
#define FMOD_STUDIO_EVENT_CALLBACK_START_EVENT_COMMAND 0x00020000
#define FMOD_STUDIO_EVENT_CALLBACK_NESTED_TIMELINE_BEAT 0x00040000
#define FMOD_STUDIO_EVENT_CALLBACK_ALL 0xFFFFFFFF
Callbacks are called from the Studio Update Thread in default / async mode and the main (calling) thread in synchronous mode.
If using FMOD_STUDIO_INIT_DEFERRED_CALLBACKS, FMOD_STUDIO_EVENT_CALLBACK_TIMELINE_MARKER and FMOD_STUDIO_EVENT_CALLBACK_TIMELINE_BEAT are instead called from the main thread.
See Also: Callback Behavior, Studio::EventDescription::setCallback, Studio::EventInstance::setCallback, FMOD_STUDIO_EVENT_CALLBACK
These definitions describe built-in event properties.
typedef enum FMOD_STUDIO_EVENT_PROPERTY {
FMOD_STUDIO_EVENT_PROPERTY_CHANNELPRIORITY,
FMOD_STUDIO_EVENT_PROPERTY_SCHEDULE_DELAY,
FMOD_STUDIO_EVENT_PROPERTY_SCHEDULE_LOOKAHEAD,
FMOD_STUDIO_EVENT_PROPERTY_MINIMUM_DISTANCE,
FMOD_STUDIO_EVENT_PROPERTY_MAXIMUM_DISTANCE,
FMOD_STUDIO_EVENT_PROPERTY_COOLDOWN,
FMOD_STUDIO_EVENT_PROPERTY_MAX
} FMOD_STUDIO_EVENT_PROPERTY;
Priority to set on Core API Channels created by this event instance, 0 for most important, 256 for least important, and -1 for default.
Schedule delay in DSP clocks, or -1 for default.
Schedule look-ahead on the timeline in DSP clocks, or -1 for default.
Override the event's 3D minimum distance, or -1 for default.
Override the event's 3D maximum distance, or -1 for default.
Override the event's cooldown, or -1 for default.
A property that returns a value of -1 from Studio::EventInstance::getProperty means it will use the values set in Studio, use Studio::EventInstance::setProperty to override these values. You can revert the properties value to default by setting it to -1.
Describes a DSP plug-in instance.
typedef struct FMOD_STUDIO_PLUGIN_INSTANCE_PROPERTIES {
const char *name;
FMOD_DSP *dsp;
} FMOD_STUDIO_PLUGIN_INSTANCE_PROPERTIES;
This data is passed to the event callback function when type is FMOD_STUDIO_EVENT_CALLBACK_PLUGIN_CREATED or FMOD_STUDIO_EVENT_CALLBACK_PLUGIN_DESTROYED.
The dsp argument can be cast to FMOD::DSP *.
See Also: FMOD_STUDIO_EVENT_CALLBACK
Describes a programmer sound.
typedef struct FMOD_STUDIO_PROGRAMMER_SOUND_PROPERTIES {
const char *name;
FMOD_SOUND *sound;
int subsoundIndex;
} FMOD_STUDIO_PROGRAMMER_SOUND_PROPERTIES;
This data is passed to the event callback function when type is FMOD_STUDIO_EVENT_CALLBACK_CREATE_PROGRAMMER_SOUND or FMOD_STUDIO_EVENT_CALLBACK_DESTROY_PROGRAMMER_SOUND.
When the callback type is FMOD_STUDIO_EVENT_CALLBACK_CREATE_PROGRAMMER_SOUND the callback should fill in the sound and subsoundIndex fields. The provided sound should be created with the FMOD_LOOP_NORMAL mode bit set. FMOD will set this bit internally if it is not set, possibly incurring a performance penalty. The subsound index should be set to the subsound to play, or -1 if the provided sound should be used directly.
When the callback type is FMOD_STUDIO_EVENT_CALLBACK_DESTROY_PROGRAMMER_SOUND the sound in sound should be cleaned up.
sound can be cast to/from FMOD::Sound *.
See Also: FMOD_STUDIO_EVENT_CALLBACK
Stop modes.
typedef enum FMOD_STUDIO_STOP_MODE {
FMOD_STUDIO_STOP_ALLOWFADEOUT,
FMOD_STUDIO_STOP_IMMEDIATE
} FMOD_STUDIO_STOP_MODE;
See Also: Studio::EventInstance::stop, Studio::Bus::stopAllEvents
Describes a beat on the timeline.
typedef struct FMOD_STUDIO_TIMELINE_BEAT_PROPERTIES {
int bar;
int beat;
int position;
float tempo;
int timesignatureupper;
int timesignaturelower;
} FMOD_STUDIO_TIMELINE_BEAT_PROPERTIES;
This data is passed to the event callback function when type is FMOD_STUDIO_EVENT_CALLBACK_TIMELINE_BEAT.
Nested events do not trigger this callback. Instead, see FMOD_STUDIO_EVENT_CALLBACK_NESTED_TIMELINE_BEAT.
See Also: FMOD_STUDIO_EVENT_CALLBACK
Describes a marker on the timeline.
typedef struct FMOD_STUDIO_TIMELINE_MARKER_PROPERTIES {
const char *name;
int position;
} FMOD_STUDIO_TIMELINE_MARKER_PROPERTIES;
This data is passed to the event callback function when type is FMOD_STUDIO_EVENT_CALLBACK_TIMELINE_MARKER.
See Also: Studio::EventDescription::setCallback, Studio::EventInstance::setCallback
Describes a beat on the timeline from a nested event.
typedef struct FMOD_STUDIO_TIMELINE_NESTED_BEAT_PROPERTIES {
FMOD_GUID eventid;
FMOD_STUDIO_TIMELINE_BEAT_PROPERTIES properties;
} FMOD_STUDIO_TIMELINE_NESTED_BEAT_PROPERTIES;
This data is passed to the event callback function when type is FMOD_STUDIO_EVENT_CALLBACK_NESTED_TIMELINE_BEAT.
See Also: FMOD_STUDIO_EVENT_CALLBACK, FMOD_STUDIO_EVENT_CALLBACK_TIMELINE_BEAT