2020-10-03 02:50:15 -04:00
|
|
|
package;
|
|
|
|
|
2021-11-29 21:43:38 -05:00
|
|
|
import SongLoad.SwagSong;
|
2021-02-11 17:06:26 -05:00
|
|
|
|
2020-10-03 02:50:15 -04:00
|
|
|
/**
|
|
|
|
* ...
|
|
|
|
* @author
|
|
|
|
*/
|
2021-02-11 17:06:26 -05:00
|
|
|
typedef BPMChangeEvent =
|
|
|
|
{
|
|
|
|
var stepTime:Int;
|
|
|
|
var songTime:Float;
|
2021-03-20 12:33:29 -04:00
|
|
|
var bpm:Float;
|
2021-02-11 17:06:26 -05:00
|
|
|
}
|
|
|
|
|
2020-10-03 02:50:15 -04:00
|
|
|
class Conductor
|
|
|
|
{
|
2021-03-20 12:33:29 -04:00
|
|
|
public static var bpm:Float = 100;
|
2020-10-03 02:50:15 -04:00
|
|
|
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;
|
2020-10-24 05:19:13 -04:00
|
|
|
public static var lastSongPos:Float;
|
2020-10-03 02:50:15 -04:00
|
|
|
public static var offset:Float = 0;
|
|
|
|
|
2021-02-11 17:06:26 -05:00
|
|
|
public static var bpmChangeMap:Array<BPMChangeEvent> = [];
|
|
|
|
|
2021-11-29 15:26:45 -05:00
|
|
|
public function new() {}
|
2020-10-04 20:53:49 -04:00
|
|
|
|
2021-02-11 17:06:26 -05:00
|
|
|
public static function mapBPMChanges(song:SwagSong)
|
|
|
|
{
|
|
|
|
bpmChangeMap = [];
|
|
|
|
|
2021-03-20 12:33:29 -04:00
|
|
|
var curBPM:Float = song.bpm;
|
2021-02-11 17:06:26 -05:00
|
|
|
var totalSteps:Int = 0;
|
|
|
|
var totalPos:Float = 0;
|
2021-12-03 07:29:47 -05:00
|
|
|
for (i in 0...song.notes[SongLoad.curDiff].length)
|
2021-02-11 17:06:26 -05:00
|
|
|
{
|
2021-11-29 22:12:18 -05:00
|
|
|
if (song.notes[SongLoad.curDiff][i].changeBPM && song.notes[SongLoad.curDiff][i].bpm != curBPM)
|
2021-02-11 17:06:26 -05:00
|
|
|
{
|
2021-11-29 22:12:18 -05:00
|
|
|
curBPM = song.notes[SongLoad.curDiff][i].bpm;
|
2021-02-11 17:06:26 -05:00
|
|
|
var event:BPMChangeEvent = {
|
|
|
|
stepTime: totalSteps,
|
|
|
|
songTime: totalPos,
|
|
|
|
bpm: curBPM
|
|
|
|
};
|
|
|
|
bpmChangeMap.push(event);
|
|
|
|
}
|
|
|
|
|
2021-11-29 22:12:18 -05:00
|
|
|
var deltaSteps:Int = song.notes[SongLoad.curDiff][i].lengthInSteps;
|
2021-02-11 17:06:26 -05:00
|
|
|
totalSteps += deltaSteps;
|
|
|
|
totalPos += ((60 / curBPM) * 1000 / 4) * deltaSteps;
|
|
|
|
}
|
|
|
|
trace("new BPM map BUDDY " + bpmChangeMap);
|
|
|
|
}
|
|
|
|
|
2021-03-20 12:33:29 -04:00
|
|
|
public static function changeBPM(newBpm:Float)
|
2020-10-04 20:53:49 -04:00
|
|
|
{
|
|
|
|
bpm = newBpm;
|
|
|
|
|
|
|
|
crochet = ((60 / bpm) * 1000);
|
|
|
|
stepCrochet = crochet / 4;
|
|
|
|
}
|
2020-10-03 02:50:15 -04:00
|
|
|
}
|