OAVp5.last#
variableoav-p5OAVp5.last
The latest note, control change or pitch bend that arrived: its type, number, value, channel, where it came from and which control it is. null before any.
A single object that is replaced on every message, so read it, do not keep it. It is how a sketch finds out where a message came from (OAVp5.last.source) or which knob moved (OAVp5.last.control), and what to read when the sketch has its own note or velocity that keeps the plain names: OAVp5.last.note and OAVp5.last.value.
It keeps only notes, control changes and pitch bends. Aftertouch and program change reach midiMessage() but are not stored here.
- Type
Object | null
{ type, note | cc, value, channel, source, control }. type is 'noteOn', 'noteOff', 'controlChange' or 'pitchBend' (a note-on with velocity 0 is a 'noteOff'). note is there for notes, cc for control changes. value is the velocity 0..1 (0 for a note-off), the control's position 0..1, or the wheel −1..1. channel is 1 to 16. source is 'hardware', 'screen', 'phone', 'virtual-out', 'link' or the label you gave OAVp5.input(). control is 'knob1', 'fader2', 'pad3' … when the controller's profile knows it, otherwise null.
Notes
midi.lastis the same object. Clock messages (tick, start, stop) are not here: seeOAVp5.clock.
Examples
function setup() {
createCanvas(400, 300);
textSize(16);
}
function mousePressed() { OAVp5.input([0x90, 60 + floor(random(12)), 100], 'mouse'); } // no controller? click
function draw() {
background(20);
fill(255);
text(OAVp5.last ? JSON.stringify(OAVp5.last, null, 1) : 'play something', 20, 30);
}source. Plug in a controller, or press 🎹 (bottom right) and use the on-screen one.Related
midiMessage()You define this function; oav-p5 calls it for every MIDI message it receives, with the raw bytes and where they came from.noteOn()You define this function; oav-p5 calls it for every MIDI note-on, with the key, how hard and the channel.noteThe MIDI number (0 to 127) of the last key pressed.velocityHow hard the last key was pressed, from 0 to 1.OAVp5.input()Sends one MIDI message into oav-p5 by hand, as bytes: the whole sketch reacts as if a controller had sent it.