修改这个控件会自动更新这一页面
《MainStage 使用手册》
- 欢迎使用
- 版权

在 MainStage 中使用 MIDI 事件 beatPos 属性
脚本编辑器中的每个 MIDI 事件都有一个叫做“beatPos”的属性,它携带了事件准确的节拍位置信息,能够提供更加准确的事件时序,同时正确处理循环。这个属性可以代替 timingInfo.blockStartBeat 使用。请参阅使用 JavaScript TimingInfo 对象。
【注】只有 "var NeedsTimingInfo = true" 时,此属性才有效,否则它的值将为 0,且在被修改时将发出警告。
在 MainStage中,在脚本编辑器窗口中键入以下其中一行代码(两行代码结果相同):
event.send()event.sendAtBeat(event.beatPos)或者,你可以在脚本编辑器窗口中使用以下其中一行代码(两行代码结果相同):
event.beatpos += 1; event.send()event.sendAtBeat(event.beatPos + 1)
beatPos 属性用法示例
你可以使用 beatPos 属性发送特定节拍位置处的 MIDI 事件。在以下示例中,一个音符关事件晚于事件中相应音符节拍位置一个节拍发送。
【注】你也可以使用 event.sendAtBeat(pos) 方法发送特定节拍位置处的事件。使用 beatPos 属性的好处是,你不需要真正发送事件,就可以使用属性来轻松获取事件的准确节拍位置。
“/*”之后的文本显示解释 JavaScript 代码的注释。
var NeedsTimingInfo = true; /* needed to make beatPos work */function HandleMIDI(event) {var on = new NoteOn; /* make a new note on */on.pitch = 60; /* set its pitch to C3 */on.beatPos = event.beatPos; /* copy beat position from incoming event */on.send(); /* send the note on */var off = new NoteOff(on); /* make a note off using the note on to initialize its pitch value to C3 */ /* note that the beatPos does not get copied here */off.beatPos = on.BeatPos+1; /* set the beat position of the note off event */off.send(); /* send the note off event */}
感谢您的反馈。