Fix time calculation in Malody chart converter.
This commit is contained in:
@@ -74,16 +74,17 @@ namespace Cryville.Crtr.Extensions.Malody {
|
|||||||
Dictionary<MalodyChart.IEvent, StartEventState> longEvents
|
Dictionary<MalodyChart.IEvent, StartEventState> longEvents
|
||||||
= new Dictionary<MalodyChart.IEvent, StartEventState>();
|
= new Dictionary<MalodyChart.IEvent, StartEventState>();
|
||||||
|
|
||||||
float? baseBpm = null;
|
float? baseBpm = null, cbpm = null;
|
||||||
float pbeat = 0f, ctime = 0f;
|
float pbeat = 0f, ctime = 0f;
|
||||||
int[] endbeat = new int[] { 0, 0, 1 };
|
int[] endbeat = new int[] { 0, 0, 1 };
|
||||||
foreach (var ev in events) {
|
foreach (var ev in events) {
|
||||||
float cbeat = ConvertBeat(ev.beat);
|
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;
|
pbeat = cbeat;
|
||||||
if (ev is MalodyChart.Time) {
|
if (ev is MalodyChart.Time) {
|
||||||
var tev = (MalodyChart.Time)ev;
|
var tev = (MalodyChart.Time)ev;
|
||||||
if (baseBpm == null) baseBpm = tev.bpm;
|
if (baseBpm == null) baseBpm = tev.bpm;
|
||||||
|
cbpm = tev.bpm;
|
||||||
chart.sigs.Add(new Chart.Signature {
|
chart.sigs.Add(new Chart.Signature {
|
||||||
time = new BeatTime(ev.beat[0], ev.beat[1], ev.beat[2]),
|
time = new BeatTime(ev.beat[0], ev.beat[1], ev.beat[2]),
|
||||||
tempo = tev.bpm,
|
tempo = tev.bpm,
|
||||||
@@ -165,7 +166,7 @@ namespace Cryville.Crtr.Extensions.Malody {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable IDE1006
|
#pragma warning disable IDE1006
|
||||||
public struct MalodyChart {
|
struct MalodyChart {
|
||||||
public interface IEvent {
|
public interface IEvent {
|
||||||
int[] beat { get; set; }
|
int[] beat { get; set; }
|
||||||
int[] endbeat { get; set; }
|
int[] endbeat { get; set; }
|
||||||
|
Reference in New Issue
Block a user