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


Java MidiDevice.getMaxTransmitters方法代码示例

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


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

示例1: 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

示例2: doTest

import javax.sound.midi.MidiDevice; //导入方法依赖的package包/类
private static boolean doTest(int numIterations, boolean input) throws Exception {
    MidiDevice.Info[] infos = MidiSystem.getMidiDeviceInfo();
    MidiDevice outDevice = null;
    MidiDevice inDevice = null;
    for (int i = 0; i < infos.length; i++) {
        MidiDevice device = MidiSystem.getMidiDevice(infos[i]);
        if (! (device instanceof Sequencer) &&
            ! (device instanceof Synthesizer)) {
            if (device.getMaxReceivers() != 0) {
                outDevice = device;
            }
            if (device.getMaxTransmitters() != 0) {
                inDevice = device;
            }
        }
    }
    MidiDevice testDevice = null;
    if (input) {
        testDevice = inDevice;
    } else {
        testDevice = outDevice;
    }
    if (testDevice == null) {
        out("Cannot test: device not available.");
        return true;
    }
    out("Using Device: " + testDevice);

    for (int i = 0; i < numIterations; i++) {
        out("@@@ ITERATION: " + i);
        testDevice.open();
        // This sleep ensures that the thread of MidiInDevice is started.
        sleep(50);
        testDevice.close();
    }
    return true;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:38,代码来源:Reopen.java

示例3: canIn

import javax.sound.midi.MidiDevice; //导入方法依赖的package包/类
private static String canIn(MidiDevice dev) {
    if (dev.getMaxTransmitters() != 0) {
        return "IN ";
    }
    return "   ";
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:IOLoop.java

示例4: main

import javax.sound.midi.MidiDevice; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    out("4356787: MIDI device I/O is not working (windows)");

    if (System.getProperty("os.name").startsWith("Windows")) {
        boolean forInput=true;
        boolean forOutput=true;
        int outOnlyCount=0;
        int inOnlyCount=0;
        out("  available MIDI devices:");
        MidiDevice.Info[] aInfos = MidiSystem.getMidiDeviceInfo();
        for (int i = 0; i < aInfos.length; i++) {
            try {
                MidiDevice      device = MidiSystem.getMidiDevice(aInfos[i]);
                boolean         bAllowsInput = (device.getMaxTransmitters() != 0);
                boolean         bAllowsOutput = (device.getMaxReceivers() != 0);
                if (bAllowsInput && !bAllowsOutput) {
                    inOnlyCount++;
                }
                if (!bAllowsInput && bAllowsOutput) {
                    outOnlyCount++;
                }
                if ((bAllowsInput && forInput) || (bAllowsOutput && forOutput)) {
                    out(""+i+"  "
                            +(bAllowsInput?"IN ":"   ")
                            +(bAllowsOutput?"OUT ":"    ")
                            +aInfos[i].getName()+", "
                            +aInfos[i].getVendor()+", "
                            +aInfos[i].getVersion()+", "
                            +aInfos[i].getDescription());
                }
            }
            catch (MidiUnavailableException e) {
                // device is obviously not available...
            }
        }
        if (aInfos.length == 0) {
            out("No devices available. Test should be run on systems with MIDI drivers installed.");
        } else {
            if (outOnlyCount>1) {
                if (inOnlyCount==0) {
                    //throw new Exception("No input devices! test fails.");
                    out("System provides out devices, but no input devices. This means either");
                    out("a bug in Java Sound, or the drivers are not set up correctly.");
                }
                out("Test passed.");
            } else {
                out("no MIDI I/O installed. Test should be run on systems with MIDI drivers installed.");
            }
        }
    } else {
        out("  -- not on Windows. Test doesn't apply.");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:54,代码来源:MidiIO.java


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