beat
beat 是RPE所有事件的时间单位,它是一个 JsonArray ,在RPE中显示为 [0]:[1]/[2]。
单BPM计算方式为:
double beat = RPEBeat[1] / RPEBeat[2] + RPEBeat[0];
double seconds = 60 / BPM * beat;
多BPM计算方式见 Python 示例。
Python 示例
- 若
self.BPMList为一个list[BPMEvent] BPMEvent定义:
@dataclass
class BPMEvent:
startTime: Beat
bpm: float
sec2beat中t为秒数,bpmfactor为判定线中的bpmfactor字段`beat2sec中t为拍数,bpmfactor为判定线中的bpmfactor字段`- 且
beat2sec(sec2beat(x)) == x与sec2beat(beat2sec(x)) == x的结果均为True - 则有:
def sec2beat(self, t: float, bpmfactor: float):
beat = 0.0
for i, e in enumerate(self.BPMList):
bpmv = e.bpm / bpmfactor
if i != len(self.BPMList) - 1:
et_beat = self.BPMList[i + 1].startTime.value - e.startTime.value
et_sec = et_beat * (60 / bpmv)
if t >= et_sec:
beat += et_beat
t -= et_sec
else:
beat += t / (60 / bpmv)
break
else:
beat += t / (60 / bpmv)
return beat
def beat2sec(self, t: float, bpmfactor: float):
sec = 0.0
for i, e in enumerate(self.BPMList):
bpmv = e.bpm / bpmfactor
if i != len(self.BPMList) - 1:
et_beat = self.BPMList[i + 1].startTime.value - e.startTime.value
if t >= et_beat:
sec += et_beat * (60 / bpmv)
t -= et_beat
else:
sec += t * (60 / bpmv)
break
else:
sec += t * (60 / bpmv)
return sec