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
Controls the volume of all sounds in the player voice group (0.0 to 1.0).
Controls the volume of all sounds in the opponent voice group (0.0 to 1.0).
Time offset in milliseconds for the player’s vocal track. Positive values delay playback.
Time offset in milliseconds for the opponent’s vocal track. Positive values delay playback.
Inherited Properties
FromSoundGroup:
Current playback time in milliseconds. Setting this syncs all voices to the same time (with offsets applied).
Master volume for all voices in the group (0.0 to 1.0).
Mutes all voices in the group when
true.Playback pitch for all voices. Requires
FLX_PITCH compiler flag.Whether any voice in the group is currently playing.
Methods
addPlayerVoice
The vocal sound to add to the player group.
addOpponentVoice
The vocal sound to add to the opponent group.
getPlayerVoice
The index of the voice to retrieve.
The player voice at the specified index, or
null if not found.getOpponentVoice
The index of the voice to retrieve.
The opponent voice at the specified index, or
null if not found.getPlayerVoiceWaveform
Waveform data for visualization, or
null if no player voices exist.getOpponentVoiceWaveform
Waveform data for visualization, or
null if no opponent voices exist.getPlayerVoiceLength
Length in milliseconds, or 0.0 if no player voices exist.
getOpponentVoiceLength
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)
