当前位置: 首页>>代码示例>>Java>>正文


Java MidiDevice.isOpen方法代码示例

本文整理汇总了Java中javax.sound.midi.MidiDevice.isOpen方法的典型用法代码示例。如果您正苦于以下问题:Java MidiDevice.isOpen方法的具体用法?Java MidiDevice.isOpen怎么用?Java MidiDevice.isOpen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.sound.midi.MidiDevice的用法示例。


在下文中一共展示了MidiDevice.isOpen方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test

import javax.sound.midi.MidiDevice; //导入方法依赖的package包/类
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;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:SequencerImplicitSynthOpen.java

示例2: update

import javax.sound.midi.MidiDevice; //导入方法依赖的package包/类
@Override
public void update() throws Exception
{
	this.transmitterLoop++;
	if (this.transmitterLoop % 600 == 0)
	{
		MidiDevice.Info[] infos = MidiSystem.getMidiDeviceInfo();
		for (int i = 0; i < infos.length; i++)
		{
			MidiDevice device = MidiSystem.getMidiDevice(infos[i]);
			if (NMOConfiguration.INSTANCE.integrations.midiTransmitter.transmitters.contains(device.getDeviceInfo().getName()))
			{
				if (!device.isOpen() && device.getMaxTransmitters() != 0)
				{
					final String name = device.getDeviceInfo().getName() + "/" + device.getDeviceInfo().getDescription() + "/" + device.getDeviceInfo().getVendor();
					log.info("Connected MIDI device: " + name);
					device.getTransmitter().setReceiver(new Receiver()
					{
						@Override
						public void send(MidiMessage message, long timeStamp)
						{
							MainDialog.resetActivityTimer(MIDI_TRANSMITTER);
						}

						@Override
						public void close()
						{
							log.info("Disconnected MIDI device: " + name);
						}
					});
					device.open();
				}
			}
		}
	}
}
 
开发者ID:PolyphasicDevTeam,项目名称:NoMoreOversleeps,代码行数:37,代码来源:IntegrationMidiTransmitter.java

示例3: open

import javax.sound.midi.MidiDevice; //导入方法依赖的package包/类
/**
 * Opens the MIDI device.
 *
 * @param device the MIDI device.
 */
public static void open(MidiDevice device) {
    if (device != null && !device.isOpen()) {
        try {
            device.open();
        } catch (MidiUnavailableException e) {
            throw SpongeUtils.wrapException(e);
        }
    }
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:15,代码来源:MidiUtils.java

示例4: close

import javax.sound.midi.MidiDevice; //导入方法依赖的package包/类
/**
 * Closes the MIDI device.
 *
 * @param device the MIDI device.
 */
public static void close(MidiDevice device) {
    try {
        if (device != null && device.isOpen()) {
            device.close();
        }
    } catch (Exception e) {
        logger.warn("close", e);
    }
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:15,代码来源:MidiUtils.java

示例5: main

import javax.sound.midi.MidiDevice; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    MidiDevice/*Synthesizer*/ synth = null;

    try {
        synth = MidiSystem.getSynthesizer();
        //synth = MidiSystem.getMidiDevice(infos[0]);

        System.out.println("Synthesizer: " + synth.getDeviceInfo());
        synth.open();
        MidiMessage msg = new GenericMidiMessage(0x90, 0x3C, 0x40);
        //ShortMessage msg = new ShortMessage();
        //msg.setMessage(0x90, 0x3C, 0x40);

        synth.getReceiver().send(msg, 0);
        Thread.sleep(2000);

    } catch (Exception ex) {
        ex.printStackTrace();
        throw ex;
    } finally {
        if (synth != null && synth.isOpen())
            synth.close();
    }
    System.out.print("Did you heard a note? (enter 'y' or 'n') ");
    int result = System.in.read();
    System.in.skip(1000);
    if (result == 'y' || result == 'Y')
    {
        System.out.println("Test passed sucessfully.");
    }
    else
    {
        System.out.println("Test FAILED.");
        throw new RuntimeException("Test failed.");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:37,代码来源:bug6186488.java

示例6: checkOpen

import javax.sound.midi.MidiDevice; //导入方法依赖的package包/类
private void checkOpen(MidiDevice device, boolean desiredState) {
    if (device.isOpen() != desiredState) {
        out("device should be " +
                            getStateString(desiredState) + ", but isn't!");
        failed = true;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:OpenClose.java

示例7: getDeviceStr

import javax.sound.midi.MidiDevice; //导入方法依赖的package包/类
static String getDeviceStr(MidiDevice dev) {
    if (dev == null) {
        return "NULL";
    }
    return getClassStr(dev) + ", " + (dev.isOpen() ? "OPENED" : "CLOSED");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:7,代码来源:SequencerImplicitSynthOpen.java


注:本文中的javax.sound.midi.MidiDevice.isOpen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。