GCubeSDK
©2026 FenixFox®Studios

Audio

Audio ⟵ Object3D

Non-positional (global) audio source.
This class inherits from Object3D and plays an AudioBuffer through the listener. Use it for music, UI, and ambient that should not spatialize. Several Audio and AudioEmitter objects can play at the same time. Attach an AudioListener to the camera, load a buffer with AudioLoader, then call setBuffer and play.

InheritanceDiagram node_Audio Audio node_AudioEmitter AudioEmitter node_Audio->node_AudioEmitter node_Object3D Object3D node_Object3D->node_Audio

Methods

Audio(AudioListener* listener)

Constructor bound to the global audio listener

listener The global audio listener

virtual Audio* clone(bool recursive) const override

Creates a copy of this audio object

recursive Whether to clone all child objects as well true

virtual void copy(const Object3D& object, bool recursive) override

Copies properties from another object

object Source object to copy from
recursive Whether to copy all child objects as well true

virtual void update()

Updates playback state (loop / ended) and reapplies volume

Audio* play(f32 delay)

Starts playback of the assigned buffer

delay Start delay in seconds 0.0f

Audio* pause()

Pauses playback. Call play() again to resume

Audio* stop(f32 delay)

Stops playback of the audio

delay Stop delay in seconds (unused) 0.0f

virtual void onEnded()

Automatically called when playback finished

Audio* setBuffer(AudioBuffer* audioBuffer)

Sets the given audio buffer as the source of this instance

audioBuffer Audio buffer to play

Audio* setVolume(f32 value)

Sets the volume

value Volume in the range 0.0 to 1.0

f32 getVolume() const

Returns the volume

Audio* setLoop(bool value)

Sets the loop flag

value Whether the audio should loop

bool getLoop() const

Returns the loop flag

Audio* setLoopStart(f32 value)

Sets where in the buffer the replay should start, in seconds

value Loop start in seconds

Audio* setLoopEnd(f32 value)

Sets where in the buffer the replay should stop, in seconds

value Loop end in seconds

Audio* setPlaybackRate(f32 value)

Sets the playback rate

value Playback rate to set 1.0f

f32 getPlaybackRate() const

Returns the current playback rate

Audio* setDetune(f32 value)

Defines the detuning of oscillation in cents

value Detune in cents

f32 getDetune() const

Returns the detuning of oscillation in cents

virtual void applyVolume()

Applies volume (and spatial gain for AudioEmitter) to this source

void applyHardwareVolume(s32 volumeL, s32 volumeR)

Writes left / right volume to the voice this source uses

volumeL Left channel volume (0 to 255)
volumeR Right channel volume (0 to 255)

s32 gainToHardware(f32 gain) const

Converts a 0.0 to 1.0 gain value to a hardware volume (0 to 255)

gain Linear gain

Properties

isAudio bool Read
listener AudioListener * The global audio listener
buffer AudioBuffer * Assigned audio buffer
autoplay bool Whether to start playback automatically
isPlaying bool Whether the audio is currently playing
hasPlaybackControl bool Whether play / pause / stop are available
loop bool Whether the audio should loop
loopStart f32 Loop start in seconds
loopEnd f32 Loop end in seconds
offset f32 Playback start offset in seconds
playbackRate f32 Playback speed
detune f32 Pitch offset in cents
volume f32 Gain (0.0 to 1.0)
duration f32 Override duration in seconds (0 = buffer)
sourceType string "empty" or "buffer"