Skip to main content
The 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

Float
Current beats per minute at the current song position. Automatically adjusts when time changes occur.
Float
Current position in the song in milliseconds. Updated every frame via update().
Int
Current position in the song as an integer beat number.
Float
Current position in the song in beats, including fractional beats.
Int
Current position in the song as an integer step number. There are 4 steps per beat.
Float
Current position in the song in steps, including fractional steps.
Int
Current position in the song as an integer measure number.
Float
Current position in the song in measures, including fractional measures.

Duration Properties

Float
Duration of a beat in milliseconds, calculated from the current BPM and time signature.
Float
Duration of a step in milliseconds. Always 1/4 of beatLengthMs.
Float
Duration of a measure in milliseconds, calculated from beat length and time signature.

Time Signature Properties

Int
The numerator of the current time signature (the 3 in 3/4).
Int
The denominator of the current time signature (the 4 in 3/4).
Float
Number of beats in a measure. Equal to timeSignatureNumerator.
Int
Number of steps in a measure. Equal to timeSignatureNumerator * 4.

Offset Properties

Float
Chart-specific offset in milliseconds to compensate for instrumental delays.
Float
Audio format offset (e.g., MP3 encoding delay).
Int
User-configured offset to compensate for input lag, loaded from save data.
Int
User-configured offset to compensate for audio/visual lag, loaded from save data.
Float
Sum of instrumentalOffset + formatOffset + globalOffset.

Methods

update()

Updates the conductor with the current song position and recalculates all timing properties.
Float
The current position in the song in milliseconds. If omitted, uses FlxG.sound.music.time.
Bool
default:"true"
Whether to apply combinedOffset to the song position.
Bool
default:"false"
Force signal dispatch even if the current step/beat/measure hasn’t changed.
Example:

mapTimeChanges()

Applies song time changes (BPM/time signature changes) to the conductor.
Array<SongTimeChange>
required
Array of time change data from song metadata.
Example:

forceBPM()

Forces the conductor to use a specific BPM, ignoring time changes.
Float
The BPM to force. Pass null to reset to time change-based BPM.
Avoid using this for setting BPM of menu music. Use metadata files instead. This is primarily for tools like the chart editor.
Example:

Time Conversion Methods

The Conductor provides several methods for converting between different time units.

getTimeInSteps()

Converts milliseconds to steps.
Float
required
Time in milliseconds.
Returns: Time in steps (float).

getStepTimeInMs()

Converts steps to milliseconds.
Float
required
Time in steps.
Returns: Time in milliseconds.

getBeatTimeInMs()

Converts beats to milliseconds.
Float
required
Time in beats.
Returns: Time in milliseconds.

getTimeInMeasures()

Converts milliseconds to measures.
Float
required
Time in milliseconds.
Returns: Time in measures (float).

getMeasureTimeInMs()

Converts measures to milliseconds.
Float
required
Time in measures.
Returns: Time in milliseconds. Example:

getTimeWithDelta()

Returns a more accurate music time for higher framerates by including interpolated delta time.
Returns: Song position with delta applied for smoother timing.

Signals

The Conductor dispatches signals when timing events occur. Use these to sync animations and gameplay to the music.
FlxSignal
Fired when the conductor advances to a new step (16th note in 4/4 time).
FlxSignal
Fired when the conductor advances to a new beat (quarter note in 4/4 time).
FlxSignal
Fired when the conductor advances to a new measure.
Example:

Static Methods

reset()

Resets the conductor by creating a new instance.
Example:

watchQuick()

Adds conductor properties to the Flixel debugger watch window.
Conductor
The conductor instance to watch. Defaults to Conductor.instance.
Example:

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

Example: Syncing to Music

See Also

  • PlayState - Main gameplay state that uses Conductor extensively
  • Song Data - Song data structure that provides time changes to the Conductor