javax.sound.midi.ShortMessage Java Examples
The following examples show how to use
javax.sound.midi.ShortMessage.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PassportMidiInterface.java From jace with GNU General Public License v2.0 | 6 votes |
private void suspendACIA() { // TODO: Stop ACIA thread... if (midiOut != null) { currentMessage = new ShortMessage(); // Send a note-off on every channel for (int channel = 0; channel < 16; channel++) { try { // All Notes Off currentMessage.setMessage(0x0B0 | channel, 123, 0); midiOut.send(currentMessage, 0); // All Oscillators Off currentMessage.setMessage(0x0B0 | channel, 120, 0); midiOut.send(currentMessage, 0); } catch (InvalidMidiDataException ex) { Logger.getLogger(PassportMidiInterface.class.getName()).log(Level.SEVERE, null, ex); } } midiOut.close(); midiOut = null; } }
Example #2
Source File: GetReceiver2.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { AudioSynthesizer synth = new SoftSynthesizer(); Receiver recv = synth.getReceiver(); assertTrue(recv != null); ShortMessage sm = new ShortMessage(); sm.setMessage(ShortMessage.NOTE_OFF, 0, 64, 64); synth.open(new DummySourceDataLine(), null); recv.send(sm, -1); synth.close(); try { recv.send(sm, -1); throw new RuntimeException("Exception not thrown!"); } catch(Exception e) { // Just checking if exception is thrown } }
Example #3
Source File: SoftReceiver.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
public void send(MidiMessage message, long timeStamp) { synchronized (control_mutex) { if (!open) throw new IllegalStateException("Receiver is not open"); } if (timeStamp != -1) { synchronized (control_mutex) { mainmixer.activity(); while (midimessages.get(timeStamp) != null) timeStamp++; if (message instanceof ShortMessage && (((ShortMessage)message).getChannel() > 0xF)) { midimessages.put(timeStamp, message.clone()); } else { midimessages.put(timeStamp, message.getMessage()); } } } else { mainmixer.processMessage(message); } }
Example #4
Source File: SoftReceiver.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public void send(MidiMessage message, long timeStamp) { synchronized (control_mutex) { if (!open) throw new IllegalStateException("Receiver is not open"); } if (timeStamp != -1) { synchronized (control_mutex) { mainmixer.activity(); while (midimessages.get(timeStamp) != null) timeStamp++; if (message instanceof ShortMessage && (((ShortMessage)message).getChannel() > 0xF)) { midimessages.put(timeStamp, message.clone()); } else { midimessages.put(timeStamp, message.getMessage()); } } } else { mainmixer.processMessage(message); } }
Example #5
Source File: SoftReceiver.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public void send(MidiMessage message, long timeStamp) { synchronized (control_mutex) { if (!open) throw new IllegalStateException("Receiver is not open"); } if (timeStamp != -1) { synchronized (control_mutex) { mainmixer.activity(); while (midimessages.get(timeStamp) != null) timeStamp++; if (message instanceof ShortMessage && (((ShortMessage)message).getChannel() > 0xF)) { midimessages.put(timeStamp, message.clone()); } else { midimessages.put(timeStamp, message.getMessage()); } } } else { mainmixer.processMessage(message); } }
Example #6
Source File: GetReceiver2.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { AudioSynthesizer synth = new SoftSynthesizer(); Receiver recv = synth.getReceiver(); assertTrue(recv != null); ShortMessage sm = new ShortMessage(); sm.setMessage(ShortMessage.NOTE_OFF, 0, 64, 64); synth.open(new DummySourceDataLine(), null); recv.send(sm, -1); synth.close(); try { recv.send(sm, -1); throw new RuntimeException("Exception not thrown!"); } catch(Exception e) { // Just checking if exception is thrown } }
Example #7
Source File: SoftReceiver.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
public void send(MidiMessage message, long timeStamp) { synchronized (control_mutex) { if (!open) throw new IllegalStateException("Receiver is not open"); } if (timeStamp != -1) { synchronized (control_mutex) { mainmixer.activity(); while (midimessages.get(timeStamp) != null) timeStamp++; if (message instanceof ShortMessage && (((ShortMessage)message).getChannel() > 0xF)) { midimessages.put(timeStamp, message.clone()); } else { midimessages.put(timeStamp, message.getMessage()); } } } else { mainmixer.processMessage(message); } }
Example #8
Source File: GetReceiver2.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { AudioSynthesizer synth = new SoftSynthesizer(); Receiver recv = synth.getReceiver(); assertTrue(recv != null); ShortMessage sm = new ShortMessage(); sm.setMessage(ShortMessage.NOTE_OFF, 0, 64, 64); synth.open(new DummySourceDataLine(), null); recv.send(sm, -1); synth.close(); try { recv.send(sm, -1); throw new RuntimeException("Exception not thrown!"); } catch(Exception e) { // Just checking if exception is thrown } }
Example #9
Source File: GetReceiver2.java From hottub with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { AudioSynthesizer synth = new SoftSynthesizer(); Receiver recv = synth.getReceiver(); assertTrue(recv != null); ShortMessage sm = new ShortMessage(); sm.setMessage(ShortMessage.NOTE_OFF, 0, 64, 64); synth.open(new DummySourceDataLine(), null); recv.send(sm, -1); synth.close(); try { recv.send(sm, -1); throw new RuntimeException("Exception not thrown!"); } catch(Exception e) { // Just checking if exception is thrown } }
Example #10
Source File: MidiWaveformSynthesizer.java From chart-fx with Apache License 2.0 | 6 votes |
public static final void addNotesToTrack(final Track track, final Track trk) throws InvalidMidiDataException { for (int ii = 0; ii < track.size(); ii++) { final MidiEvent me = track.get(ii); final MidiMessage mm = me.getMessage(); if (mm instanceof ShortMessage) { final ShortMessage sm = (ShortMessage) mm; final int command = sm.getCommand(); int com = -1; if (command == ShortMessage.NOTE_ON) { com = LOCAL_NOTE_ON; } else if (command == ShortMessage.NOTE_OFF) { com = LOCAL_NOTE_OFF; } if (com > 0) { final byte[] b = sm.getMessage(); final int l = (b == null ? 0 : b.length); final MetaMessage metaMessage = new MetaMessage(com, b, l); final MidiEvent me2 = new MidiEvent(metaMessage, me.getTick()); trk.add(me2); } } } }
Example #11
Source File: SoftReceiver.java From hottub with GNU General Public License v2.0 | 6 votes |
public void send(MidiMessage message, long timeStamp) { synchronized (control_mutex) { if (!open) throw new IllegalStateException("Receiver is not open"); } if (timeStamp != -1) { synchronized (control_mutex) { mainmixer.activity(); while (midimessages.get(timeStamp) != null) timeStamp++; if (message instanceof ShortMessage && (((ShortMessage)message).getChannel() > 0xF)) { midimessages.put(timeStamp, message.clone()); } else { midimessages.put(timeStamp, message.getMessage()); } } } else { mainmixer.processMessage(message); } }
Example #12
Source File: SoftReceiver.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public void send(MidiMessage message, long timeStamp) { synchronized (control_mutex) { if (!open) throw new IllegalStateException("Receiver is not open"); } if (timeStamp != -1) { synchronized (control_mutex) { mainmixer.activity(); while (midimessages.get(timeStamp) != null) timeStamp++; if (message instanceof ShortMessage && (((ShortMessage)message).getChannel() > 0xF)) { midimessages.put(timeStamp, message.clone()); } else { midimessages.put(timeStamp, message.getMessage()); } } } else { mainmixer.processMessage(message); } }
Example #13
Source File: ClosedReceiver.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Execute Receiver.send() and expect that there is no exception. */ private static boolean testReceiverSend() { boolean result = true; Receiver receiver; ShortMessage shMsg = new ShortMessage(); try { receiver = MidiSystem.getReceiver(); shMsg.setMessage(ShortMessage.NOTE_ON, 0,60, 93); try { receiver.send( shMsg, -1 ); } catch(IllegalStateException ilEx) { ilEx.printStackTrace(System.out); out("IllegalStateException was thrown incorrectly!"); result = false; } receiver.close(); } catch(MidiUnavailableException e) { out("Midi unavailable, cannot test."); } catch(InvalidMidiDataException ine) { out("InvalidMidiDataException, cannot test."); } return result; }
Example #14
Source File: GetReceiver2.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { AudioSynthesizer synth = new SoftSynthesizer(); Receiver recv = synth.getReceiver(); assertTrue(recv != null); ShortMessage sm = new ShortMessage(); sm.setMessage(ShortMessage.NOTE_OFF, 0, 64, 64); synth.open(new DummySourceDataLine(), null); recv.send(sm, -1); synth.close(); try { recv.send(sm, -1); throw new RuntimeException("Exception not thrown!"); } catch(Exception e) { // Just checking if exception is thrown } }
Example #15
Source File: SoftReceiver.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public void send(MidiMessage message, long timeStamp) { synchronized (control_mutex) { if (!open) throw new IllegalStateException("Receiver is not open"); } if (timeStamp != -1) { synchronized (control_mutex) { mainmixer.activity(); while (midimessages.get(timeStamp) != null) timeStamp++; if (message instanceof ShortMessage && (((ShortMessage)message).getChannel() > 0xF)) { midimessages.put(timeStamp, message.clone()); } else { midimessages.put(timeStamp, message.getMessage()); } } } else { mainmixer.processMessage(message); } }
Example #16
Source File: SoftReceiver.java From tuxguitar with GNU Lesser General Public License v2.1 | 6 votes |
public void send(MidiMessage message, long timeStamp) { synchronized (control_mutex) { if (!open) throw new IllegalStateException("Receiver is not open"); } if (timeStamp != -1) { synchronized (control_mutex) { while (midimessages.get(timeStamp) != null) timeStamp++; if (message instanceof ShortMessage && (((ShortMessage)message).getChannel() > 0xF)) { midimessages.put(timeStamp, message.clone()); } else { midimessages.put(timeStamp, message.getMessage()); } } } else { mainmixer.processMessage(message); } }
Example #17
Source File: GetReceiver2.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { AudioSynthesizer synth = new SoftSynthesizer(); Receiver recv = synth.getReceiver(); assertTrue(recv != null); ShortMessage sm = new ShortMessage(); sm.setMessage(ShortMessage.NOTE_OFF, 0, 64, 64); synth.open(new DummySourceDataLine(), null); recv.send(sm, -1); synth.close(); try { recv.send(sm, -1); throw new RuntimeException("Exception not thrown!"); } catch(Exception e) { // Just checking if exception is thrown } }
Example #18
Source File: GetReceiver2.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { AudioSynthesizer synth = new SoftSynthesizer(); Receiver recv = synth.getReceiver(); assertTrue(recv != null); ShortMessage sm = new ShortMessage(); sm.setMessage(ShortMessage.NOTE_OFF, 0, 64, 64); synth.open(new DummySourceDataLine(), null); recv.send(sm, -1); synth.close(); try { recv.send(sm, -1); throw new RuntimeException("Exception not thrown!"); } catch(Exception e) { // Just checking if exception is thrown } }
Example #19
Source File: MiPort.java From tuxguitar with GNU Lesser General Public License v2.1 | 6 votes |
public void send(MidiMessage inMessage, long inTimeStamp) { if(inMessage instanceof ShortMessage) { ShortMessage mm = (ShortMessage)inMessage; switch(mm.getCommand()) { case ShortMessage.NOTE_ON: case ShortMessage.NOTE_OFF: MiProvider.instance().noteReceived(mm, inTimeStamp); break; case ShortMessage.CONTROL_CHANGE: //System.err.println("Control change"); break; } } }
Example #20
Source File: GetReceiver2.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { AudioSynthesizer synth = new SoftSynthesizer(); Receiver recv = synth.getReceiver(); assertTrue(recv != null); ShortMessage sm = new ShortMessage(); sm.setMessage(ShortMessage.NOTE_OFF, 0, 64, 64); synth.open(new DummySourceDataLine(), null); recv.send(sm, -1); synth.close(); try { recv.send(sm, -1); throw new RuntimeException("Exception not thrown!"); } catch(Exception e) { // Just checking if exception is thrown } }
Example #21
Source File: RealTimeSequencer.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
void notesOff(boolean doControllers) { int done = 0; for (int ch=0; ch<16; ch++) { int channelMask = (1<<ch); for (int i=0; i<128; i++) { if ((noteOnCache[i] & channelMask) != 0) { noteOnCache[i] ^= channelMask; // send note on with velocity 0 getTransmitterList().sendMessage((ShortMessage.NOTE_ON | ch) | (i<<8), -1); done++; } } /* all notes off */ getTransmitterList().sendMessage((ShortMessage.CONTROL_CHANGE | ch) | (123<<8), -1); /* sustain off */ getTransmitterList().sendMessage((ShortMessage.CONTROL_CHANGE | ch) | (64<<8), -1); if (doControllers) { /* reset all controllers */ getTransmitterList().sendMessage((ShortMessage.CONTROL_CHANGE | ch) | (121<<8), -1); done++; } } if (DEBUG_PUMP) Printer.println(" noteOff: sent "+done+" messages."); }
Example #22
Source File: RealTimeSequencer.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Send midi player events. */ void sendControllerEvents(MidiMessage message) { int size = controllerEventListeners.size(); if (size == 0) return; //if (Printer.debug) Printer.debug("sending a controller event"); if (! (message instanceof ShortMessage)) { if (Printer.debug) Printer.debug("sendControllerEvents: message is NOT instanceof ShortMessage!"); return; } ShortMessage msg = (ShortMessage) message; int controller = msg.getData1(); List<Object> sendToListeners = new ArrayList<>(); for (int i = 0; i < size; i++) { ControllerListElement cve = controllerEventListeners.get(i); for(int j = 0; j < cve.controllers.length; j++) { if (cve.controllers[j] == controller) { sendToListeners.add(cve.listener); break; } } } getEventDispatcher().sendAudioEvents(message, sendToListeners); }
Example #23
Source File: SoftReceiver.java From Bytecoder with Apache License 2.0 | 6 votes |
@Override public void send(MidiMessage message, long timeStamp) { synchronized (control_mutex) { if (!open) throw new IllegalStateException("Receiver is not open"); } if (timeStamp != -1) { synchronized (control_mutex) { mainmixer.activity(); while (midimessages.get(timeStamp) != null) timeStamp++; if (message instanceof ShortMessage && (((ShortMessage)message).getChannel() > 0xF)) { midimessages.put(timeStamp, message.clone()); } else { midimessages.put(timeStamp, message.getMessage()); } } } else { mainmixer.processMessage(message); } }
Example #24
Source File: SoftMainMixer.java From hottub with GNU General Public License v2.0 | 5 votes |
public void processMessage(MidiMessage message) { if (message instanceof ShortMessage) { ShortMessage sms = (ShortMessage)message; processMessage(sms.getChannel(), sms.getCommand(), sms.getData1(), sms.getData2()); return; } processMessage(message.getMessage()); }
Example #25
Source File: SoftMainMixer.java From tuxguitar with GNU Lesser General Public License v2.1 | 5 votes |
public void processMessage(MidiMessage message) { if (message instanceof ShortMessage) { ShortMessage sms = (ShortMessage)message; processMessage(sms.getChannel(), sms.getCommand(), sms.getData1(), sms.getData2()); return; } processMessage(message.getMessage()); }
Example #26
Source File: SoftMainMixer.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public void processMessage(MidiMessage message) { if (message instanceof ShortMessage) { ShortMessage sms = (ShortMessage)message; processMessage(sms.getChannel(), sms.getCommand(), sms.getData1(), sms.getData2()); return; } processMessage(message.getMessage()); }
Example #27
Source File: SoftMainMixer.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public void processMessage(MidiMessage message) { if (message instanceof ShortMessage) { ShortMessage sms = (ShortMessage)message; processMessage(sms.getChannel(), sms.getCommand(), sms.getData1(), sms.getData2()); return; } processMessage(message.getMessage()); }
Example #28
Source File: MidiSynth.java From jmg with GNU General Public License v2.0 | 5 votes |
/** * Create a Note On Event * @param int channel is the channel to change * @param int pitch is the pitch of the note * @param int velocity is the velocity of the note * @param long tick is the time this event occurs */ protected static MidiEvent createNoteOnEvent(int channel, int pitch, int velocity, long tick) throws InvalidMidiDataException { ShortMessage msg = new ShortMessage(); msg.setMessage(0x90 + channel, pitch, velocity); MidiEvent evt = new MidiEvent(msg, tick); return evt; }
Example #29
Source File: FinnwMusicModule.java From mochadoom with GNU General Public License v3.0 | 5 votes |
private void addShortMessage(int midiChan, int cmd, int data1, int data2) { try { ShortMessage msg = new ShortMessage(); msg.setMessage(cmd, midiChan, data1, data2); messages.add(msg); } catch (InvalidMidiDataException ex) { throw new RuntimeException(ex); } }
Example #30
Source File: MidiMessageUtils.java From tuxguitar with GNU Lesser General Public License v2.1 | 5 votes |
public static MidiMessage programChange(int channel,int instrument){ try { ShortMessage message = new ShortMessage(); message.setMessage(ShortMessage.PROGRAM_CHANGE, fixChannel(channel), fixValue(instrument), 0); return message; } catch (InvalidMidiDataException e) { e.printStackTrace(); } return null; }