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


Java MidiSystem.getReceiver方法代码示例

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


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

示例1: testReceiverSend

import javax.sound.midi.MidiSystem; //导入方法依赖的package包/类
/**
 * Execute Receiver.send() and expect that there is no exception.
 */
private static boolean testReceiverSend() {
    boolean result = true;

    Receiver receiver;
    ShortMessage shMsg = new ShortMessage();

    try {
        receiver = MidiSystem.getReceiver();
        shMsg.setMessage(ShortMessage.NOTE_ON, 0,60, 93);
        try {
            receiver.send( shMsg, -1 );
        } catch(IllegalStateException ilEx) {
            ilEx.printStackTrace(System.out);
            out("IllegalStateException was thrown incorrectly!");
            result = false;
        }
        receiver.close();
    } catch(MidiUnavailableException e) {
        out("Midi unavailable, cannot test.");
    } catch(InvalidMidiDataException ine) {
        out("InvalidMidiDataException, cannot test.");
    }
    return result;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:ClosedReceiver.java

示例2: init

import javax.sound.midi.MidiSystem; //导入方法依赖的package包/类
/**
 * Initialise the input source
 */
  	private boolean init() {
  		if (trans == null) {
     		try {
        		if (MidiSystem.getReceiver() == null) {
           			System.err.println("MidiSystem Receiver Unavailable");
             			 return false;
         		}
		MidiDevice.Info[] mdi=MidiSystem.getMidiDeviceInfo();
		for(int i=0;i<mdi.length;i++){
			System.out.println(mdi[i]);
		}
		trans = MidiSystem.getTransmitter();
		trans.setReceiver(this);
       	}catch (MidiUnavailableException e) {
        		System.err.println("Midi System Unavailable:" + e);
          		return false;
        	}
  	}
    		return true;
}
 
开发者ID:Armaxis,项目名称:jmg,代码行数:24,代码来源:RTMidiIn.java

示例3: main

import javax.sound.midi.MidiSystem; //导入方法依赖的package包/类
public static void main(final String[] argv) {
    try {
        MidiSystem.getReceiver();
        Toolkit.getDefaultToolkit();
    } catch (final MidiUnavailableException ignored) {
        // the test is not applicable
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:InitializationHang.java

示例4: SoundCache

import javax.sound.midi.MidiSystem; //导入方法依赖的package包/类
public SoundCache() {
	try {
		midiSequencer = MidiSystem.getSequencer(false);
		midiReceiver = MidiSystem.getReceiver();
		midiAvailable = true;
		logger.info("MIDI is available on this system.");
	} catch (MidiUnavailableException error) {
		logger.warn("MIDI is unsupported on this system.", error);
		midiAvailable = false;
	}
	setVolume(0.5);
}
 
开发者ID:UQdeco2800,项目名称:coaster,代码行数:13,代码来源:SoundCache.java

示例5: MidiModule

import javax.sound.midi.MidiSystem; //导入方法依赖的package包/类
public MidiModule() {
    Receiver tempReceiver = null;

    if (Property.MIDI.isTrue()) {
        try {
            tempReceiver = MidiSystem.getReceiver();
            log.info("Midi module loaded");
        } catch (MidiUnavailableException e) {
            log.error("Midi module failed to load {}", e);
        }
    }
    receiver = tempReceiver;
}
 
开发者ID:danielkihlgren,项目名称:stagedisplayviewer,代码行数:14,代码来源:MidiModule.java

示例6: main

import javax.sound.midi.MidiSystem; //导入方法依赖的package包/类
public static void main(final String[] argv) throws Exception {
    MidiSystem.getReceiver();
    Toolkit.getDefaultToolkit();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:5,代码来源:InitializationHang.java

示例7: testDevice

import javax.sound.midi.MidiSystem; //导入方法依赖的package包/类
private static boolean testDevice(MidiDevice device, Class type,
        String providerClassName, String instanceName,
        boolean expectedResult) {
    boolean allOk = true;

    try {
        String propertyName = type.getName();
        String propertyValue = (providerClassName != null) ? providerClassName: "" ;
        propertyValue += "#" + instanceName;
        out("property: " + propertyName + "="+ propertyValue);
        System.setProperty(propertyName, propertyValue);
        Object reference = null;
        Object result = null;
        if (type == SEQUENCER_CLASS) {
            reference = device;
            result = MidiSystem.getSequencer();
        } else if (type == SYNTHESIZER_CLASS) {
            reference = device;
            result = MidiSystem.getSynthesizer();
        } else if (type == RECEIVER_CLASS) {
            reference = device.getReceiver();
            result = MidiSystem.getReceiver();
        } else if (type == TRANSMITTER_CLASS) {
            reference = device.getTransmitter();
            result = MidiSystem.getTransmitter();
        }
        out("result: " + result);
        boolean rightDevice = (reference.getClass() == result.getClass());
        if (rightDevice != expectedResult) {
            out("\nERROR: type " + type + " failed:"
                    + " class should" + (expectedResult ? "" : " NOT") + " be '"
                    + reference.getClass()
                    + "' but is '" + result.getClass() + "'!\n");
            allOk = false;
        }
        if (expectedResult
                && reference instanceof MidiDevice
                && result instanceof MidiDevice) {
            MidiDevice referenceDevice = (MidiDevice)reference;
            MidiDevice resultDevice = (MidiDevice)result;
            if (!referenceDevice.getDeviceInfo().getName().equals(
                                resultDevice.getDeviceInfo().getName())) {
                out("\nERROR: type " + type + " failed: name should be '"
                        + referenceDevice.getDeviceInfo().getName()
                        + "' but is '"
                        + resultDevice.getDeviceInfo().getName() + "'!\n");
                allOk = false;
            }
        }
        if (result instanceof Receiver) {
            ((Receiver)result).close();
        } else if (result instanceof Transmitter) {
            ((Transmitter)result).close();
        } else if (result instanceof Synthesizer) {
            ((Synthesizer)result).close();
        } else if (result instanceof Sequencer) {
            ((Sequencer)result).close();
        }
    } catch (Exception e) {
        out("Exception thrown; Test NOT failed.");
        e.printStackTrace(System.out);
        out("");
    }
    return allOk;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:66,代码来源:DefaultDevices.java

示例8: fetchObjectMidiSystem

import javax.sound.midi.MidiSystem; //导入方法依赖的package包/类
public void fetchObjectMidiSystem() throws MidiUnavailableException {
    receiverMidiSystem = MidiSystem.getReceiver();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:4,代码来源:OpenClose.java

示例9: createReceiver

import javax.sound.midi.MidiSystem; //导入方法依赖的package包/类
@Override protected Receiver createReceiver() throws MidiUnavailableException
{
	return (lotroSynth != null) ? lotroSynth.getReceiver() : MidiSystem.getReceiver();
}
 
开发者ID:digero,项目名称:maestro,代码行数:5,代码来源:LotroSequencerWrapper.java

示例10: createReceiver

import javax.sound.midi.MidiSystem; //导入方法依赖的package包/类
protected Receiver createReceiver() throws MidiUnavailableException
{
	return MidiSystem.getReceiver();
}
 
开发者ID:digero,项目名称:maestro,代码行数:5,代码来源:SequencerWrapper.java

示例11: Launchpad

import javax.sound.midi.MidiSystem; //导入方法依赖的package包/类
/**
 * This is the full configured solution if you want to receive notifications if a {@link Pad} is
 * being pressed, and want to configure the midi channel (default is {@link Channel#C1}) of your
 * launchpad.
 *
 * @param channel The {@link Channel} to send and receive data to and from.
 * @param launchpadReceiver The {@link LaunchpadReceiver} implementation that will receive the
 *        information if a {@link Pad} is pressed.
 * @throws MidiUnavailableException No midi device could be found, is your launchpad connected to
 *         your computer?
 */
public Launchpad(Channel channel, LaunchpadReceiver launchpadReceiver)
    throws MidiUnavailableException {
  this.channel = channel;
  transmitter = MidiSystem.getTransmitter();
  receiver = MidiSystem.getReceiver();
  this.launchpadReceiver = launchpadReceiver;

  transmitter.setReceiver(this);
}
 
开发者ID:rynr,项目名称:launchpad,代码行数:21,代码来源:Launchpad.java


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