Java examples for javax.sound.midi:MidiMessage
Return a String of the name of status byte of a MidiMessage.
/*/* w w w . j av a2s. c om*/ * Copyright 2004 Hiroo Hayashi * * This file is part of JSynthLib. * * JSynthLib is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published * by the Free Software Foundation; either version 2 of the License, * or(at your option) any later version. * * JSynthLib is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with JSynthLib; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA */ //package com.java2s; import javax.sound.midi.*; public class Main { /** * Return a <code>String</code> of the name of status byte of a * <code>MidiMessage</code>. * * @param m a <code>MidiMessage</code> value * @return a <code>String</code> value * @exception InvalidMidiDataException if an error occurs */ public static String statusString(MidiMessage m) throws InvalidMidiDataException { int c = m.getStatus(); switch (c < 0xf0 ? c & 0xf0 : c) { case 0x80: return "Note Off"; case 0x90: return "Note On"; case 0xa0: return "Poly Pressure"; case 0xb0: return "Control Change"; case 0xc0: return "Program Change"; case 0xd0: return "Channel Pressure"; case 0xe0: return "Pitch Bend"; case 0xf0: return "System Exclusive"; case 0xf1: return "MIDI Time Code"; case 0xf2: return "Song Position Pointer"; case 0xf3: return "Song Select"; case 0xf4: return "Undefined"; case 0xf5: return "Undefined"; case 0xf6: return "Tune Request"; //case 0xf7: return "End of System Exclusive"; case 0xf7: return "Special System Exclusive"; case 0xf8: return "Timing Clock"; case 0xf9: return "Undefined"; case 0xfa: return "Start"; case 0xfb: return "Continue"; case 0xfc: return "Stop"; case 0xfd: return "Undefined"; case 0xfe: return "Active Sensing"; case 0xff: return "System Reset"; default: throw new InvalidMidiDataException(); } } }