am c445438e: am d9eef347: Merge "MIDI docs: fix buffer allocation" into mnc-dev

* commit 'c445438e64d713ceb45937de17f7ab2fa34fe295':
  MIDI docs: fix buffer allocation
This commit is contained in:
Glenn Kasten
2015-08-22 00:17:53 +00:00
committed by Android Git Automerger

View File

@@ -202,11 +202,12 @@ MidiInputPort inputPort = device.openInputPort(index);
<p>MIDI messages are sent as byte arrays. Here we encode a NoteOn message.</p> <p>MIDI messages are sent as byte arrays. Here we encode a NoteOn message.</p>
<pre class=prettyprint> <pre class=prettyprint>
byte[] buffer = new buffer[64]; byte[] buffer = new byte[32];
int numBytes = 0; int numBytes = 0;
buffer[numBytes++] = 0x90 + channel; // note on int channel = 3; // MIDI channels 1-16 are encoded as 0-15.
buffer[numBytes++] = pitch; buffer[numBytes++] = (byte)(0x90 + (channel - 1)); // note on
buffer[numBytes++] = velocity; buffer[numBytes++] = (byte)60; // pitch is middle C
buffer[numBytes++] = (byte)127; // max velocity
int offset = 0; int offset = 0;
// post is non-blocking // post is non-blocking
inputPort.send(buffer, offset, numBytes); inputPort.send(buffer, offset, numBytes);