Add TimeTimingModel.
This commit is contained in:
@@ -16,7 +16,12 @@ namespace Cryville.Crtr {
|
|||||||
n = _n;
|
n = _n;
|
||||||
d = _d;
|
d = _d;
|
||||||
}
|
}
|
||||||
|
public BeatTime(int _n, int _d) {
|
||||||
|
b = _n / _d;
|
||||||
|
n = _n % _d;
|
||||||
|
d = _d;
|
||||||
|
}
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public int b;
|
public int b;
|
||||||
|
|
||||||
|
@@ -39,4 +39,16 @@ namespace Cryville.Crtr.Extensions {
|
|||||||
return new BeatTime(i, n, d);
|
return new BeatTime(i, n, d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public class TimeTimingModel : TimingModel {
|
||||||
|
public TimeTimingModel(double offset = 0) : base(offset) { }
|
||||||
|
public void ForwardTo(double t) {
|
||||||
|
if (t == Time) return;
|
||||||
|
if (BPM == 0) throw new InvalidOperationException("BPM not determined");
|
||||||
|
BeatTime += (t - Time) * BPM / 60;
|
||||||
|
int n, d;
|
||||||
|
FractionUtils.ToFraction(BeatTime, 1f / 48 / BPM * 60, out n, out d);
|
||||||
|
FractionalBeatTime = new BeatTime(n, d);
|
||||||
|
Time = t;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user