Conductor class is a core singleton that manages musical timing for both gameplay and menus. It handles BPM changes, time signatures, beat/step detection, and provides time conversion utilities.
Overview
The Conductor maintains the current song position and automatically dispatches signals when musical events occur (measures, beats, steps). It supports complex timing scenarios including:- Multiple BPM changes within a song
- Arbitrary time signatures (4/4, 3/4, 7/8, etc.)
- Audio/visual offsets and latency compensation
- Precise time-to-beat/step conversions
Accessing the Conductor
Properties
Timing Properties
Current beats per minute at the current song position. Automatically adjusts when time changes occur.
Current position in the song in milliseconds. Updated every frame via
update().Current position in the song as an integer beat number.
Current position in the song in beats, including fractional beats.
Current position in the song as an integer step number. There are 4 steps per beat.
Current position in the song in steps, including fractional steps.
Current position in the song as an integer measure number.
Current position in the song in measures, including fractional measures.
Duration Properties
Duration of a beat in milliseconds, calculated from the current BPM and time signature.
Duration of a step in milliseconds. Always 1/4 of
beatLengthMs.Duration of a measure in milliseconds, calculated from beat length and time signature.
Time Signature Properties
The numerator of the current time signature (the
3 in 3/4).The denominator of the current time signature (the
4 in 3/4).Number of beats in a measure. Equal to
timeSignatureNumerator.Number of steps in a measure. Equal to
timeSignatureNumerator * 4.Offset Properties
Chart-specific offset in milliseconds to compensate for instrumental delays.
Audio format offset (e.g., MP3 encoding delay).
User-configured offset to compensate for input lag, loaded from save data.
User-configured offset to compensate for audio/visual lag, loaded from save data.
Sum of
instrumentalOffset + formatOffset + globalOffset.Methods
update()
Updates the conductor with the current song position and recalculates all timing properties.The current position in the song in milliseconds. If omitted, uses
FlxG.sound.music.time.Whether to apply
combinedOffset to the song position.Force signal dispatch even if the current step/beat/measure hasn’t changed.
mapTimeChanges()
Applies song time changes (BPM/time signature changes) to the conductor.Array of time change data from song metadata.
forceBPM()
Forces the conductor to use a specific BPM, ignoring time changes.The BPM to force. Pass
null to reset to time change-based BPM.Time Conversion Methods
The Conductor provides several methods for converting between different time units.getTimeInSteps()
Converts milliseconds to steps.Time in milliseconds.
getStepTimeInMs()
Converts steps to milliseconds.Time in steps.
getBeatTimeInMs()
Converts beats to milliseconds.Time in beats.
getTimeInMeasures()
Converts milliseconds to measures.Time in milliseconds.
getMeasureTimeInMs()
Converts measures to milliseconds.Time in measures.
getTimeWithDelta()
Returns a more accurate music time for higher framerates by including interpolated delta time.Signals
The Conductor dispatches signals when timing events occur. Use these to sync animations and gameplay to the music.Fired when the conductor advances to a new step (16th note in 4/4 time).
Fired when the conductor advances to a new beat (quarter note in 4/4 time).
Fired when the conductor advances to a new measure.
Static Methods
reset()
Resets the conductor by creating a new instance.watchQuick()
Adds conductor properties to the Flixel debugger watch window.The conductor instance to watch. Defaults to
Conductor.instance.Understanding Steps, Beats, and Measures
The Conductor uses musical notation concepts:- Step: A subdivision of a beat. In 4/4 time with 4 steps per beat, a step equals a 16th note.
- Beat: The basic unit of time in music. In 4/4 time, a beat equals a quarter note.
- Measure: A grouping of beats. In 4/4 time, a measure contains 4 beats.
Time Signature Effects
- 4/4 time: 4 beats per measure, 16 steps per measure
- 120 BPM = 2 beats/second, 8 steps/second
- 3/4 time: 3 beats per measure, 12 steps per measure
- 120 BPM = 2 beats/second, 8 steps/second
- 7/8 time: 7 beats per measure (eighth notes!), 28 steps per measure
- 120 BPM = 4 beats/second, 16 steps/second
