diff options
| author | 2015-08-22 01:38:12 +0000 | |
|---|---|---|
| committer | 2015-08-22 01:38:12 +0000 | |
| commit | d62b9fc172cb9552ded07df69eec0301ff11d00d (patch) | |
| tree | 2c6fc1f3409c49e988e99ba76201d9a75dbceefd | |
| parent | 2d60fd111142f51697288b946b619443a81bebbd (diff) | |
| parent | 6136d30641aae3f679aa768b7e8ed6d1025510cf (diff) | |
am 6136d306: am 0035f2ce: am 403eaaf2: am c445438e: am d9eef347: Merge "MIDI docs: fix buffer allocation" into mnc-dev
* commit '6136d30641aae3f679aa768b7e8ed6d1025510cf':
MIDI docs: fix buffer allocation
| -rw-r--r-- | media/java/android/media/midi/package.html | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/media/java/android/media/midi/package.html b/media/java/android/media/midi/package.html index 7baa5bc42bd2..45fb5791dfa7 100644 --- a/media/java/android/media/midi/package.html +++ b/media/java/android/media/midi/package.html @@ -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); |