Skip to content

Wwise GDNative interface

Alessandro Famà edited this page Aug 7, 2023 · 23 revisions

Methods

Return value Signature
bool load_bank(String bank_name)
bool load_bank_id(int bank_id)
bool unload_bank(String bank_id)
bool unload_bank_id(int bank_id)
bool register_listener(Object game_object)
bool register_game_obj(Object game_object, String game_object_name)
bool unregister_game_obj(Object game_object)
bool set_listeners(Object game_object, Object listener)
bool set_3d_position(Object game_object, Transform transform)
bool set_2d_position(Object game_object, Transform2D transform2D, float z_depth)
void set_random_seed(int seed)
int post_event(String event_name, Object game_object)
int post_event_callback(String event_name, int flags, Object game_object, Object cookie)
int post_event_id(int event_id, Object game_object)
int post_event_id_callback(int event_id, int flags, Object game_object, Object cookie)
bool stop_event(int playing_id, int fade_time, int interpolation)
bool set_switch(String switch_group, String switch_state, Object game_object)
bool set_switch_id(int switch_group_id, int switch_state_id, Object game_object)
bool set_state(String state_group, String state_value)
bool set_state_id(int state_group_id, int state_value_id)
float get_rtpc(String rtpc_name, Object game_object)
float get_rtpc_id(int rtpc_id, Object game_object)
bool set_rtpc(String rtpc_name, float rtpc_value, Object game_object)
bool set_rtpc_id(int rtpc_id, float rtpc_value, Object game_object)
bool post_trigger(String trigger_name, Object game_object)
bool post_trigger_id(int trigger_id, Object game_object)
int post_external_source(String event_name, Object game_object, String source_object_name, String file_path, int id_codec)
int post_external_source_id(int event_id, Object game_object, int source_object_id, String file_path, int id_codec)
int get_source_play_position(int playing_id, bool extrapolate)
Dictionary get_playing_segment_info(int playing_id, bool extrapolate)
bool set_game_obj_output_bus_volume(int game_obj_id, int listener_id, float control_value)
bool set_game_obj_aux_send_values(int game_obj_id, Array ak_aux_send_values, int send_values)
bool set_obj_obstruction_and_occlusion(int game_obj_id, int listener_id, float calculated_obs, float calculated_occ)
bool set_geometry(Array vertices, Array triangles, Resource acoustic_texture, float occlusion_value, Object game_object, bool enable_diffraction, bool enable_diffraction_on_boundary_edges, Object associated_room)
bool remove_geometry(Object game_object)
bool register_spatial_listener(Object game_object)
bool set_room(Object game_object, int ak_aux_bus_id, String room_name)
bool remove_room(Object game_object)
bool set_portal(Object game_object, Transform transform, Vector3 extent, Object front_room, Object back_room, bool enabled, String portal_name)
bool remove_portal(Object game_object)
bool set_game_obj_in_room(Object game_object, Object room)
bool remove_game_obj_from_room(Object game_object)
bool set_early_reflections_aux_send(Object game_object, int aux_bus_id)
bool set_early_reflections_volume(Object game_object, float volume)
bool add_output(String share_set, int output_id)
bool remove_output(int output_id)
bool suspend(bool render_anyway)
bool wakeup_from_suspend()

Method descriptions

  • bool load_bank(String bank_name)

Loads a bank with the given bank_name. Calls AK::SoundEngine::LoadBank.

Note: You need to check the Use SoundBank names option in the SoundBank Settings of the authoring application for this to work. Use load_bank_id as the alternative method.

Returns true if bank loading succeeded.


  • bool load_bank_id(int bank_id)

Loads a bank with the given bank_id. Calls AK::SoundEngine::LoadBank.

Note: You need to uncheck the Use SoundBank names option in the SoundBank Settings of the authoring application for this to work. Use load_bank as the alternative method.

Returns true if bank loading succeeded.


  • bool unload_bank(String bank_name)

Unloads a bank with the given bank_name. Calls AK::SoundEngine::UnloadBank.

Note: You need to check the Use SoundBank names option in the SoundBank Settings of the authoring application for this to work. Use unload_bank_id as the alternative method.

Returns true if bank unloading succeeded.


  • bool unload_bank_id(int bank_id)

Unloads a bank with the given bank_id. Calls AK::SoundEngine::UnloadBank.

Note: You need to uncheck the Use SoundBank names option in the SoundBank Settings of the authoring application for this to work. Use unload_bank as the alternative method.

Returns true if bank unloading succeeded.


  • bool register_listener(Object game_object)

Registers a listener with the given game_object.

Returns true if registering succeeded.


  • bool register_game_obj(Object game_object, String game_object_name)

Registers a game object with the given game_object and game_object_name. Calls AK::SoundEngine::RegisterGameObj.

Returns true if registering succeeded.


  • bool unregister_game_obj(Object game_object)

Unregisters a game object with the given game_object. Calls AK::SoundEngine::UnregisterGameObj.

Returns true if unregistering succeeded.


  • bool set_listeners(Object emitter, Object listener)

Associates game object emitter with listener object. Calls AK::SoundEngine::SetListeners.

Returns true if succeded.


  • bool set_3d_position(Object game_object, Transform transform)

Sets the 3D position of the given game_object with the given transform. Calls AK::SoundEngine::SetPosition.

Returns true if positioning succeeded.


  • bool set_2d_position(Object game_object, Transform2D transform2D, float z_depth)

Sets the 3D position of the given game_object with the given transform2D and z_depth. Calls AK::SoundEngine::SetPosition.

Use the z_depth parameter to position the game object on the z-axis.

Returns true if positioning succeeded.


  • void set_random_seed(int seed)

Sets the random seed value. Can be used to synchronize randomness across instances of the Sound Engine. Calls AK::SoundEngine::SetRandomSeed.

This seeds the number generator used for all container randomizations and the plug-in RNG; since it acts globally, this should be called right before any PostEvent call where randomness synchronization is required, and cannot guarantee similar results for continuous containers.


  • int post_event(String event_name, Object game_object)

Posts an Event with the given event_name on the given game_object to the sound engine. Calls AK::SoundEngine::PostEvent.

Returns the playing ID of the Event launched, or 0 if posting the Event failed.


  • int post_event_callback(String event_name, int flags, Object game_object, Object cookie)

Posts an Event (with callbacks) with the given event_name on the given game_object to the sound engine. Pass the AKCallbackType bitmask specified in the AkUtils class to flags. The cookie Object should be a FuncRef instance variable. Set the instance and the function of the FuncRef that should be called by Wwise.

Example:

extends Node

export(AkUtils.AkCallbackType) var callback_type = AkUtils.AkCallbackType.AK_MusicSyncBeat
var cookie:FuncRef
var playing_id = 0

func _ready():
	var register_result = Wwise.register_game_obj(self, "Beat Callback Test")
	print("Registering GameObject: ", register_result)

	cookie = FuncRef.new() # needs to be an instance variable
	cookie.set_instance(self) # instance in which the function should be called
	cookie.set_function("beat_callback") # name of the function
	
	playing_id= Wwise.post_event_callback("TestEvent", callback_type, self, cookie)

func beat_callback(data):
	print(data)
	
func _exit_tree():
	Wwise.stop_event(playing_id, 100, AkUtils.AkCurveInterpolation.LINEAR)
	cookie.free()

Calls AK::SoundEngine::PostEvent.

Returns the playing ID of the Event launched, or 0 if posting the Event failed.


  • int post_event_id(int event_id, Object game_object)

Posts an Event with the given event_id on the given game_object to the sound engine. Calls AK::SoundEngine::PostEvent.

Returns the playing ID of the Event launched, or 0 if posting the Event failed.


  • int post_event_id_callback(String event_name, int flags, Object game_object, Object cookie)

Posts an Event (with callbacks) with the given event_id on the given game_object to the sound engine. Pass the AKCallbackType bitmask specified in the AkUtils class to flags. The cookie Object should be a FuncRef instance variable. Set the instance and the function of the FuncRef that should be called by Wwise.

Example:

extends Node

export(AkUtils.AkCallbackType) var callback_type = AkUtils.AkCallbackType.AK_MusicSyncBeat
var cookie:FuncRef
var playing_id = 0

func _ready():
	var register_result = Wwise.register_game_obj(self, "Beat Callback Test")
	print("Registering GameObject: ", register_result)

	cookie = FuncRef.new() # needs to be an instance variable
	cookie.set_instance(self) # instance in which the function should be called
	cookie.set_function("beat_callback") # name of the function
	
	playing_id= Wwise.post_event_id_callback(AK.EVENTS.MUSIC, callback_type, self, cookie)

func beat_callback(data):
	print(data)
	
func _exit_tree():
	Wwise.stop_event(playing_id, 100, AkUtils.AkCurveInterpolation.LINEAR)
	cookie.free()

Calls AK::SoundEngine::PostEvent.

Returns the playing ID of the Event launched, or 0 if posting the Event failed.


  • bool stop_event(int playing_id, int fade_time, int interpolation)

Stops an Event with the given playing_id. fade_time describes the fade time duration in milliseconds. Pass the AkCurveInterpolation value from the AkUtils class to interpolation. Calls AK::SoundEngine::ExecuteActionOnPlayingID.

Always returns true.


  • bool set_switch(String switch_group, String switch_state, Object game_object)

Sets the given switch_state of the switch_group on the given game_object. Calls AK::SoundEngine::SetSwitch.

Returns true if setting the switch succeeded.


  • bool set_switch_id(int switch_group_id, int switch_state_id, Object game_object)

Sets the given switch_state_id of the switch_group_id on the given game_object. Calls AK::SoundEngine::SetSwitch.

Returns true if setting the switch succeeded.


  • bool set_state(String state_group, String state_value)

Sets the given state_value of the state_group. Calls AK::SoundEngine::SetState.

Returns true if setting the state succeeded.


  • bool set_state_id(int state_group_id, int state_value_id)

Sets the given state_value_id of the state_group_id. Calls AK::SoundEngine::SetState.

Returns true if setting the state succeeded.


  • float get_rtpc(String rtpc_name, Object game_object)

Gets the RTPC value of the given rtpc_name of the game_object. Calls AK::SoundEngine::Query::GetRTPCValue.

Returns the RTPC value if succeeded, 1 if failed.


  • float get_rtpc_id(int rtpc_id, Object game_object)

Gets the RTPC value of the given rtpc_id of the game_object. Calls AK::SoundEngine::Query::GetRTPCValue.

Returns the RTPC value if succeeded, 1 if failed.


  • bool set_rtpc(String rtpc_name, float rtpc_value, Object game_object)

Sets the RTPC rtpc_name with the given rtpc_value on the game_object. Calls AK::SoundEngine::SetRTPCValue.

Returns true if setting the RTPC succeeded.


  • bool set_rtpc_id(int rtpc_id, float rtpc_value, Object game_object)

Sets the RTPC rtpc_id with the given rtpc_value on the game_object. Calls AK::SoundEngine::SetRTPCValue.

Returns true if setting the RTPC succeeded.


  • bool post_trigger(String trigger_name, Object game_object)

Posts a trigger with the given trigger_name on the game_object. Calls AK::SoundEngine::PostTrigger.

Returns true if posting the trigger succeeded.


  • bool post_trigger_id(int trigger_id, Object game_object)

Posts a trigger with the given trigger_id on the game_object. Calls AK::SoundEngine::PostTrigger.

Returns true if posting the trigger succeeded.


  • int post_external_source(String event_name, Object game_object, String source_object_name, String file_path, int id_codec)

Posts an Event with the given event_name with an External Source on the game_object. source_object_name is the Wwise External Source SFX name added through the Contents Editor in the authoring application. file_path refers to the relative file path of the external source specified in the Output Path of the External Sources settings in the authoring application. Pass the AkCodecID value defined in AkUtils class to id_codec. Calls AK::SoundEngine::PostEvent.

Returns the playing ID of the Event launched, or 0 if posting the Event failed.


  • int post_external_source_id(int event_id, Object game_object, int source_object_id, String file_path, int id_codec)

Posts an Event with the given event_id with an External Source on the game_object. source_object_id is the Wwise External Source SFX ID added through the Contents Editor in the authoring application. file_path refers to the relative file path of the external source specified in the Output Path of the External Sources settings in the authoring application. Pass the AkCodecID value defined in AkUtils class to id_codec. Calls AK::SoundEngine::PostEvent.

Returns the playing ID of the Event launched, or 0 if posting the Event failed.


  • int get_source_play_position(int playing_id, bool extrapolate)

Gets the current position of the source associated with the given playing_id, obtained from post_event_callback() or post_event_id_callback(). You need to pass the AK_EnableGetSourcePlayPosition AkCallbackType flag defined in the AkUtils class to use this method. Calls AK::SoundEngine::GetSourcePlayPosition.

Returns the current position of the source if succeeded, 0 if failed.


  • Dictionary get_playing_segment_info(int playing_id, bool extrapolate)

Queries information on the active segment of a music object that is playing, associated with the given playing_id, obtained from post_event_callback() or post_event_id_callback(). You need to pass the AK_EnableGetMusicPlayPosition AkCallbackType flag defined in the AkUtils class to use this method. Calls AK::MusicEngine::GetPlayingSegmentInfo.

Returns a Dictionary with the segment info.


  • bool set_game_obj_output_bus_volume(int game_obj_id, int listener_id, float control_value)

Sets the Output Bus Volume of the given game_object_id. Calls AK::SoundEngine::SetGameObjectOutputBusVolume.

Returns true if setting the Output Bus Volume succeeded.


  • bool set_game_obj_aux_send_values(int game_obj_id, Array ak_aux_send_values, int send_values)

Sets the Auxiliary Busses to route the specified game object with game_obj_id. Pass an Array of Dictionaries to ak_aux_send_values representing environments. The Dictionaries should contain the keys aux_bus_id (the Aux Bus ID) and control_value (float representing the attenuation or amplification factor applied to the volume of the sound going through the auxiliary bus). Pass the number of environments to send_values, 0 to clear the game object's auxiliary send. Calls AK::SoundEngine::SetGameObjectAuxSendValues.

Returns true if succeeded.


  • bool set_obj_obstruction_and_occlusion(int game_obj_id, int listener_id, float calculated_obs, float calculated_occ)

Sets a game object's specified with game_obj_id obstruction and occlusion levels. It's up to you to calculate the calculated_obs and calculated_occ values. Calls AK::SoundEngine::SetObjObstructionAndOcclusion.

Returns true if succeeded.


  • bool set_geometry(Array vertices, Array triangles, Resource acoustic_texture, float occlusion_value, Object game_object, bool enable_diffraction, bool enable_diffraction_on_boundary_edges, Object associated_room)

Adds a set of geometry from the SpatialAudio module for geometric reflection and diffaction processing on the given 'game_object'. vertices should be an Array containing Vertices (Vector3), pass an Array of triangles (int) to triangles. enable_diffraction enables or disables geometric diffraction for this geometry, enable_diffraction_on_boundary_edges enables or disables geometric diffraction on boundary edges for this geometry. Pass the associated_room object if the geometry is inside a room, null if the geometry has a global scope. Doing so reduces the search space for ray casting performed by reflection and diffraction calculations. acoustic_texture is a AkAcousticTexture resource. Pass null here if you don't use acoustic textures. Calls AK::SpatialAudio::SetGeometry.

TODO: AcousticTexture


  • bool remove_geometry(Object game_object)

Removes a set of geometry to the SpatialAudio API. Pass the game_object that was used to register the geometry. Calls AK::SpatialAudio::RemoveGeometry.

Returns true if removing the geometry set succeeded.


  • bool register_spatial_listener(Object game_object)

Registers a spatial audio listener with the given game_object.

Note: There can be only one Spatial Audio listener registered at any given time

Calls AK::SpatialAudio::RegisterListener.

Returns true if registering the spatial audio listener succeeded.


  • bool set_room(Object game_object, int ak_aux_bus_id, String room_name)

Adds a room with the given game_object. Pass the reverb aux bus that is associated with the room to ak_aux_bus_id. Calls AK::SpatialAudio::SetRoom.

Returns true if setting the room succeeded.


  • bool remove_room(Object game_object)

Removes a room with the given game_object. Calls AK::SpatialAudio::RemoveRoom.

Returns true if removing the room succeeded.


  • bool set_portal(Object game_object, Transform transform, Vector3 extent, Object front_room, Object back_room, bool enabled, String portal_name) Adds an acoustic portal with the given game_object at the transform position. extent defines the dimensions of the portal relative to its center. Pass room objects created with set_room to front_room and back_room. enabled defines wheter the portal is active or enabled. Calls AK::SpatialAudio::SetPortal

Returns true if setting the portal succeeded.


  • bool remove_portal(Object game_object)

Removes a portal created previously with set_portal. Calls AK::SpatialAudio::RemovePortal.

Returns true if removing the portal succeeded.


  • bool set_game_obj_in_room(Object game_object, Object room)

Sets the room that the game object is currently located in. Pass a previously registered game object to game_object and the room to room. Calls AK::SpatialAudio::SetGameObjInRoom.

Returns true if setting the game object in a room succeeded.


  • bool remove_game_obj_from_room(Object game_object)

Removes the given game_object from any rooms. Calls AK::SpatialAudio::SetGameObjInRoom.

Returns true if removing the game object from a room succeeded.


  • bool set_early_reflections_aux_send(Object game_object, int aux_bus_id)

Set the given early reflections auxiliary bus aux_bus_id for the particular game object game_object. Calls AK::SpatialAudio::SetEarlyReflectionsAuxSend.

Returns true if setting the early reflections auxiliary bus succeeded.


  • bool set_early_reflections_volume(Object game_object, float volume)

Set the given early reflections send volume volume for the particular game_object. Calls AK::SpatialAudio::SetEarlyReflectionsVolume.

Returns true if setting the early reflections send volume succeeded.


  • bool add_output(String share_set, int output_id)

Adds an output to with the given share_set name and output_id to the sound engine. Calls AK::SoundEngine::AddOutput.

Returns true if adding the output succeeded.


  • bool remove_output(int output_id)

Removes an output with the given output_id. Calls AK::SoundEngine::RemoveOutput.

Returns true if removing the output succeeded.


  • bool suspend(bool render_anyway)

Suspends the sound engine. Set render_anyway to true if your game still runs in backround. Calls AK::SoundEngine::Suspend.

Returns true if suspending the sound engine succeeded.


  • bool wakeup_from_suspend()

Wakes up the sound engine and starts processing audio again. Calls AK::SoundEngine::WakeupFromSuspend.

Returns true if waking up the sound engine succeeded.