OAVp5.clock.info#
物件oav-p5OAVp5.clock.info
外部時鐘的快照:state(none、running、stopped 或 lost)、bpm、鼓機有沒有跟著它、它從哪裡來,還有各種計數。
state 在收到任何時鐘訊息之前是 'none',時鐘在走的時候是 'running',MIDI stop 之後是 'stopped'(位置停住,時鐘訊息可能還在來),超過 0.6 秒沒收到時鐘訊息就是 'lost'。bpm 是用最近 24 個 tick 擬合出來的速度,四捨五入到小數兩位,兩個 tick 之前是 null。running 在播放中是 true,只有時鐘、沒有 start 訊息的串流也算(那時 implicit 是 true)。
following 在鼓機讀這個時鐘的時候是 true:它在跑、有速度、而且沒有設 clock=off。source 說訊息從哪裡來:'hardware'、'screen'、'phone'、'virtual-out'(某個程式送進 OAV Virtual MIDI)或 'link'。clocks、dupes、starts、stops、continues 數的是收到了什麼:用同一個時間戳送三次的 start 只算一次,其餘加進 dupes。
- 型別
Object
每次讀都是一個新的物件:{ state, bpm, running, following, source, implicit, clocks, dupes, starts, stops, continues }。在任何時鐘訊息之前是 { state: 'none', bpm: null, running: false, following: false, source: null, clocks: 0 }。
範例
function setup() {
createCanvas(400, 300);
OAVp5.input([0xFA]); // MIDI start
setInterval(() => OAVp5.input([0xF8]), 20); // clock ticks: 24 a beat, here 50 a second (125 BPM)
}
function draw() {
background(20);
fill(255);
const i = OAVp5.clock.info;
text('state: ' + i.state + (i.running ? ' (running)' : ''), 20, 30);
text('bpm: ' + i.bpm + ', following: ' + i.following, 20, 60);
text('source: ' + i.source + ', clocks heard: ' + i.clocks, 20, 90);
}相關
OAVp5.clockoav-p5 聽到的外部 MIDI 時鐘:它的狀態、速度、現在在小節的哪裡。在別的程式或設備開始送時鐘之前什麼都沒有。OAVp5.clock.bpm外部 MIDI 時鐘的速度,單位是每分鐘幾拍,沒有的時候是null。OAVp5.clock.phase外部時鐘現在走到哪裡:{ pos, bar, beat, bpm, running },沒有速度的時候是null。clock外部的 MIDI 時鐘(來自 DAW、Strudel 或鼓機)要不要推動drumPhase、drumBpm和鼓機:follow或off。