1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-25 08:13:45 +00:00
Funkin/source/Conductor.hx
2021-12-03 07:29:47 -05:00

64 lines
1.4 KiB
Haxe

package;
import SongLoad.SwagSong;
/**
* ...
* @author
*/
typedef BPMChangeEvent =
{
var stepTime:Int;
var songTime:Float;
var bpm:Float;
}
class Conductor
{
public static var bpm:Float = 100;
public static var crochet:Float = ((60 / bpm) * 1000); // beats in milliseconds
public static var stepCrochet:Float = crochet / 4; // steps in milliseconds
public static var songPosition:Float;
public static var lastSongPos:Float;
public static var offset:Float = 0;
public static var bpmChangeMap:Array<BPMChangeEvent> = [];
public function new() {}
public static function mapBPMChanges(song:SwagSong)
{
bpmChangeMap = [];
var curBPM:Float = song.bpm;
var totalSteps:Int = 0;
var totalPos:Float = 0;
for (i in 0...song.notes[SongLoad.curDiff].length)
{
if (song.notes[SongLoad.curDiff][i].changeBPM && song.notes[SongLoad.curDiff][i].bpm != curBPM)
{
curBPM = song.notes[SongLoad.curDiff][i].bpm;
var event:BPMChangeEvent = {
stepTime: totalSteps,
songTime: totalPos,
bpm: curBPM
};
bpmChangeMap.push(event);
}
var deltaSteps:Int = song.notes[SongLoad.curDiff][i].lengthInSteps;
totalSteps += deltaSteps;
totalPos += ((60 / curBPM) * 1000 / 4) * deltaSteps;
}
trace("new BPM map BUDDY " + bpmChangeMap);
}
public static function changeBPM(newBpm:Float)
{
bpm = newBpm;
crochet = ((60 / bpm) * 1000);
stepCrochet = crochet / 4;
}
}