當前位置: 首頁>>代碼示例>>Java>>正文


Java MidiSystem.getTransmitter方法代碼示例

本文整理匯總了Java中javax.sound.midi.MidiSystem.getTransmitter方法的典型用法代碼示例。如果您正苦於以下問題:Java MidiSystem.getTransmitter方法的具體用法?Java MidiSystem.getTransmitter怎麽用?Java MidiSystem.getTransmitter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.sound.midi.MidiSystem的用法示例。


在下文中一共展示了MidiSystem.getTransmitter方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

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

示例2: getDefaultInputDevice

import javax.sound.midi.MidiSystem; //導入方法依賴的package包/類
/**
 * Returns the default input MIDI device.
 *
 * @return the default input MIDI device or {@code null} if not found.
 */
public static MidiDevice getDefaultInputDevice() {
    try {
        Transmitter transmitter = MidiSystem.getTransmitter();

        if (transmitter != null && transmitter instanceof MidiDeviceTransmitter) {
            return ((MidiDeviceTransmitter) transmitter).getMidiDevice();
        }

        return null;
    } catch (MidiUnavailableException e) {
        throw SpongeUtils.wrapException(e);
    }
}
 
開發者ID:softelnet,項目名稱:sponge,代碼行數:19,代碼來源:MidiUtils.java

示例3: test

import javax.sound.midi.MidiSystem; //導入方法依賴的package包/類
boolean test() {
    openThread = new Thread(new Runnable() {
        public void run() {
            try {
                log("openThread: getting transmitter...");
                transmitter = MidiSystem.getTransmitter();
                log("openThread:   - OK: " + transmitter);
            } catch (MidiUnavailableException ex) {
                log("openThread:   - Exception: ");
                ex.printStackTrace(System.out);
                log("openThread: skipping...");
            }
            log("openThread: exiting...");
        }
    });
    log("starting openThread...");
    openThread.start();

    while (openThread.isAlive())
        delay(500);
    // make additional delay
    delay(500);

    if (transmitter == null) {
        return true;   // midi is not available, just ignore
    }

    log("closing transmitter");
    transmitter.close();
    log("  - OK");

    return true;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:34,代碼來源:bug6415669.java

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

示例5: fetchObjectMidiSystem

import javax.sound.midi.MidiSystem; //導入方法依賴的package包/類
public void fetchObjectMidiSystem() throws MidiUnavailableException {
    transmitterMidiSystem = MidiSystem.getTransmitter();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:4,代碼來源:OpenClose.java

示例6: 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.getTransmitter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。