我有一组这样的笔记
const notes = [{note: 'C4', duration: '8n'}, {note: 'D4', duration: '4n'}, {note: 'C4', duration: '2n'}, {note: '', duration: '8n'}] //last element stands for a pause如何播放基于此数组的旋律?有没有更好的存储旋律的方法?
或者也许我应该使用另一个库来完成这个任务?
谢谢!
发布于 2020-08-26 15:09:03
所以我是这样做的:
playTab = tab => {
const now = Tone.Time()
let currentTime = 0
tab.forEach(item => {
const {note, duration} = parseNote(item)
if (note !== '') {
this.synth.triggerAttackRelease(note, duration, now + currentTime)
}
currentTime += Tone.Time(duration).toSeconds()
})
}这是一个好的决定吗?或者应该以不同的方式来做?
https://stackoverflow.com/questions/63590352
复制相似问题