A core class which handles musical timing throughout the game, both in gameplay and in menus.

Static variables

@:value(new FlxSignal())staticread onlybeatHit:FlxSignal = new FlxSignal()

Signal fired when the current Conductor instance advances to a new beat.

staticread onlyinstance:Conductor

The current instance of the Conductor. If one doesn't currently exist, a new one will be created.

You can also do stuff like store a reference to the Conductor and pass it around or temporarily replace it, or have a second Conductor running at the same time, or other weird stuff like that if you need to.

@:value(new FlxSignal())staticread onlymeasureHit:FlxSignal = new FlxSignal()

Signal fired when the current static Conductor instance advances to a new measure.

@:value(new FlxSignal())staticread onlystepHit:FlxSignal = new FlxSignal()

Signal fired when the current Conductor instance advances to a new step.

Static methods

staticreset():Void

Reset the Conductor, replacing the current instance with a fresh one.

staticwatchQuick(?target:Conductor):Void

Adds Conductor fields to the Flixel debugger variable display.

Parameters:

conductorToUse

The conductor to use. Defaults to Conductor.instance.

Constructor

new()

The constructor.

Variables

read onlyaudioVisualOffset:Int

An offset set by the user to compensate for audio/visual lag No matter if you're using a local conductor or not, this always loads to/from the save file

read onlybeatLengthMs:Float

Duration of a beat in milliseconds. Calculated based on bpm.

read onlybeatsPerMeasure:Float

The number of beats in a measure.

read onlybpm:Float

Beats per minute of the current song at the current time.

read onlycombinedOffset:Float

@:value(0)read onlycurrentBeat:Int = 0

Current position in the song, in beats.

@:value(0)read onlycurrentBeatTime:Float = 0

Current position in the song, in beats and fractions of a measure.

@:value(0)read onlycurrentMeasure:Int = 0

Current position in the song, in measures.

@:value(0)read onlycurrentMeasureTime:Float = 0

Current position in the song, in measures and fractions of a measure.

@:value(0)read onlycurrentStep:Int = 0

Current position in the song, in steps.

@:value(0)read onlycurrentStepTime:Float = 0

Current position in the song, in steps and fractions of a step.

read onlycurrentTimeChange:Null<SongTimeChange>

The most recent time change for the current song position.

@:value(0)formatOffset:Float = 0

An offset tied to the file format of the audio file being played.

read onlyglobalOffset:Int

An offset set by the user to compensate for input lag. No matter if you're using a local conductor or not, this always loads to/from the save file

@:value(0)instrumentalOffset:Float = 0

An offset tied to the current chart file to compensate for a delay in the instrumental.

read onlyinstrumentalOffsetSteps:Float

The instrumental offset, in terms of steps.

read onlymeasureLengthMs:Float

Duration of a measure in milliseconds. Calculated based on bpm.

@:value(new FlxSignal())read onlyonBeatHit:FlxSignal = new FlxSignal()

Signal fired when THIS Conductor instance advances to a new beat. TODO: This naming sucks but we can't make a static and instance field with the same name!

@:value(new FlxSignal())read onlyonMeasureHit:FlxSignal = new FlxSignal()

Signal fired when THIS Conductor instance advances to a new measure. TODO: This naming sucks but we can't make a static and instance field with the same name!

@:value(new FlxSignal())read onlyonStepHit:FlxSignal = new FlxSignal()

Signal fired when THIS Conductor instance advances to a new step. TODO: This naming sucks but we can't make a static and instance field with the same name!

@:value(0)read onlysongPosition:Float = 0

The current position in the song in milliseconds. Update this every frame based on the audio position using Conductor.instance.update().

read onlystartingBPM:Float

Beats per minute of the current song at the start time.

read onlystepLengthMs:Float

Duration of a step in milliseconds. Calculated based on bpm.

read onlystepsPerMeasure:Int

The number of steps in a measure.

read onlytimeSignatureDenominator:Int

The denominator for the current time signature (the 4 in 3/4).

read onlytimeSignatureNumerator:Int

The numerator for the current time signature (the 3 in 3/4).

Methods

forceBPM(?bpm:Float):Void

Forcibly defines the current BPM of the song. Useful for things like the chart editor that need to manipulate BPM in real time.

Set to null to reset to the BPM defined by the timeChanges.

WARNING: Avoid this for things like setting the BPM of the title screen music, you should have a metadata file for it instead. We should probably deprecate this in the future.

getBeatTimeInMs(beatTime:Float):Float

Given a time in beats and fractional beats, return a time in milliseconds.

Parameters:

beatTime

The time in beats.

Returns:

The time in milliseconds.

getMeasureTimeInMs(measureTime:Float):Float

Given a time in measures and fractional measures, return a time in milliseconds.

Parameters:

measureTime

The time in measures.

Returns:

The time in milliseconds.

getStepTimeInMs(stepTime:Float):Float

Given a time in steps and fractional steps, return a time in milliseconds.

Parameters:

stepTime

The time in steps.

Returns:

The time in milliseconds.

getTimeChange(ms:Float):SongTimeChange

Given a time in milliseconds, return the time change that time is inside of.

Parameters:

ms

The time in milliseconds.

Returns:

The resulting time change.

getTimeInMeasures(ms:Float):Float

Given a time in milliseconds, return a time in measures.

Parameters:

ms

The time in milliseconds.

Returns:

The time in measures.

getTimeInSteps(ms:Float):Float

Given a time in milliseconds, return a time in steps.

Parameters:

ms

The time in milliseconds.

Returns:

The time in steps.

getTimeWithDelta():Float

Returns a more accurate music time for higher framerates.

Returns:

Float

getTimeWithDiff(?soundToCheck:FlxSound):Float

Can be called in-between frames, usually for input related things that can potentially get processed on exact milliseconds/timestamps. If you need song position, use Conductor.instance.songPosition instead for use in update() related functions.

Parameters:

soundToCheck

Which FlxSound object to check, defaults to FlxG.sound.music if no input

Returns:

Float

@:value({ type : "beat" })getTypeLengthAtMs(ms:Float, type:String = "beat"):Float

An all-in-one function for getting either a step, beat, or measure's length in milliseconds from a given time change.

Parameters:

ms

The time in milliseconds. The time change is determined by this.

type

The type of length to return. Either "step", "beat", or "measure" works, along with their first character.

Returns:

The length of a step/beat/measure in milliseconds.

mapTimeChanges(songTimeChanges:Array<SongTimeChange>):Void

Apply the SongTimeChange data from the song metadata to this Conductor.

Parameters:

songTimeChanges

The SongTimeChanges.

@:value({ forceDispatch : false, applyOffsets : true })update(?songPos:Float, applyOffsets:Bool = true, forceDispatch:Bool = false):Void

Update the conductor with the current song position. BPM, current step, etc. will be re-calculated based on the song position.

Parameters:

songPosition

The current position in the song in milliseconds. Leave blank to use the FlxG.sound.music position.

applyOffsets

If it should apply the instrumentalOffset + formatOffset + audioVisualOffset

forceDispatch

If it should force the dispatch of onStepHit, onBeatHit, and onMeasureHit even if the current step, beat, or measure hasn't changed.