OAVp5.bend#
變數oav-p5OAVp5.bend
音高輪現在的位置,從 −1(推到底往下)、經過 0(中間)到 1(推到底往上)。
像一顆可以往兩邊轉的旋鈕那樣在 draw() 裡讀:x = width / 2 + OAVp5.bend * 150。MIDI 用 14 位元送出位置(0 到 16383,中間是 8192)。oav-p5 把兩半分別對應成 −1 到 0 和 0 到 1,所以推到底剛好是 −1 和 1。想每次移動都被通知,就定義 pitchBend()。
- 型別
Number- 範圍
-1..1
輪子動的時候才會變。還沒動過之前是 0,有彈簧的輪子彈回中間時也是 0。
注意
midi.bend是同一個數字。沒有叫bend的變數。
範例
function setup() {
createCanvas(400, 300);
}
function mouseDragged() {
OAVp5.input([0xE0, 0, constrain(round(mouseX / width * 127), 0, 127)]); // no wheel? drag the mouse
}
function draw() {
background(20);
circle(width / 2 + OAVp5.bend * 150, height / 2, 50); // wheel up: right, wheel down: left
text('bend ' + nf(OAVp5.bend, 1, 2), 20, 30);
}相關
pitchBend()你來定義這個函式。音高輪一動,oav-p5 就呼叫它,帶著它的位置,從 −1 到 1。OAVp5.cc128 個數字的陣列,每個 MIDI 控制器號碼一個:每個控制最後停在哪裡,0 到 1。OAVp5.cc[1]是調變輪,OAVp5.cc[64]是延音踏板。OAVp5.note128 個數字的陣列,每個 MIDI 鍵一個:那個鍵被按得多用力,0 到 1,放開就是 0。OAVp5.note[60]是中央 C。