Java Code Examples for javax.sound.midi.Receiver#close()
The following examples show how to use
javax.sound.midi.Receiver#close() .
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: 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 2
Source File: GetReceivers.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { AudioSynthesizer synth = new SoftSynthesizer(); synth.open(new DummySourceDataLine(), null); assertTrue(synth.getReceivers().size() == 0); Receiver recv = synth.getReceiver(); assertTrue(synth.getReceivers().size() == 1); recv.close(); assertTrue(synth.getReceivers().size() == 0); synth.close(); }
Example 3
Source File: GetReceivers.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { AudioSynthesizer synth = new SoftSynthesizer(); synth.open(new DummySourceDataLine(), null); assertTrue(synth.getReceivers().size() == 0); Receiver recv = synth.getReceiver(); assertTrue(synth.getReceivers().size() == 1); recv.close(); assertTrue(synth.getReceivers().size() == 0); synth.close(); }
Example 4
Source File: GetReceivers.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { AudioSynthesizer synth = new SoftSynthesizer(); synth.open(new DummySourceDataLine(), null); assertTrue(synth.getReceivers().size() == 0); Receiver recv = synth.getReceiver(); assertTrue(synth.getReceivers().size() == 1); recv.close(); assertTrue(synth.getReceivers().size() == 0); synth.close(); }
Example 5
Source File: GetReceivers.java From hottub with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { AudioSynthesizer synth = new SoftSynthesizer(); synth.open(new DummySourceDataLine(), null); assertTrue(synth.getReceivers().size() == 0); Receiver recv = synth.getReceiver(); assertTrue(synth.getReceivers().size() == 1); recv.close(); assertTrue(synth.getReceivers().size() == 0); synth.close(); }
Example 6
Source File: GetReceivers.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { AudioSynthesizer synth = new SoftSynthesizer(); synth.open(new DummySourceDataLine(), null); assertTrue(synth.getReceivers().size() == 0); Receiver recv = synth.getReceiver(); assertTrue(synth.getReceivers().size() == 1); recv.close(); assertTrue(synth.getReceivers().size() == 0); synth.close(); }
Example 7
Source File: GetReceivers.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { AudioSynthesizer synth = new SoftSynthesizer(); synth.open(new DummySourceDataLine(), null); assertTrue(synth.getReceivers().size() == 0); Receiver recv = synth.getReceiver(); assertTrue(synth.getReceivers().size() == 1); recv.close(); assertTrue(synth.getReceivers().size() == 0); synth.close(); }
Example 8
Source File: GetReceivers.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { AudioSynthesizer synth = new SoftSynthesizer(); synth.open(new DummySourceDataLine(), null); assertTrue(synth.getReceivers().size() == 0); Receiver recv = synth.getReceiver(); assertTrue(synth.getReceivers().size() == 1); recv.close(); assertTrue(synth.getReceivers().size() == 0); synth.close(); }
Example 9
Source File: GetReceivers.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { AudioSynthesizer synth = new SoftSynthesizer(); synth.open(new DummySourceDataLine(), null); assertTrue(synth.getReceivers().size() == 0); Receiver recv = synth.getReceiver(); assertTrue(synth.getReceivers().size() == 1); recv.close(); assertTrue(synth.getReceivers().size() == 0); synth.close(); }
Example 10
Source File: GetReceivers.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { AudioSynthesizer synth = new SoftSynthesizer(); synth.open(new DummySourceDataLine(), null); assertTrue(synth.getReceivers().size() == 0); Receiver recv = synth.getReceiver(); assertTrue(synth.getReceivers().size() == 1); recv.close(); assertTrue(synth.getReceivers().size() == 0); synth.close(); }
Example 11
Source File: GetReceivers.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { AudioSynthesizer synth = new SoftSynthesizer(); synth.open(new DummySourceDataLine(), null); assertTrue(synth.getReceivers().size() == 0); Receiver recv = synth.getReceiver(); assertTrue(synth.getReceivers().size() == 1); recv.close(); assertTrue(synth.getReceivers().size() == 0); synth.close(); }
Example 12
Source File: ImplicitOpenClose.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { Field f = SoftSynthesizer.class.getDeclaredField("testline"); f.setAccessible(true); f.set(null, new DummySourceDataLine()); Synthesizer synth = new SoftSynthesizer(); ReferenceCountingDevice rcd = (ReferenceCountingDevice)synth; // Test single open/close cycle Receiver recv = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); // Test using 2 receiver cycle Receiver recv1 = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); Receiver recv2 = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv2.close(); if(!synth.isOpen()) throw new Exception("Synthesizer was closed!"); recv1.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); // Test for explicit,implicit conflict synth.open(); Receiver recv3 = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv3.close(); if(!synth.isOpen()) throw new Exception("Synthesizer was closed!"); synth.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); // Test for implicit,explicit conflict recv3 = rcd.getReceiverReferenceCounting(); synth.open(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv3.close(); if(!synth.isOpen()) throw new Exception("Synthesizer was closed!"); synth.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); }
Example 13
Source File: ImplicitOpenClose.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { Field f = SoftSynthesizer.class.getDeclaredField("testline"); f.setAccessible(true); f.set(null, new DummySourceDataLine()); Synthesizer synth = new SoftSynthesizer(); ReferenceCountingDevice rcd = (ReferenceCountingDevice)synth; // Test single open/close cycle Receiver recv = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); // Test using 2 receiver cycle Receiver recv1 = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); Receiver recv2 = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv2.close(); if(!synth.isOpen()) throw new Exception("Synthesizer was closed!"); recv1.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); // Test for explicit,implicit conflict synth.open(); Receiver recv3 = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv3.close(); if(!synth.isOpen()) throw new Exception("Synthesizer was closed!"); synth.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); // Test for implicit,explicit conflict recv3 = rcd.getReceiverReferenceCounting(); synth.open(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv3.close(); if(!synth.isOpen()) throw new Exception("Synthesizer was closed!"); synth.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); }
Example 14
Source File: ImplicitOpenClose.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { Field f = SoftSynthesizer.class.getDeclaredField("testline"); f.setAccessible(true); f.set(null, new DummySourceDataLine()); Synthesizer synth = new SoftSynthesizer(); ReferenceCountingDevice rcd = (ReferenceCountingDevice)synth; // Test single open/close cycle Receiver recv = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); // Test using 2 receiver cycle Receiver recv1 = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); Receiver recv2 = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv2.close(); if(!synth.isOpen()) throw new Exception("Synthesizer was closed!"); recv1.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); // Test for explicit,implicit conflict synth.open(); Receiver recv3 = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv3.close(); if(!synth.isOpen()) throw new Exception("Synthesizer was closed!"); synth.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); // Test for implicit,explicit conflict recv3 = rcd.getReceiverReferenceCounting(); synth.open(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv3.close(); if(!synth.isOpen()) throw new Exception("Synthesizer was closed!"); synth.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); }
Example 15
Source File: ImplicitOpenClose.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { Field f = SoftSynthesizer.class.getDeclaredField("testline"); f.setAccessible(true); f.set(null, new DummySourceDataLine()); Synthesizer synth = new SoftSynthesizer(); ReferenceCountingDevice rcd = (ReferenceCountingDevice)synth; // Test single open/close cycle Receiver recv = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); // Test using 2 receiver cycle Receiver recv1 = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); Receiver recv2 = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv2.close(); if(!synth.isOpen()) throw new Exception("Synthesizer was closed!"); recv1.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); // Test for explicit,implicit conflict synth.open(); Receiver recv3 = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv3.close(); if(!synth.isOpen()) throw new Exception("Synthesizer was closed!"); synth.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); // Test for implicit,explicit conflict recv3 = rcd.getReceiverReferenceCounting(); synth.open(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv3.close(); if(!synth.isOpen()) throw new Exception("Synthesizer was closed!"); synth.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); }
Example 16
Source File: ImplicitOpenClose.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { Field f = SoftSynthesizer.class.getDeclaredField("testline"); f.setAccessible(true); f.set(null, new DummySourceDataLine()); Synthesizer synth = new SoftSynthesizer(); ReferenceCountingDevice rcd = (ReferenceCountingDevice)synth; // Test single open/close cycle Receiver recv = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); // Test using 2 receiver cycle Receiver recv1 = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); Receiver recv2 = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv2.close(); if(!synth.isOpen()) throw new Exception("Synthesizer was closed!"); recv1.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); // Test for explicit,implicit conflict synth.open(); Receiver recv3 = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv3.close(); if(!synth.isOpen()) throw new Exception("Synthesizer was closed!"); synth.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); // Test for implicit,explicit conflict recv3 = rcd.getReceiverReferenceCounting(); synth.open(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv3.close(); if(!synth.isOpen()) throw new Exception("Synthesizer was closed!"); synth.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); }
Example 17
Source File: ImplicitOpenClose.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { Field f = SoftSynthesizer.class.getDeclaredField("testline"); f.setAccessible(true); f.set(null, new DummySourceDataLine()); Synthesizer synth = new SoftSynthesizer(); ReferenceCountingDevice rcd = (ReferenceCountingDevice)synth; // Test single open/close cycle Receiver recv = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); // Test using 2 receiver cycle Receiver recv1 = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); Receiver recv2 = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv2.close(); if(!synth.isOpen()) throw new Exception("Synthesizer was closed!"); recv1.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); // Test for explicit,implicit conflict synth.open(); Receiver recv3 = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv3.close(); if(!synth.isOpen()) throw new Exception("Synthesizer was closed!"); synth.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); // Test for implicit,explicit conflict recv3 = rcd.getReceiverReferenceCounting(); synth.open(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv3.close(); if(!synth.isOpen()) throw new Exception("Synthesizer was closed!"); synth.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); }
Example 18
Source File: ImplicitOpenClose.java From hottub with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { Field f = SoftSynthesizer.class.getDeclaredField("testline"); f.setAccessible(true); f.set(null, new DummySourceDataLine()); Synthesizer synth = new SoftSynthesizer(); ReferenceCountingDevice rcd = (ReferenceCountingDevice)synth; // Test single open/close cycle Receiver recv = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); // Test using 2 receiver cycle Receiver recv1 = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); Receiver recv2 = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv2.close(); if(!synth.isOpen()) throw new Exception("Synthesizer was closed!"); recv1.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); // Test for explicit,implicit conflict synth.open(); Receiver recv3 = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv3.close(); if(!synth.isOpen()) throw new Exception("Synthesizer was closed!"); synth.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); // Test for implicit,explicit conflict recv3 = rcd.getReceiverReferenceCounting(); synth.open(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv3.close(); if(!synth.isOpen()) throw new Exception("Synthesizer was closed!"); synth.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); }
Example 19
Source File: ImplicitOpenClose.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { Field f = SoftSynthesizer.class.getDeclaredField("testline"); f.setAccessible(true); f.set(null, new DummySourceDataLine()); Synthesizer synth = new SoftSynthesizer(); ReferenceCountingDevice rcd = (ReferenceCountingDevice)synth; // Test single open/close cycle Receiver recv = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); // Test using 2 receiver cycle Receiver recv1 = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); Receiver recv2 = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv2.close(); if(!synth.isOpen()) throw new Exception("Synthesizer was closed!"); recv1.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); // Test for explicit,implicit conflict synth.open(); Receiver recv3 = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv3.close(); if(!synth.isOpen()) throw new Exception("Synthesizer was closed!"); synth.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); // Test for implicit,explicit conflict recv3 = rcd.getReceiverReferenceCounting(); synth.open(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv3.close(); if(!synth.isOpen()) throw new Exception("Synthesizer was closed!"); synth.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); }
Example 20
Source File: ImplicitOpenClose.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { Field f = SoftSynthesizer.class.getDeclaredField("testline"); f.setAccessible(true); f.set(null, new DummySourceDataLine()); Synthesizer synth = new SoftSynthesizer(); ReferenceCountingDevice rcd = (ReferenceCountingDevice)synth; // Test single open/close cycle Receiver recv = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); // Test using 2 receiver cycle Receiver recv1 = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); Receiver recv2 = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv2.close(); if(!synth.isOpen()) throw new Exception("Synthesizer was closed!"); recv1.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); // Test for explicit,implicit conflict synth.open(); Receiver recv3 = rcd.getReceiverReferenceCounting(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv3.close(); if(!synth.isOpen()) throw new Exception("Synthesizer was closed!"); synth.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); // Test for implicit,explicit conflict recv3 = rcd.getReceiverReferenceCounting(); synth.open(); if(!synth.isOpen()) throw new Exception("Synthesizer not open!"); recv3.close(); if(!synth.isOpen()) throw new Exception("Synthesizer was closed!"); synth.close(); if(synth.isOpen()) throw new Exception("Synthesizer not closed!"); }