当前位置: 首页>>代码示例>>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;未经允许,请勿转载。