If you have set up tempo markers in your FMOD Event or set up normal destination markers you can get time related information about the Event or a trigger when the cursor reaches a marker in the Timeline by using event callbacks.
Here is an example the prints prints “beat!” on every beat of the Event:
extends Node3D
var callable: Callable = Callable(self, "beat_callback")
@export var event: EventAsset
var instance: EventInstance
func _ready():
instance = FMODRuntime.create_instance(event)
instance.start()
instance.set_callback(callable, FMODStudioModule.FMOD_STUDIO_EVENT_CALLBACK_TIMELINE_BEAT)
func beat_callback(args):
if args.properties.beat:
print("beat!")
To stop the callback from running you would pass null
to set_callback
:
instance.set_callback(null, FMODStudioModule.FMOD_STUDIO_EVENT_CALLBACK_ALL)
For markers the process is the same, but you would pass FMODStudioModule.FMOD_STUDIO_EVENT_CALLBACK_TIMELINE_MARKER
to set_callback
:
extends Node3D
var callable: Callable = Callable(self, "marker_callback")
@export var event: EventAsset
var instance: EventInstance
func _ready():
instance = FMODRuntime.create_instance(event)
instance.start()
instance.set_callback(callable, FMODStudioModule.FMOD_STUDIO_EVENT_CALLBACK_TIMELINE_MARKER)
func marker_callback(args):
print("Marker: " + args.properties.name + " at position: " + str(args.properties.position))
Naturally, you can both get information about the timeline beats and markers by passing FMOD_STUDIO_EVENT_CALLBACK_ALL
or both callback types to set_callback
:
extends Node3D
var callable: Callable = Callable(self, "callback")
@export var event: EventAsset
var instance: EventInstance
var type = FMODStudioModule.FMOD_STUDIO_EVENT_CALLBACK_TIMELINE_BEAT | FMODStudioModule.FMOD_STUDIO_EVENT_CALLBACK_TIMELINE_MARKER
func _ready():
instance = FMODRuntime.create_instance(event)
instance.start()
instance.set_callback(callable, type)
func callback(args):
if args.type == FMODStudioModule.FMOD_STUDIO_EVENT_CALLBACK_TIMELINE_BEAT:
print(args.properties.beat)
elif args.type == FMODStudioModule.FMOD_STUDIO_EVENT_CALLBACK_TIMELINE_MARKER:
print("Marker: " + args.properties.name + " at position: " + str(args.properties.position))