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


Java Sequencer.getTransmitters方法代碼示例

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


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

示例1: getConnectedDevice

import javax.sound.midi.Sequencer; //導入方法依賴的package包/類
static MidiDevice getConnectedDevice(Sequencer sequencer) {
    List<Transmitter> trans = sequencer.getTransmitters();
    log("  sequencer has " + trans.size() + " opened transmitters:");
    for (Transmitter tr: trans) {
        Receiver r = tr.getReceiver();
        log("    " + getClassStr(tr) + " connected to " + getClassStr(r));
        if (r instanceof MidiDeviceReceiver) {
            MidiDeviceReceiver recv = (MidiDeviceReceiver)r;
            MidiDevice dev = recv.getMidiDevice();
            log("      - receiver of " + getClassStr(dev));
            return dev;
        } else {
            log("      - does NOT implement MidiDeviceReceiver");
        }
    }
    return null;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:18,代碼來源:SequencerImplicitSynthOpen.java

示例2: doTest

import javax.sound.midi.Sequencer; //導入方法依賴的package包/類
public static void doTest(int mode) {
    Sequencer seq = null;
    boolean connected = false;

    try {
        switch (mode) {
        case 1:
            seq = MidiSystem.getSequencer();
            connected = true;
            break;
        case 2:
            seq = MidiSystem.getSequencer(false);
            connected = false;
            break;
        case 3:
            seq = MidiSystem.getSequencer(true);
            connected = true;
            break;
        }
        out("Testing Sequencer "+seq);
        if (connected) {
            out("  opened in connected mode.");
        } else {
            out("  opened in non-connected mode.");
        }
        System.out.println("  opening...");
        seq.open();
    } catch (MidiUnavailableException mue) {
        System.err.println("MidiUnavailableException was thrown: " + mue);
        System.err.println("  could not test this sequencer.");
        return;
    }

    try {
        List<Transmitter> transmitters = seq.getTransmitters();
        int size = transmitters.size();
        out("  transmitters.size()="+size);
        if (size != 1 && connected) {
            out("  should have 1 connection! Failed.");
            failed = true;
        }
        if (size != 0 && !connected) {
            out("  should have 0 connections! Failed.");
            failed = true;
        }
        out("  closing...");
        seq.close();
        transmitters = seq.getTransmitters();
        size = transmitters.size();
        out("  transmitters.size()="+size);
        if (size != 0) {
            out("  should have 0 connections! Failed.");
            failed = true;
        }

        out("  opening again...");
        seq.open();
        transmitters = seq.getTransmitters();
        size = transmitters.size();
        out("  transmitters.size()="+size);
        if (size != 1 && connected) {
            out("  should have 1 connection! Failed.");
            failed = true;
        }
        if (size != 0 && !connected) {
            out("  should have 0 connections! Failed.");
            failed = true;
        }
    } catch (Exception e) {
        System.err.println("  unexpectedException was thrown: " + e);
        System.err.println("  causes this test to FAIL.");
        failed = true;
    }
    seq.close();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:76,代碼來源:GetSequencer.java


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