A core class which handles musical timing throughout the game, both in gameplay and in menus.
Static variables
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.
staticread onlymeasureHit:FlxSignal = new FlxSignal()
Signal fired when the current static Conductor instance advances to a new measure.
Static methods
staticwatchQuick(?target:Conductor):Void
Adds Conductor fields to the Flixel debugger variable display.
Parameters:
conductorToUse | The conductor to use. Defaults to |
|---|
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 onlycurrentBeatTime:Float = 0
Current position in the song, in beats and fractions of a measure.
read onlycurrentMeasureTime:Float = 0
Current position in the song, in measures and fractions of a measure.
read onlycurrentTimeChange:Null<SongTimeChange>
The most recent time change for the current song position.
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
instrumentalOffset:Float = 0
An offset tied to the current chart file to compensate for a delay in the instrumental.
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!
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!
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!
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().
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.
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
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. |
|---|
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. |