Fix time calculation in Malody chart converter.

This commit is contained in:
2022-11-18 15:55:31 +08:00
parent f3549353f3
commit 3ed7e566dd

View File

@@ -74,16 +74,17 @@ namespace Cryville.Crtr.Extensions.Malody {
Dictionary<MalodyChart.IEvent, StartEventState> longEvents
= new Dictionary<MalodyChart.IEvent, StartEventState>();
float? baseBpm = null;
float? baseBpm = null, cbpm = null;
float pbeat = 0f, ctime = 0f;
int[] endbeat = new int[] { 0, 0, 1 };
foreach (var ev in events) {
float cbeat = ConvertBeat(ev.beat);
ctime += baseBpm == null ? 0 : (cbeat - pbeat) / baseBpm.Value * 60f;
ctime += cbpm == null ? 0 : (cbeat - pbeat) / cbpm.Value * 60f;
pbeat = cbeat;
if (ev is MalodyChart.Time) {
var tev = (MalodyChart.Time)ev;
if (baseBpm == null) baseBpm = tev.bpm;
cbpm = tev.bpm;
chart.sigs.Add(new Chart.Signature {
time = new BeatTime(ev.beat[0], ev.beat[1], ev.beat[2]),
tempo = tev.bpm,
@@ -165,7 +166,7 @@ namespace Cryville.Crtr.Extensions.Malody {
}
#pragma warning disable IDE1006
public struct MalodyChart {
struct MalodyChart {
public interface IEvent {
int[] beat { get; set; }
int[] endbeat { get; set; }