Skip to main content

Overview

VoicesGroup extends SoundGroup to provide separate management of player and opponent vocal tracks. It allows independent volume control and time offset adjustments for each vocal type, which is essential for gameplay where different characters have separate vocal tracks. Location: funkin.audio.VoicesGroup

Key Features

  • Separate player and opponent vocal track management
  • Independent volume control for each track type
  • Individual time offset support per track
  • Waveform data access for both tracks
  • Synchronized playback control

Properties

Float
default:"1.0"
Controls the volume of all sounds in the player voice group (0.0 to 1.0).
Float
default:"1.0"
Controls the volume of all sounds in the opponent voice group (0.0 to 1.0).
Float
default:"0.0"
Time offset in milliseconds for the player’s vocal track. Positive values delay playback.
Float
default:"0.0"
Time offset in milliseconds for the opponent’s vocal track. Positive values delay playback.

Inherited Properties

From SoundGroup:
Float
Current playback time in milliseconds. Setting this syncs all voices to the same time (with offsets applied).
Float
Master volume for all voices in the group (0.0 to 1.0).
Bool
Mutes all voices in the group when true.
Float
Playback pitch for all voices. Requires FLX_PITCH compiler flag.
Bool
Whether any voice in the group is currently playing.

Methods

addPlayerVoice

Adds a vocal track to the player voice group.
FunkinSound
required
The vocal sound to add to the player group.

addOpponentVoice

Adds a vocal track to the opponent voice group.
FunkinSound
required
The vocal sound to add to the opponent group.

getPlayerVoice

Retrieves a player voice by index.
Int
default:"0"
The index of the voice to retrieve.
Null<FunkinSound>
The player voice at the specified index, or null if not found.

getOpponentVoice

Retrieves an opponent voice by index.
Int
default:"0"
The index of the voice to retrieve.
Null<FunkinSound>
The opponent voice at the specified index, or null if not found.

getPlayerVoiceWaveform

Gets the waveform data for the first player voice.
Null<WaveformData>
Waveform data for visualization, or null if no player voices exist.

getOpponentVoiceWaveform

Gets the waveform data for the first opponent voice.
Null<WaveformData>
Waveform data for visualization, or null if no opponent voices exist.

getPlayerVoiceLength

Returns the length of the player’s vocal track in milliseconds.
Float
Length in milliseconds, or 0.0 if no player voices exist.

getOpponentVoiceLength

Returns the length of the opponent’s vocal track in milliseconds.
Float
Length in milliseconds, or 0.0 if no opponent voices exist.

clear

Removes all voices from both player and opponent groups.

destroy

Destroys the voices group and all contained voices.

Inherited Methods

From SoundGroup:
  • play(forceRestart:Bool = false, startTime:Float = 0.0, ?endTime:Float) - Plays all voices
  • pause() - Pauses all voices
  • resume() - Resumes all voices
  • stop() - Stops all voices
  • fadeIn(duration:Float, ?from:Float = 0.0, ?to:Float = 1.0, ?onComplete:FlxTween->Void) - Fades in all voices
  • fadeOut(duration:Float, ?to:Float = 0.0, ?onComplete:FlxTween->Void) - Fades out all voices

Example Usage

Basic Setup

Volume Control

Time Synchronization

Waveform Visualization

Advanced Usage with Offsets

Checking Track Lengths

Notes

  • Time offsets are automatically applied when setting the time property
  • Changing offset values adjusts the current playback position of affected tracks
  • Volume controls are independent - playerVolume and opponentVolume don’t affect each other
  • The master volume property multiplies with individual track volumes
  • Both groups share the same muted, pitch, and playing state through the parent SoundGroup
  • Waveform data is retrieved from the first voice in each group (index 0)