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
FromSoundGroup:
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
FunkinSound
required
The vocal sound to add to the player group.
addOpponentVoice
FunkinSound
required
The vocal sound to add to the opponent group.
getPlayerVoice
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
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
Null<WaveformData>
Waveform data for visualization, or
null if no player voices exist.getOpponentVoiceWaveform
Null<WaveformData>
Waveform data for visualization, or
null if no opponent voices exist.getPlayerVoiceLength
Float
Length in milliseconds, or 0.0 if no player voices exist.
getOpponentVoiceLength
Float
Length in milliseconds, or 0.0 if no opponent voices exist.
clear
destroy
Inherited Methods
FromSoundGroup:
play(forceRestart:Bool = false, startTime:Float = 0.0, ?endTime:Float)- Plays all voicespause()- Pauses all voicesresume()- Resumes all voicesstop()- Stops all voicesfadeIn(duration:Float, ?from:Float = 0.0, ?to:Float = 1.0, ?onComplete:FlxTween->Void)- Fades in all voicesfadeOut(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
timeproperty - Changing offset values adjusts the current playback position of affected tracks
- Volume controls are independent -
playerVolumeandopponentVolumedon’t affect each other - The master
volumeproperty multiplies with individual track volumes - Both groups share the same
muted,pitch, andplayingstate through the parentSoundGroup - Waveform data is retrieved from the first voice in each group (index 0)
