Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 191f23a4 authored by Phil Burk's avatar Phil Burk Committed by Glenn Kasten
Browse files

MIDI docs: fix buffer allocation



Also describe NoteOn more clearly.

Bug: 23303608
Change-Id: I35f88022c854c2eb16ec606e58f28e06c52d18b7
Signed-off-by: default avatarPhil Burk <philburk@google.com>
(cherry picked from commit bda0caf0)
parent b6e91dfa
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -202,11 +202,12 @@ MidiInputPort inputPort = device.openInputPort(index);
<p>MIDI messages are sent as byte arrays. Here we encode a NoteOn message.</p>

<pre class=prettyprint>
byte[] buffer = new buffer[64];
byte[] buffer = new byte[32];
int numBytes = 0;
buffer[numBytes++] = 0x90 + channel; // note on
buffer[numBytes++] = pitch;
buffer[numBytes++] = velocity;
int channel = 3; // MIDI channels 1-16 are encoded as 0-15.
buffer[numBytes++] = (byte)(0x90 + (channel - 1)); // note on
buffer[numBytes++] = (byte)60; // pitch is middle C
buffer[numBytes++] = (byte)127; // max velocity
int offset = 0;
// post is non-blocking
inputPort.send(buffer, offset, numBytes);