Java Code Examples for javax.sound.midi.MidiUnavailableException#printStackTrace()
The following examples show how to use
javax.sound.midi.MidiUnavailableException#printStackTrace() .
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: MidiDeviceTools.java From jsyn with Apache License 2.0 | 6 votes |
/** Print the available MIDI Devices. */ public static void listDevices() { // Ask the MidiSystem what is available. MidiDevice.Info[] infos = MidiSystem.getMidiDeviceInfo(); // Print info about each device. for (MidiDevice.Info info : infos) { System.out.println("MIDI Info: " + info.getDescription() + ", " + info.getName() + ", " + info.getVendor() + ", " + info.getVersion()); // Get the device for more information. try { MidiDevice device = MidiSystem.getMidiDevice(info); System.out.println(" Device: " + ", #recv = " + device.getMaxReceivers() + ", #xmit = " + device.getMaxTransmitters() + ", open = " + device.isOpen() + ", " + device); } catch (MidiUnavailableException e) { e.printStackTrace(); } } }
Example 2
Source File: MidiApp.java From FXTutorials with MIT License | 6 votes |
private void loadChannel() { try { Synthesizer synth = MidiSystem.getSynthesizer(); synth.open(); synth.loadInstrument(synth.getDefaultSoundbank().getInstruments()[5]); channel = synth.getChannels()[0]; } catch (MidiUnavailableException e) { System.out.println("Cannot get synth"); e.printStackTrace(); } }
Example 3
Source File: JavaSoundAudioClip.java From Bytecoder with Apache License 2.0 | 6 votes |
private boolean createSequencer(BufferedInputStream in) throws IOException { // get the sequencer try { sequencer = MidiSystem.getSequencer( ); } catch(MidiUnavailableException me) { if (Printer.err) me.printStackTrace(); return false; } if (sequencer==null) { return false; } try { sequence = MidiSystem.getSequence(in); if (sequence == null) { return false; } } catch (InvalidMidiDataException e) { if (Printer.err) e.printStackTrace(); return false; } return true; }
Example 4
Source File: MidiSender.java From EWItool with GNU General Public License v3.0 | 6 votes |
MidiSender( SharedData pSharedData, MidiDevice pOutDev ) { sharedData = pSharedData; msgQ = pSharedData.sendQ; outDev = pOutDev; if (!outDev.isOpen()) { System.err.println( "Error - MidiSender() called with non-open MIDI Device" ); System.exit( 1 ); } try { receiver = outDev.getReceiver(); } catch (MidiUnavailableException e) { e.printStackTrace(); System.err.println( "Error - MidiSender() could not obtain chosen MIDI OUT receiver" ); System.exit( 1 ); } mmsg = new MidiMonitorMessage(); mmsg.direction = MidiMonitorMessage.MidiDirection.SENT; }
Example 5
Source File: JavaSoundAudioClip.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private boolean createSequencer(BufferedInputStream in) throws IOException { if (DEBUG || Printer.debug)Printer.debug("JavaSoundAudioClip.createSequencer()"); // get the sequencer try { sequencer = MidiSystem.getSequencer( ); } catch(MidiUnavailableException me) { if (DEBUG || Printer.err)me.printStackTrace(); return false; } if (sequencer==null) { return false; } try { sequence = MidiSystem.getSequence(in); if (sequence == null) { return false; } } catch (InvalidMidiDataException e) { if (DEBUG || Printer.err)e.printStackTrace(); return false; } if (DEBUG || Printer.debug)Printer.debug("Created Sequencer."); return true; }
Example 6
Source File: MidiDeviceTools.java From jsyn with Apache License 2.0 | 5 votes |
/** Find a MIDI transmitter that contains text in the name. */ public static MidiDevice findKeyboard(String text) { MidiDevice keyboard = null; // Ask the MidiSystem what is available. MidiDevice.Info[] infos = MidiSystem.getMidiDeviceInfo(); // Print info about each device. for (MidiDevice.Info info : infos) { try { MidiDevice device = MidiSystem.getMidiDevice(info); // Hardware devices are not Synthesizers or Sequencers. if (!(device instanceof Synthesizer) && !(device instanceof Sequencer)) { // Is this a transmitter? // Might be -1 if unlimited. if (device.getMaxTransmitters() != 0) { if ((text == null) || (info.getDescription().toLowerCase() .contains(text.toLowerCase()))) { keyboard = device; System.out.println("Chose: " + info.getDescription()); break; } } } } catch (MidiUnavailableException e) { e.printStackTrace(); } } return keyboard; }
Example 7
Source File: JavaSoundAudioClip.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
private boolean createSequencer(BufferedInputStream in) throws IOException { if (DEBUG || Printer.debug)Printer.debug("JavaSoundAudioClip.createSequencer()"); // get the sequencer try { sequencer = MidiSystem.getSequencer( ); } catch(MidiUnavailableException me) { if (DEBUG || Printer.err)me.printStackTrace(); return false; } if (sequencer==null) { return false; } try { sequence = MidiSystem.getSequence(in); if (sequence == null) { return false; } } catch (InvalidMidiDataException e) { if (DEBUG || Printer.err)e.printStackTrace(); return false; } if (DEBUG || Printer.debug)Printer.debug("Created Sequencer."); return true; }
Example 8
Source File: JavaSoundAudioClip.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private boolean createSequencer(BufferedInputStream in) throws IOException { if (DEBUG || Printer.debug)Printer.debug("JavaSoundAudioClip.createSequencer()"); // get the sequencer try { sequencer = MidiSystem.getSequencer( ); } catch(MidiUnavailableException me) { if (DEBUG || Printer.err)me.printStackTrace(); return false; } if (sequencer==null) { return false; } try { sequence = MidiSystem.getSequence(in); if (sequence == null) { return false; } } catch (InvalidMidiDataException e) { if (DEBUG || Printer.err)e.printStackTrace(); return false; } if (DEBUG || Printer.debug)Printer.debug("Created Sequencer."); return true; }
Example 9
Source File: JavaSoundAudioClip.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private boolean createSequencer(BufferedInputStream in) throws IOException { if (DEBUG || Printer.debug)Printer.debug("JavaSoundAudioClip.createSequencer()"); // get the sequencer try { sequencer = MidiSystem.getSequencer( ); } catch(MidiUnavailableException me) { if (DEBUG || Printer.err)me.printStackTrace(); return false; } if (sequencer==null) { return false; } try { sequence = MidiSystem.getSequence(in); if (sequence == null) { return false; } } catch (InvalidMidiDataException e) { if (DEBUG || Printer.err)e.printStackTrace(); return false; } if (DEBUG || Printer.debug)Printer.debug("Created Sequencer."); return true; }
Example 10
Source File: JavaSoundAudioClip.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private boolean createSequencer(BufferedInputStream in) throws IOException { if (DEBUG || Printer.debug)Printer.debug("JavaSoundAudioClip.createSequencer()"); // get the sequencer try { sequencer = MidiSystem.getSequencer( ); } catch(MidiUnavailableException me) { if (DEBUG || Printer.err)me.printStackTrace(); return false; } if (sequencer==null) { return false; } try { sequence = MidiSystem.getSequence(in); if (sequence == null) { return false; } } catch (InvalidMidiDataException e) { if (DEBUG || Printer.err)e.printStackTrace(); return false; } if (DEBUG || Printer.debug)Printer.debug("Created Sequencer."); return true; }
Example 11
Source File: JavaSoundAudioClip.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private boolean createSequencer(BufferedInputStream in) throws IOException { if (DEBUG || Printer.debug)Printer.debug("JavaSoundAudioClip.createSequencer()"); // get the sequencer try { sequencer = MidiSystem.getSequencer( ); } catch(MidiUnavailableException me) { if (DEBUG || Printer.err)me.printStackTrace(); return false; } if (sequencer==null) { return false; } try { sequence = MidiSystem.getSequence(in); if (sequence == null) { return false; } } catch (InvalidMidiDataException e) { if (DEBUG || Printer.err)e.printStackTrace(); return false; } if (DEBUG || Printer.debug)Printer.debug("Created Sequencer."); return true; }
Example 12
Source File: JavaSoundAudioClip.java From hottub with GNU General Public License v2.0 | 5 votes |
private boolean createSequencer(BufferedInputStream in) throws IOException { if (DEBUG || Printer.debug)Printer.debug("JavaSoundAudioClip.createSequencer()"); // get the sequencer try { sequencer = MidiSystem.getSequencer( ); } catch(MidiUnavailableException me) { if (DEBUG || Printer.err)me.printStackTrace(); return false; } if (sequencer==null) { return false; } try { sequence = MidiSystem.getSequence(in); if (sequence == null) { return false; } } catch (InvalidMidiDataException e) { if (DEBUG || Printer.err)e.printStackTrace(); return false; } if (DEBUG || Printer.debug)Printer.debug("Created Sequencer."); return true; }
Example 13
Source File: JavaSoundAudioClip.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private boolean createSequencer(BufferedInputStream in) throws IOException { if (DEBUG || Printer.debug)Printer.debug("JavaSoundAudioClip.createSequencer()"); // get the sequencer try { sequencer = MidiSystem.getSequencer( ); } catch(MidiUnavailableException me) { if (DEBUG || Printer.err)me.printStackTrace(); return false; } if (sequencer==null) { return false; } try { sequence = MidiSystem.getSequence(in); if (sequence == null) { return false; } } catch (InvalidMidiDataException e) { if (DEBUG || Printer.err)e.printStackTrace(); return false; } if (DEBUG || Printer.debug)Printer.debug("Created Sequencer."); return true; }
Example 14
Source File: JavaSoundAudioClip.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private boolean createSequencer(BufferedInputStream in) throws IOException { if (DEBUG || Printer.debug)Printer.debug("JavaSoundAudioClip.createSequencer()"); // get the sequencer try { sequencer = MidiSystem.getSequencer( ); } catch(MidiUnavailableException me) { if (DEBUG || Printer.err)me.printStackTrace(); return false; } if (sequencer==null) { return false; } try { sequence = MidiSystem.getSequence(in); if (sequence == null) { return false; } } catch (InvalidMidiDataException e) { if (DEBUG || Printer.err)e.printStackTrace(); return false; } if (DEBUG || Printer.debug)Printer.debug("Created Sequencer."); return true; }
Example 15
Source File: JavaSoundAudioClip.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private boolean createSequencer(BufferedInputStream in) throws IOException { if (DEBUG || Printer.debug)Printer.debug("JavaSoundAudioClip.createSequencer()"); // get the sequencer try { sequencer = MidiSystem.getSequencer( ); } catch(MidiUnavailableException me) { if (DEBUG || Printer.err)me.printStackTrace(); return false; } if (sequencer==null) { return false; } try { sequence = MidiSystem.getSequence(in); if (sequence == null) { return false; } } catch (InvalidMidiDataException e) { if (DEBUG || Printer.err)e.printStackTrace(); return false; } if (DEBUG || Printer.debug)Printer.debug("Created Sequencer."); return true; }
Example 16
Source File: JavaSoundAudioClip.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private boolean createSequencer(BufferedInputStream in) throws IOException { if (DEBUG || Printer.debug)Printer.debug("JavaSoundAudioClip.createSequencer()"); // get the sequencer try { sequencer = MidiSystem.getSequencer( ); } catch(MidiUnavailableException me) { if (DEBUG || Printer.err)me.printStackTrace(); return false; } if (sequencer==null) { return false; } try { sequence = MidiSystem.getSequence(in); if (sequence == null) { return false; } } catch (InvalidMidiDataException e) { if (DEBUG || Printer.err)e.printStackTrace(); return false; } if (DEBUG || Printer.debug)Printer.debug("Created Sequencer."); return true; }
Example 17
Source File: JavaSoundAudioClip.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private boolean createSequencer(BufferedInputStream in) throws IOException { if (DEBUG || Printer.debug)Printer.debug("JavaSoundAudioClip.createSequencer()"); // get the sequencer try { sequencer = MidiSystem.getSequencer( ); } catch(MidiUnavailableException me) { if (DEBUG || Printer.err)me.printStackTrace(); return false; } if (sequencer==null) { return false; } try { sequence = MidiSystem.getSequence(in); if (sequence == null) { return false; } } catch (InvalidMidiDataException e) { if (DEBUG || Printer.err)e.printStackTrace(); return false; } if (DEBUG || Printer.debug)Printer.debug("Created Sequencer."); return true; }
Example 18
Source File: JavaSoundAudioClip.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private boolean createSequencer(BufferedInputStream in) throws IOException { if (DEBUG || Printer.debug)Printer.debug("JavaSoundAudioClip.createSequencer()"); // get the sequencer try { sequencer = MidiSystem.getSequencer( ); } catch(MidiUnavailableException me) { if (DEBUG || Printer.err)me.printStackTrace(); return false; } if (sequencer==null) { return false; } try { sequence = MidiSystem.getSequence(in); if (sequence == null) { return false; } } catch (InvalidMidiDataException e) { if (DEBUG || Printer.err)e.printStackTrace(); return false; } if (DEBUG || Printer.debug)Printer.debug("Created Sequencer."); return true; }
Example 19
Source File: DefaultDevices.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private static boolean testDevices(MidiDevice.Info[] infos, String providerClassName) { boolean allOk = true; for (int i = 0; i < infos.length; i++) { MidiDevice device = null; try { device = MidiSystem.getMidiDevice(infos[i]); } catch (MidiUnavailableException e) { out("Exception thrown; Test NOT failed."); e.printStackTrace(System.out); out(""); } out("\nTesting device: " + device); if (device instanceof Sequencer) { allOk &= testDevice(device, SEQUENCER_CLASS, providerClassName, true, true); // incorrect cases allOk &= testDevice(device, SYNTHESIZER_CLASS, providerClassName, false, false); allOk &= testDevice(device, RECEIVER_CLASS, providerClassName, false, false); allOk &= testDevice(device, TRANSMITTER_CLASS, providerClassName, false, false); } if (device instanceof Synthesizer) { allOk &= testDevice(device, SYNTHESIZER_CLASS, providerClassName, true, true); allOk &= testDevice(device, RECEIVER_CLASS, providerClassName, false, true); // incorrect cases allOk &= testDevice(device, TRANSMITTER_CLASS, providerClassName, false, false); allOk &= testDevice(device, SEQUENCER_CLASS, providerClassName, false, false); } if (device instanceof Receiver) { allOk &= testDevice(device, RECEIVER_CLASS, providerClassName, true, true); // incorrect cases allOk &= testDevice(device, TRANSMITTER_CLASS, providerClassName, false, false); allOk &= testDevice(device, SYNTHESIZER_CLASS, providerClassName, false, false); allOk &= testDevice(device, SEQUENCER_CLASS, providerClassName, false, false); } if (device instanceof Transmitter) { allOk &= testDevice(device, TRANSMITTER_CLASS, providerClassName, true, true); // incorrect cases allOk &= testDevice(device, RECEIVER_CLASS, providerClassName, false, false); allOk &= testDevice(device, SYNTHESIZER_CLASS, providerClassName, false, false); allOk &= testDevice(device, SEQUENCER_CLASS, providerClassName, false, false); } } return allOk; }
Example 20
Source File: PortsItemEventHandler.java From EWItool with GNU General Public License v3.0 | 4 votes |
@Override public void handle( ActionEvent arg0 ) { Dialog<ButtonType> dialog = new Dialog<>(); dialog.setTitle( "EWItool - Select MIDI Ports" ); dialog.getDialogPane().getButtonTypes().addAll( ButtonType.CANCEL, ButtonType.OK ); GridPane gp = new GridPane(); gp.add( new Label( "MIDI In Ports" ), 0, 0 ); gp.add( new Label( "MIDI Out Ports" ), 1, 0 ); ListView<String> inView, outView; List<String> inPortList = new ArrayList<>(), outPortList = new ArrayList<>(); ObservableList<String> inPorts = FXCollections.observableArrayList( inPortList ), outPorts = FXCollections.observableArrayList( outPortList ); inView = new ListView<>( inPorts ); outView = new ListView<>( outPorts ); String lastInDevice = userPrefs.getMidiInPort(); String lastOutDevice = userPrefs.getMidiOutPort(); int ipIx = -1, opIx = -1; MidiDevice device; MidiDevice.Info[] infos = MidiSystem.getMidiDeviceInfo(); for ( MidiDevice.Info info : infos ) { try { device = MidiSystem.getMidiDevice( info ); if (!( device instanceof Sequencer ) && !( device instanceof Synthesizer )) { if (device.getMaxReceivers() != 0) { opIx++; outPorts.add( info.getName() ); if (info.getName().equals( lastOutDevice )) { outView.getSelectionModel().clearAndSelect( opIx ); } Debugger.log( "DEBUG - Found OUT Port: " + info.getName() + " - " + info.getDescription() ); } else if (device.getMaxTransmitters() != 0) { ipIx++; inPorts.add( info.getName() ); if (info.getName().equals( lastInDevice )) { inView.getSelectionModel().clearAndSelect( ipIx ); } Debugger.log( "DEBUG - Found IN Port: " + info.getName() + " - " + info.getDescription() ); } } } catch (MidiUnavailableException ex) { ex.printStackTrace(); } } gp.add( inView, 0, 1 ); gp.add( outView, 1, 1 ); dialog.getDialogPane().setContent( gp ); Optional<ButtonType> rc = dialog.showAndWait(); if (rc.get() == ButtonType.OK) { if (outView.getSelectionModel().getSelectedIndex() != -1) { userPrefs.setMidiOutPort( outView.getSelectionModel().getSelectedItem() ); } if (inView.getSelectionModel().getSelectedIndex() != -1) { userPrefs.setMidiInPort( inView.getSelectionModel().getSelectedItem() ); } } }