javax.sound.midi.Sequencer Java Examples

The following examples show how to use javax.sound.midi.Sequencer. 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: SequencerImplicitSynthOpen.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
static boolean test(Sequencer sequencer) throws MidiUnavailableException {
    log("");
    log("opening sequencer...");
    sequencer.open();   // opens connected synthesizer implicitly
    MidiDevice synth = getConnectedDevice(sequencer);
    log("  connected device: " + getDeviceStr(synth));

    log("closing sequencer...");
    sequencer.close();  // closes the synth implicitly
    log("  synth is " + getDeviceStr(synth));
    MidiDevice synth2 = getConnectedDevice(sequencer);
    log("  currently connected device: " + getDeviceStr(synth2));

    if (synth != null && synth.isOpen()) {
        log("FAIL.");
        return false;
    }
    log("OK.");
    return true;
}
 
Example #2
Source File: SequencerImplicitSynthOpen.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
static MidiDevice getConnectedDevice(Sequencer sequencer) {
    List<Transmitter> trans = sequencer.getTransmitters();
    log("  sequencer has " + trans.size() + " opened transmitters:");
    for (Transmitter tr: trans) {
        Receiver r = tr.getReceiver();
        log("    " + getClassStr(tr) + " connected to " + getClassStr(r));
        if (r instanceof MidiDeviceReceiver) {
            MidiDeviceReceiver recv = (MidiDeviceReceiver)r;
            MidiDevice dev = recv.getMidiDevice();
            log("      - receiver of " + getClassStr(dev));
            return dev;
        } else {
            log("      - does NOT implement MidiDeviceReceiver");
        }
    }
    return null;
}
 
Example #3
Source File: SequencerImplicitSynthOpen.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
static MidiDevice getConnectedDevice(Sequencer sequencer) {
    List<Transmitter> trans = sequencer.getTransmitters();
    log("  sequencer has " + trans.size() + " opened transmitters:");
    for (Transmitter tr: trans) {
        Receiver r = tr.getReceiver();
        log("    " + getClassStr(tr) + " connected to " + getClassStr(r));
        if (r instanceof MidiDeviceReceiver) {
            MidiDeviceReceiver recv = (MidiDeviceReceiver)r;
            MidiDevice dev = recv.getMidiDevice();
            log("      - receiver of " + getClassStr(dev));
            return dev;
        } else {
            log("      - does NOT implement MidiDeviceReceiver");
        }
    }
    return null;
}
 
Example #4
Source File: JDK13Services.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/** Obtain the value of a default provider property.
    @param typeClass The type of the default provider property. This
    should be one of Receiver.class, Transmitter.class, Sequencer.class,
    Synthesizer.class, SourceDataLine.class, TargetDataLine.class,
    Clip.class or Port.class.
    @return The complete value of the property, if available.
    If the property is not set, null is returned.
 */
private static synchronized String getDefaultProvider(Class typeClass) {
    if (!SourceDataLine.class.equals(typeClass)
            && !TargetDataLine.class.equals(typeClass)
            && !Clip.class.equals(typeClass)
            && !Port.class.equals(typeClass)
            && !Receiver.class.equals(typeClass)
            && !Transmitter.class.equals(typeClass)
            && !Synthesizer.class.equals(typeClass)
            && !Sequencer.class.equals(typeClass)) {
        return null;
    }
    String name = typeClass.getName();
    String value = AccessController.doPrivileged(
            (PrivilegedAction<String>) () -> System.getProperty(name));
    if (value == null) {
        value = getProperties().getProperty(name);
    }
    if ("".equals(value)) {
        value = null;
    }
    return value;
}
 
Example #5
Source File: SequencerImplicitSynthOpen.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
static boolean test(Sequencer sequencer) throws MidiUnavailableException {
    log("");
    log("opening sequencer...");
    sequencer.open();   // opens connected synthesizer implicitly
    MidiDevice synth = getConnectedDevice(sequencer);
    log("  connected device: " + getDeviceStr(synth));

    log("closing sequencer...");
    sequencer.close();  // closes the synth implicitly
    log("  synth is " + getDeviceStr(synth));
    MidiDevice synth2 = getConnectedDevice(sequencer);
    log("  currently connected device: " + getDeviceStr(synth2));

    if (synth != null && synth.isOpen()) {
        log("FAIL.");
        return false;
    }
    log("OK.");
    return true;
}
 
Example #6
Source File: SequencerImplicitSynthOpen.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
static MidiDevice getConnectedDevice(Sequencer sequencer) {
    List<Transmitter> trans = sequencer.getTransmitters();
    log("  sequencer has " + trans.size() + " opened transmitters:");
    for (Transmitter tr: trans) {
        Receiver r = tr.getReceiver();
        log("    " + getClassStr(tr) + " connected to " + getClassStr(r));
        if (r instanceof MidiDeviceReceiver) {
            MidiDeviceReceiver recv = (MidiDeviceReceiver)r;
            MidiDevice dev = recv.getMidiDevice();
            log("      - receiver of " + getClassStr(dev));
            return dev;
        } else {
            log("      - does NOT implement MidiDeviceReceiver");
        }
    }
    return null;
}
 
Example #7
Source File: JDK13Services.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/** Obtain the value of a default provider property.
    @param typeClass The type of the default provider property. This
    should be one of Receiver.class, Transmitter.class, Sequencer.class,
    Synthesizer.class, SourceDataLine.class, TargetDataLine.class,
    Clip.class or Port.class.
    @return The complete value of the property, if available.
    If the property is not set, null is returned.
 */
private static synchronized String getDefaultProvider(Class typeClass) {
    if (!SourceDataLine.class.equals(typeClass)
            && !TargetDataLine.class.equals(typeClass)
            && !Clip.class.equals(typeClass)
            && !Port.class.equals(typeClass)
            && !Receiver.class.equals(typeClass)
            && !Transmitter.class.equals(typeClass)
            && !Synthesizer.class.equals(typeClass)
            && !Sequencer.class.equals(typeClass)) {
        return null;
    }
    String name = typeClass.getName();
    String value = AccessController.doPrivileged(
            (PrivilegedAction<String>) () -> System.getProperty(name));
    if (value == null) {
        value = getProperties().getProperty(name);
    }
    if ("".equals(value)) {
        value = null;
    }
    return value;
}
 
Example #8
Source File: JDK13Services.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/** Obtain the value of a default provider property.
    @param typeClass The type of the default provider property. This
    should be one of Receiver.class, Transmitter.class, Sequencer.class,
    Synthesizer.class, SourceDataLine.class, TargetDataLine.class,
    Clip.class or Port.class.
    @return The complete value of the property, if available.
    If the property is not set, null is returned.
 */
private static synchronized String getDefaultProvider(Class typeClass) {
    if (!SourceDataLine.class.equals(typeClass)
            && !TargetDataLine.class.equals(typeClass)
            && !Clip.class.equals(typeClass)
            && !Port.class.equals(typeClass)
            && !Receiver.class.equals(typeClass)
            && !Transmitter.class.equals(typeClass)
            && !Synthesizer.class.equals(typeClass)
            && !Sequencer.class.equals(typeClass)) {
        return null;
    }
    String name = typeClass.getName();
    String value = AccessController.doPrivileged(
            (PrivilegedAction<String>) () -> System.getProperty(name));
    if (value == null) {
        value = getProperties().getProperty(name);
    }
    if ("".equals(value)) {
        value = null;
    }
    return value;
}
 
Example #9
Source File: LMidiSound.java    From RipplePower with Apache License 2.0 6 votes vote down vote up
public LMidiSound(String fileName) throws IOException {
	bytes = new ArrayByte(UIRes.getStream(fileName), ArrayByte.BIG_ENDIAN);
	if (rendererStatus == UNINITIALIZED) {
		rendererStatus = INITIALIZING;
		Thread thread = new Thread() {
			public final void run() {
				try {

					Sequencer sequencer = MidiSystem.getSequencer();
					sequencer.open();
					volumeSupported = (sequencer instanceof Synthesizer);

					sequencer.close();
					available = true;
				} catch (Throwable e) {
					available = false;
				}
				rendererStatus = INITIALIZED;
			}
		};
		thread.setDaemon(true);
		thread.start();
	}
}
 
Example #10
Source File: JDK13Services.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/** Obtain the value of a default provider property.
    @param typeClass The type of the default provider property. This
    should be one of Receiver.class, Transmitter.class, Sequencer.class,
    Synthesizer.class, SourceDataLine.class, TargetDataLine.class,
    Clip.class or Port.class.
    @return The complete value of the property, if available.
    If the property is not set, null is returned.
 */
private static synchronized String getDefaultProvider(Class typeClass) {
    if (!SourceDataLine.class.equals(typeClass)
            && !TargetDataLine.class.equals(typeClass)
            && !Clip.class.equals(typeClass)
            && !Port.class.equals(typeClass)
            && !Receiver.class.equals(typeClass)
            && !Transmitter.class.equals(typeClass)
            && !Synthesizer.class.equals(typeClass)
            && !Sequencer.class.equals(typeClass)) {
        return null;
    }
    String name = typeClass.getName();
    String value = AccessController.doPrivileged(
            (PrivilegedAction<String>) () -> System.getProperty(name));
    if (value == null) {
        value = getProperties().getProperty(name);
    }
    if ("".equals(value)) {
        value = null;
    }
    return value;
}
 
Example #11
Source File: SequencerImplicitSynthOpen.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
static boolean test(Sequencer sequencer) throws MidiUnavailableException {
    log("");
    log("opening sequencer...");
    sequencer.open();   // opens connected synthesizer implicitly
    MidiDevice synth = getConnectedDevice(sequencer);
    log("  connected device: " + getDeviceStr(synth));

    log("closing sequencer...");
    sequencer.close();  // closes the synth implicitly
    log("  synth is " + getDeviceStr(synth));
    MidiDevice synth2 = getConnectedDevice(sequencer);
    log("  currently connected device: " + getDeviceStr(synth2));

    if (synth != null && synth.isOpen()) {
        log("FAIL.");
        return false;
    }
    log("OK.");
    return true;
}
 
Example #12
Source File: JDK13Services.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/** Obtain the value of a default provider property.
    @param typeClass The type of the default provider property. This
    should be one of Receiver.class, Transmitter.class, Sequencer.class,
    Synthesizer.class, SourceDataLine.class, TargetDataLine.class,
    Clip.class or Port.class.
    @return The complete value of the property, if available.
    If the property is not set, null is returned.
 */
private static synchronized String getDefaultProvider(Class typeClass) {
    if (!SourceDataLine.class.equals(typeClass)
            && !TargetDataLine.class.equals(typeClass)
            && !Clip.class.equals(typeClass)
            && !Port.class.equals(typeClass)
            && !Receiver.class.equals(typeClass)
            && !Transmitter.class.equals(typeClass)
            && !Synthesizer.class.equals(typeClass)
            && !Sequencer.class.equals(typeClass)) {
        return null;
    }
    String name = typeClass.getName();
    String value = AccessController.doPrivileged(
            (PrivilegedAction<String>) () -> System.getProperty(name));
    if (value == null) {
        value = getProperties().getProperty(name);
    }
    if ("".equals(value)) {
        value = null;
    }
    return value;
}
 
Example #13
Source File: SequencerImplicitSynthOpen.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
static MidiDevice getConnectedDevice(Sequencer sequencer) {
    List<Transmitter> trans = sequencer.getTransmitters();
    log("  sequencer has " + trans.size() + " opened transmitters:");
    for (Transmitter tr: trans) {
        Receiver r = tr.getReceiver();
        log("    " + getClassStr(tr) + " connected to " + getClassStr(r));
        if (r instanceof MidiDeviceReceiver) {
            MidiDeviceReceiver recv = (MidiDeviceReceiver)r;
            MidiDevice dev = recv.getMidiDevice();
            log("      - receiver of " + getClassStr(dev));
            return dev;
        } else {
            log("      - does NOT implement MidiDeviceReceiver");
        }
    }
    return null;
}
 
Example #14
Source File: SequencerImplicitSynthOpen.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
static boolean test(Sequencer sequencer) throws MidiUnavailableException {
    log("");
    log("opening sequencer...");
    sequencer.open();   // opens connected synthesizer implicitly
    MidiDevice synth = getConnectedDevice(sequencer);
    log("  connected device: " + getDeviceStr(synth));

    log("closing sequencer...");
    sequencer.close();  // closes the synth implicitly
    log("  synth is " + getDeviceStr(synth));
    MidiDevice synth2 = getConnectedDevice(sequencer);
    log("  currently connected device: " + getDeviceStr(synth2));

    if (synth != null && synth.isOpen()) {
        log("FAIL.");
        return false;
    }
    log("OK.");
    return true;
}
 
Example #15
Source File: SequencerImplicitSynthOpen.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
static MidiDevice getConnectedDevice(Sequencer sequencer) {
    List<Transmitter> trans = sequencer.getTransmitters();
    log("  sequencer has " + trans.size() + " opened transmitters:");
    for (Transmitter tr: trans) {
        Receiver r = tr.getReceiver();
        log("    " + getClassStr(tr) + " connected to " + getClassStr(r));
        if (r instanceof MidiDeviceReceiver) {
            MidiDeviceReceiver recv = (MidiDeviceReceiver)r;
            MidiDevice dev = recv.getMidiDevice();
            log("      - receiver of " + getClassStr(dev));
            return dev;
        } else {
            log("      - does NOT implement MidiDeviceReceiver");
        }
    }
    return null;
}
 
Example #16
Source File: JDK13Services.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/** Obtain the value of a default provider property.
    @param typeClass The type of the default provider property. This
    should be one of Receiver.class, Transmitter.class, Sequencer.class,
    Synthesizer.class, SourceDataLine.class, TargetDataLine.class,
    Clip.class or Port.class.
    @return The complete value of the property, if available.
    If the property is not set, null is returned.
 */
private static synchronized String getDefaultProvider(Class typeClass) {
    if (!SourceDataLine.class.equals(typeClass)
            && !TargetDataLine.class.equals(typeClass)
            && !Clip.class.equals(typeClass)
            && !Port.class.equals(typeClass)
            && !Receiver.class.equals(typeClass)
            && !Transmitter.class.equals(typeClass)
            && !Synthesizer.class.equals(typeClass)
            && !Sequencer.class.equals(typeClass)) {
        return null;
    }
    String value;
    String propertyName = typeClass.getName();
    value = JSSecurityManager.getProperty(propertyName);
    if (value == null) {
        value = getProperties().getProperty(propertyName);
    }
    if ("".equals(value)) {
        value = null;
    }
    return value;
}
 
Example #17
Source File: JDK13Services.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/** Obtain the value of a default provider property.
    @param typeClass The type of the default provider property. This
    should be one of Receiver.class, Transmitter.class, Sequencer.class,
    Synthesizer.class, SourceDataLine.class, TargetDataLine.class,
    Clip.class or Port.class.
    @return The complete value of the property, if available.
    If the property is not set, null is returned.
 */
private static synchronized String getDefaultProvider(Class<?> typeClass) {
    if (!SourceDataLine.class.equals(typeClass)
            && !TargetDataLine.class.equals(typeClass)
            && !Clip.class.equals(typeClass)
            && !Port.class.equals(typeClass)
            && !Receiver.class.equals(typeClass)
            && !Transmitter.class.equals(typeClass)
            && !Synthesizer.class.equals(typeClass)
            && !Sequencer.class.equals(typeClass)) {
        return null;
    }
    String name = typeClass.getName();
    String value = AccessController.doPrivileged(
            (PrivilegedAction<String>) () -> System.getProperty(name));
    if (value == null) {
        value = getProperties().getProperty(name);
    }
    if ("".equals(value)) {
        value = null;
    }
    return value;
}
 
Example #18
Source File: JDK13Services.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/** Obtain the value of a default provider property.
    @param typeClass The type of the default provider property. This
    should be one of Receiver.class, Transmitter.class, Sequencer.class,
    Synthesizer.class, SourceDataLine.class, TargetDataLine.class,
    Clip.class or Port.class.
    @return The complete value of the property, if available.
    If the property is not set, null is returned.
 */
private static synchronized String getDefaultProvider(Class typeClass) {
    if (!SourceDataLine.class.equals(typeClass)
            && !TargetDataLine.class.equals(typeClass)
            && !Clip.class.equals(typeClass)
            && !Port.class.equals(typeClass)
            && !Receiver.class.equals(typeClass)
            && !Transmitter.class.equals(typeClass)
            && !Synthesizer.class.equals(typeClass)
            && !Sequencer.class.equals(typeClass)) {
        return null;
    }
    String value;
    String propertyName = typeClass.getName();
    value = JSSecurityManager.getProperty(propertyName);
    if (value == null) {
        value = getProperties().getProperty(propertyName);
    }
    if ("".equals(value)) {
        value = null;
    }
    return value;
}
 
Example #19
Source File: SequencerImplicitSynthOpen.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
static MidiDevice getConnectedDevice(Sequencer sequencer) {
    List<Transmitter> trans = sequencer.getTransmitters();
    log("  sequencer has " + trans.size() + " opened transmitters:");
    for (Transmitter tr: trans) {
        Receiver r = tr.getReceiver();
        log("    " + getClassStr(tr) + " connected to " + getClassStr(r));
        if (r instanceof MidiDeviceReceiver) {
            MidiDeviceReceiver recv = (MidiDeviceReceiver)r;
            MidiDevice dev = recv.getMidiDevice();
            log("      - receiver of " + getClassStr(dev));
            return dev;
        } else {
            log("      - does NOT implement MidiDeviceReceiver");
        }
    }
    return null;
}
 
Example #20
Source File: SequencerImplicitSynthOpen.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
static MidiDevice getConnectedDevice(Sequencer sequencer) {
    List<Transmitter> trans = sequencer.getTransmitters();
    log("  sequencer has " + trans.size() + " opened transmitters:");
    for (Transmitter tr: trans) {
        Receiver r = tr.getReceiver();
        log("    " + getClassStr(tr) + " connected to " + getClassStr(r));
        if (r instanceof MidiDeviceReceiver) {
            MidiDeviceReceiver recv = (MidiDeviceReceiver)r;
            MidiDevice dev = recv.getMidiDevice();
            log("      - receiver of " + getClassStr(dev));
            return dev;
        } else {
            log("      - does NOT implement MidiDeviceReceiver");
        }
    }
    return null;
}
 
Example #21
Source File: JDK13Services.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/** Obtain the value of a default provider property.
    @param typeClass The type of the default provider property. This
    should be one of Receiver.class, Transmitter.class, Sequencer.class,
    Synthesizer.class, SourceDataLine.class, TargetDataLine.class,
    Clip.class or Port.class.
    @return The complete value of the property, if available.
    If the property is not set, null is returned.
 */
private static synchronized String getDefaultProvider(Class typeClass) {
    if (!SourceDataLine.class.equals(typeClass)
            && !TargetDataLine.class.equals(typeClass)
            && !Clip.class.equals(typeClass)
            && !Port.class.equals(typeClass)
            && !Receiver.class.equals(typeClass)
            && !Transmitter.class.equals(typeClass)
            && !Synthesizer.class.equals(typeClass)
            && !Sequencer.class.equals(typeClass)) {
        return null;
    }
    String name = typeClass.getName();
    String value = AccessController.doPrivileged(
            (PrivilegedAction<String>) () -> System.getProperty(name));
    if (value == null) {
        value = getProperties().getProperty(name);
    }
    if ("".equals(value)) {
        value = null;
    }
    return value;
}
 
Example #22
Source File: SequencerImplicitSynthOpen.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
static MidiDevice getConnectedDevice(Sequencer sequencer) {
    List<Transmitter> trans = sequencer.getTransmitters();
    log("  sequencer has " + trans.size() + " opened transmitters:");
    for (Transmitter tr: trans) {
        Receiver r = tr.getReceiver();
        log("    " + getClassStr(tr) + " connected to " + getClassStr(r));
        if (r instanceof MidiDeviceReceiver) {
            MidiDeviceReceiver recv = (MidiDeviceReceiver)r;
            MidiDevice dev = recv.getMidiDevice();
            log("      - receiver of " + getClassStr(dev));
            return dev;
        } else {
            log("      - does NOT implement MidiDeviceReceiver");
        }
    }
    return null;
}
 
Example #23
Source File: SequencerImplicitSynthOpen.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
static boolean test(Sequencer sequencer) throws MidiUnavailableException {
    log("");
    log("opening sequencer...");
    sequencer.open();   // opens connected synthesizer implicitly
    MidiDevice synth = getConnectedDevice(sequencer);
    log("  connected device: " + getDeviceStr(synth));

    log("closing sequencer...");
    sequencer.close();  // closes the synth implicitly
    log("  synth is " + getDeviceStr(synth));
    MidiDevice synth2 = getConnectedDevice(sequencer);
    log("  currently connected device: " + getDeviceStr(synth2));

    if (synth != null && synth.isOpen()) {
        log("FAIL.");
        return false;
    }
    log("OK.");
    return true;
}
 
Example #24
Source File: MidiOutGetMicrosecondPositionBug.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns true if at least one MIDI (port) device is correctly installed on
 * the system.
 */
public static boolean isMidiInstalled() {
    boolean result = false;
    MidiDevice.Info[] devices = MidiSystem.getMidiDeviceInfo();
    for (int i = 0; i < devices.length; i++) {
        try {
            MidiDevice device = MidiSystem.getMidiDevice(devices[i]);
            result = ! (device instanceof Sequencer) && ! (device instanceof Synthesizer);
        } catch (Exception e1) {
            System.err.println(e1);
        }
        if (result)
            break;
    }
    if (!result) {
        System.err.println("Soundcard does not exist or sound drivers not installed!");
        System.err.println("This test requires sound drivers for execution.");
    }
    return result;
}
 
Example #25
Source File: SequencerImplicitSynthOpen.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
static boolean test(Sequencer sequencer) throws MidiUnavailableException {
    log("");
    log("opening sequencer...");
    sequencer.open();   // opens connected synthesizer implicitly
    MidiDevice synth = getConnectedDevice(sequencer);
    log("  connected device: " + getDeviceStr(synth));

    log("closing sequencer...");
    sequencer.close();  // closes the synth implicitly
    log("  synth is " + getDeviceStr(synth));
    MidiDevice synth2 = getConnectedDevice(sequencer);
    log("  currently connected device: " + getDeviceStr(synth2));

    if (synth != null && synth.isOpen()) {
        log("FAIL.");
        return false;
    }
    log("OK.");
    return true;
}
 
Example #26
Source File: JDK13Services.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/** Obtain the value of a default provider property.
    @param typeClass The type of the default provider property. This
    should be one of Receiver.class, Transmitter.class, Sequencer.class,
    Synthesizer.class, SourceDataLine.class, TargetDataLine.class,
    Clip.class or Port.class.
    @return The complete value of the property, if available.
    If the property is not set, null is returned.
 */
private static synchronized String getDefaultProvider(Class typeClass) {
    if (!SourceDataLine.class.equals(typeClass)
            && !TargetDataLine.class.equals(typeClass)
            && !Clip.class.equals(typeClass)
            && !Port.class.equals(typeClass)
            && !Receiver.class.equals(typeClass)
            && !Transmitter.class.equals(typeClass)
            && !Synthesizer.class.equals(typeClass)
            && !Sequencer.class.equals(typeClass)) {
        return null;
    }
    String name = typeClass.getName();
    String value = AccessController.doPrivileged(
            (PrivilegedAction<String>) () -> System.getProperty(name));
    if (value == null) {
        value = getProperties().getProperty(name);
    }
    if ("".equals(value)) {
        value = null;
    }
    return value;
}
 
Example #27
Source File: SequencerCacheValues.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void doTest(Sequencer seq) throws Exception {
    seq.setTempoInMPQ(3.0f);
    System.out.println("Setting tempo in MPQ to "+3.0f);
    if (!equalsFloat(seq.getTempoInMPQ(), 3.0f)) {
        System.err.println("getTempoInMPQ() returns wrong value : "
            + seq.getTempoInMPQ());
        failed = true;
    }

    System.out.println("Setting tempo factor to "+2.0f);
    seq.setTempoFactor(2.0f);
    if (!equalsFloat(seq.getTempoFactor(), 2.0f)) {
        System.err.println("getTempoFactor() returns: " + seq.getTempoFactor());
        failed = true;
    }

    float bpmTempo = 120.0f;
    System.out.println("Setting tempo to "+120.0f+"bpm");
    seq.setTempoInBPM(bpmTempo);
    if (!equalsFloat(seq.getTempoInMPQ(), (60000000.0f/seq.getTempoInBPM()))) {
        System.err.println("getTempoInMPQ() returns: " + seq.getTempoInMPQ());
        System.err.println("getTempoInBPM() returns: " + seq.getTempoInBPM());
        failed = true;
    }
}
 
Example #28
Source File: OpenClose.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns true if at least one MIDI (port) device is correctly installed on
 * the system.
 */
public static boolean isMidiInstalled() {
    boolean result = false;
    MidiDevice.Info[] devices = MidiSystem.getMidiDeviceInfo();
    for (int i = 0; i < devices.length; i++) {
        try {
            MidiDevice device = MidiSystem.getMidiDevice(devices[i]);
            result = ! (device instanceof Sequencer) && ! (device instanceof Synthesizer);
        } catch (Exception e1) {
            System.err.println(e1);
        }
        if (result)
            break;
    }
    return result;
}
 
Example #29
Source File: SeqStartRecording.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String argv[]) {
    Sequencer seq = null;
    try {
        seq = MidiSystem.getSequencer();
        seq.open();
    } catch (final MidiUnavailableException ignored) {
        // the test is not applicable
        return;
    }
    try {
        seq.startRecording();
        System.out.println("Test passed.");
    } catch (NullPointerException npe) {
        System.out.println("Caught NPE: "+npe);
        npe.printStackTrace();
        throw new RuntimeException("Test FAILED!");
    } catch (Exception e) {
        System.out.println("Unexpected Exception: "+e);
        e.printStackTrace();
        System.out.println("Test NOT failed.");
    } finally {
        seq.close();
    }
}
 
Example #30
Source File: SequencerImplicitSynthOpen.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
static MidiDevice getConnectedDevice(Sequencer sequencer) {
    List<Transmitter> trans = sequencer.getTransmitters();
    log("  sequencer has " + trans.size() + " opened transmitters:");
    for (Transmitter tr: trans) {
        Receiver r = tr.getReceiver();
        log("    " + getClassStr(tr) + " connected to " + getClassStr(r));
        if (r instanceof MidiDeviceReceiver) {
            MidiDeviceReceiver recv = (MidiDeviceReceiver)r;
            MidiDevice dev = recv.getMidiDevice();
            log("      - receiver of " + getClassStr(dev));
            return dev;
        } else {
            log("      - does NOT implement MidiDeviceReceiver");
        }
    }
    return null;
}