2022-03-08 08:13:53 +00:00
|
|
|
package funkin;
|
2020-10-03 06:50:15 +00:00
|
|
|
|
2022-03-08 08:13:53 +00:00
|
|
|
import funkin.SongLoad.SwagSong;
|
2021-02-11 22:06:26 +00:00
|
|
|
|
2020-10-03 06:50:15 +00:00
|
|
|
/**
|
|
|
|
* ...
|
|
|
|
* @author
|
|
|
|
*/
|
2021-02-11 22:06:26 +00:00
|
|
|
typedef BPMChangeEvent =
|
|
|
|
{
|
|
|
|
var stepTime:Int;
|
|
|
|
var songTime:Float;
|
2021-03-20 16:33:29 +00:00
|
|
|
var bpm:Float;
|
2021-02-11 22:06:26 +00:00
|
|
|
}
|
|
|
|
|
2020-10-03 06:50:15 +00:00
|
|
|
class Conductor
|
|
|
|
{
|
2022-03-30 01:56:04 +00:00
|
|
|
/**
|
|
|
|
* Beats per minute of the song.
|
|
|
|
*/
|
2021-03-20 16:33:29 +00:00
|
|
|
public static var bpm:Float = 100;
|
2022-03-30 01:56:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Duration of a beat in millisecond.
|
|
|
|
*/
|
|
|
|
public static var crochet(get, null):Float;
|
|
|
|
|
|
|
|
static function get_crochet():Float
|
|
|
|
{
|
|
|
|
return ((60 / bpm) * 1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Duration of a step in milliseconds.
|
|
|
|
*/
|
|
|
|
public static var stepCrochet(get, null):Float;
|
|
|
|
|
|
|
|
static function get_stepCrochet():Float
|
|
|
|
{
|
|
|
|
return crochet / 4;
|
|
|
|
}
|
|
|
|
|
2020-10-03 06:50:15 +00:00
|
|
|
public static var songPosition:Float;
|
2020-10-24 09:19:13 +00:00
|
|
|
public static var lastSongPos:Float;
|
2020-10-03 06:50:15 +00:00
|
|
|
public static var offset:Float = 0;
|
|
|
|
|
2021-02-11 22:06:26 +00:00
|
|
|
public static var bpmChangeMap:Array<BPMChangeEvent> = [];
|
|
|
|
|
2021-11-29 20:26:45 +00:00
|
|
|
public function new() {}
|
2020-10-05 00:53:49 +00:00
|
|
|
|
2021-02-11 22:06:26 +00:00
|
|
|
public static function mapBPMChanges(song:SwagSong)
|
|
|
|
{
|
|
|
|
bpmChangeMap = [];
|
|
|
|
|
2021-03-20 16:33:29 +00:00
|
|
|
var curBPM:Float = song.bpm;
|
2021-02-11 22:06:26 +00:00
|
|
|
var totalSteps:Int = 0;
|
|
|
|
var totalPos:Float = 0;
|
2021-12-06 22:49:05 +00:00
|
|
|
for (i in 0...SongLoad.getSong().length)
|
2021-02-11 22:06:26 +00:00
|
|
|
{
|
2021-12-06 22:49:05 +00:00
|
|
|
if (SongLoad.getSong()[i].changeBPM && SongLoad.getSong()[i].bpm != curBPM)
|
2021-02-11 22:06:26 +00:00
|
|
|
{
|
2021-12-06 22:49:05 +00:00
|
|
|
curBPM = SongLoad.getSong()[i].bpm;
|
2021-02-11 22:06:26 +00:00
|
|
|
var event:BPMChangeEvent = {
|
|
|
|
stepTime: totalSteps,
|
|
|
|
songTime: totalPos,
|
|
|
|
bpm: curBPM
|
|
|
|
};
|
|
|
|
bpmChangeMap.push(event);
|
|
|
|
}
|
|
|
|
|
2021-12-06 22:49:05 +00:00
|
|
|
var deltaSteps:Int = SongLoad.getSong()[i].lengthInSteps;
|
2021-02-11 22:06:26 +00:00
|
|
|
totalSteps += deltaSteps;
|
|
|
|
totalPos += ((60 / curBPM) * 1000 / 4) * deltaSteps;
|
|
|
|
}
|
|
|
|
trace("new BPM map BUDDY " + bpmChangeMap);
|
|
|
|
}
|
2020-10-03 06:50:15 +00:00
|
|
|
}
|