< prev index next >

src/java.desktop/share/classes/javax/sound/midi/MidiMessage.java

Print this page


   1 /*
   2  * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  30  * only the standard MIDI messages that a synthesizer can respond to, but also
  31  * "meta-events" that can be used by sequencer programs. There are meta-events
  32  * for such information as lyrics, copyrights, tempo indications, time and key
  33  * signatures, markers, etc. For more information, see the Standard MIDI Files
  34  * 1.0 specification, which is part of the Complete MIDI 1.0 Detailed
  35  * Specification published by the MIDI Manufacturer's Association
  36  * (<a href = http://www.midi.org>http://www.midi.org</a>).
  37  * <p>
  38  * The base {@code MidiMessage} class provides access to three types of
  39  * information about a MIDI message:
  40  * <ul>
  41  * <li>The messages's status byte</li>
  42  * <li>The total length of the message in bytes (the status byte plus any data
  43  * bytes)</li>
  44  * <li>A byte array containing the complete message</li>
  45  * </ul>
  46  *
  47  * {@code MidiMessage} includes methods to get, but not set, these values.
  48  * Setting them is a subclass responsibility.
  49  * <p>
  50  * <a name="integersVsBytes"></a> The MIDI standard expresses MIDI data in
  51  * bytes. However, because Java<sup>TM</sup> uses signed bytes, the Java Sound
  52  * API uses integers instead of bytes when expressing MIDI data. For example,
  53  * the {@link #getStatus()} method of {@code MidiMessage} returns MIDI status
  54  * bytes as integers. If you are processing MIDI data that originated outside
  55  * Java Sound and now is encoded as signed bytes, the bytes can be
  56  * converted to integers using this conversion:
  57  *
  58  * <center>{@code int i = (int)(byte & 0xFF)}</center>
  59  * <p>
  60  * If you simply need to pass a known MIDI byte value as a method parameter, it
  61  * can be expressed directly as an integer, using (for example) decimal or
  62  * hexadecimal notation. For instance, to pass the "active sensing" status byte
  63  * as the first argument to ShortMessage's
  64  * {@link ShortMessage#setMessage(int) setMessage(int)} method, you can express
  65  * it as 254 or 0xFE.
  66  *
  67  * @author David Rivas
  68  * @author Kara Kytle
  69  * @see Track
  70  * @see Sequence
  71  * @see Receiver
  72  */
  73 public abstract class MidiMessage implements Cloneable {
  74 
  75     /**
  76      * The MIDI message data. The first byte is the status byte for the message;
  77      * subsequent bytes up to the length of the message are data bytes for this
  78      * message.


   1 /*
   2  * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  30  * only the standard MIDI messages that a synthesizer can respond to, but also
  31  * "meta-events" that can be used by sequencer programs. There are meta-events
  32  * for such information as lyrics, copyrights, tempo indications, time and key
  33  * signatures, markers, etc. For more information, see the Standard MIDI Files
  34  * 1.0 specification, which is part of the Complete MIDI 1.0 Detailed
  35  * Specification published by the MIDI Manufacturer's Association
  36  * (<a href = http://www.midi.org>http://www.midi.org</a>).
  37  * <p>
  38  * The base {@code MidiMessage} class provides access to three types of
  39  * information about a MIDI message:
  40  * <ul>
  41  * <li>The messages's status byte</li>
  42  * <li>The total length of the message in bytes (the status byte plus any data
  43  * bytes)</li>
  44  * <li>A byte array containing the complete message</li>
  45  * </ul>
  46  *
  47  * {@code MidiMessage} includes methods to get, but not set, these values.
  48  * Setting them is a subclass responsibility.
  49  * <p>
  50  * <a id="integersVsBytes"></a> The MIDI standard expresses MIDI data in
  51  * bytes. However, because Java<sup>TM</sup> uses signed bytes, the Java Sound
  52  * API uses integers instead of bytes when expressing MIDI data. For example,
  53  * the {@link #getStatus()} method of {@code MidiMessage} returns MIDI status
  54  * bytes as integers. If you are processing MIDI data that originated outside
  55  * Java Sound and now is encoded as signed bytes, the bytes can be
  56  * converted to integers using this conversion:
  57  * <p style="text-align:center">
  58  * {@code int i = (int)(byte & 0xFF)}
  59  * <p>
  60  * If you simply need to pass a known MIDI byte value as a method parameter, it
  61  * can be expressed directly as an integer, using (for example) decimal or
  62  * hexadecimal notation. For instance, to pass the "active sensing" status byte
  63  * as the first argument to ShortMessage's
  64  * {@link ShortMessage#setMessage(int) setMessage(int)} method, you can express
  65  * it as 254 or 0xFE.
  66  *
  67  * @author David Rivas
  68  * @author Kara Kytle
  69  * @see Track
  70  * @see Sequence
  71  * @see Receiver
  72  */
  73 public abstract class MidiMessage implements Cloneable {
  74 
  75     /**
  76      * The MIDI message data. The first byte is the status byte for the message;
  77      * subsequent bytes up to the length of the message are data bytes for this
  78      * message.


< prev index next >