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


Java MidiUnavailableException.printStackTrace方法代码示例

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


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

示例1: getMidiDeviceInfo

import javax.sound.midi.MidiUnavailableException; //导入方法依赖的package包/类
/**
 * Retrieve a MidiDevice.Info for a given name.
 * 
 * This method tries to return a MidiDevice.Info whose name matches the
 * passed name. If no matching MidiDevice.Info is found, null is returned.
 * If bForOutput is true, then only output devices are searched, otherwise
 * only input devices.
 * 
 * @param strDeviceName
 *            the name of the device for which an info object should be
 *            retrieved.
 * @param bForOutput
 *            If true, only output devices are considered. If false, only
 *            input devices are considered.
 * 
 * @return A MidiDevice.Info object matching the passed device name or null
 *         if none could be found.
 */
public static MidiDevice.Info getMidiDeviceInfo(String strDeviceName,
		boolean bForOutput) {
	MidiDevice.Info[] aInfos = MidiSystem.getMidiDeviceInfo();
	for (int i = 0; i < aInfos.length; i++) {
		if (aInfos[i].getName().contains(strDeviceName)) {
			try {
				MidiDevice device = MidiSystem.getMidiDevice(aInfos[i]);
				boolean bAllowsInput = (device.getMaxTransmitters() != 0);
				boolean bAllowsOutput = (device.getMaxReceivers() != 0);
				if ((bAllowsOutput && bForOutput)
						|| (bAllowsInput && !bForOutput)) {
					return aInfos[i];
				}
			} catch (MidiUnavailableException e) {
				e.printStackTrace();
			}
		}
	}
	return null;
}
 
开发者ID:helionmusic,项目名称:launchpad_s_plus,代码行数:39,代码来源:MidiCommon.java

示例2: init

import javax.sound.midi.MidiUnavailableException; //导入方法依赖的package包/类
/**
 * This method initializes the MusicPlayer
 */
public static boolean init()
{
	try
	{
		if (synth == null)
			synth = MidiSystem.getSynthesizer();
		if (!synth.isOpen())
			synth.open();
		return true;
	} catch (MidiUnavailableException e)
	{
		e.printStackTrace();
		return false;
	}
}
 
开发者ID:creativitRy,项目名称:ClearComposer,代码行数:19,代码来源:MusicPlayer.java

示例3: SoundPlayer

import javax.sound.midi.MidiUnavailableException; //导入方法依赖的package包/类
public SoundPlayer() {
    try {
        synthesizer = MidiSystem.getSynthesizer();
        synthesizer.open();
        midiChannel = synthesizer.getChannels()[0];
    } catch (MidiUnavailableException e) {
        e.printStackTrace();
    }
}
 
开发者ID:rafzby,项目名称:chip8-emulator,代码行数:10,代码来源:SoundPlayer.java

示例4: createSequencer

import javax.sound.midi.MidiUnavailableException; //导入方法依赖的package包/类
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;
    }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:29,代码来源:JavaSoundAudioClip.java

示例5: checkAudio

import javax.sound.midi.MidiUnavailableException; //导入方法依赖的package包/类
private static void checkAudio() {
    try {
        if (javax.sound.midi.MidiSystem.getSequencer() == null)
            System.out.println("MidiSystem sequencer unavailable.");
        else if (javax.sound.sampled.AudioSystem.getMixer(null) == null)
            System.out.println("AudioSystem unavailable.");
    } catch (MidiUnavailableException e) {
        e.printStackTrace();
    }
    System.out.println("AudioSystem and MidiSystem Sequencer found.");
}
 
开发者ID:SarutaSan72,项目名称:Yass,代码行数:12,代码来源:YassMain.java

示例6: listDevicesAndExit

import javax.sound.midi.MidiUnavailableException; //导入方法依赖的package包/类
public static void listDevicesAndExit(boolean bForInput,
		boolean bForOutput, boolean bVerbose) {
	if (bForInput && !bForOutput) {
		out("Available MIDI IN Devices:");
	} else if (!bForInput && bForOutput) {
		out("Available MIDI OUT Devices:");
	} else {
		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 && bForInput)
					|| (bAllowsOutput && bForOutput)) {
				if (bVerbose) {
					out("" + i + "  " + (bAllowsInput ? "IN " : "   ")
							+ (bAllowsOutput ? "OUT " : "    ")
							+ aInfos[i].getName() + ", "
							+ aInfos[i].getVendor() + ", "
							+ aInfos[i].getVersion() + ", "
							+ aInfos[i].getDescription());
				} else {
					out("" + i + "  " + aInfos[i].getName());
				}
			}
		} catch (MidiUnavailableException e) {
			e.printStackTrace();
			// device is obviously not available...
			// out(e);
		}
	}
	if (aInfos.length == 0) {
		out("[No devices available]");
	}
	System.exit(0);
}
 
开发者ID:helionmusic,项目名称:launchpad_s_plus,代码行数:41,代码来源:MidiCommon.java

示例7: testDevices

import javax.sound.midi.MidiUnavailableException; //导入方法依赖的package包/类
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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:46,代码来源:DefaultDevices.java


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