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


Java Synthesizer.isOpen方法代码示例

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


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

示例1: allNotesOff

import javax.sound.midi.Synthesizer; //导入方法依赖的package包/类
/**
 * Stops all notes from playing on all MIDI channels.
 */
public static void allNotesOff(Synthesizer synth)
{
    try {
        if (!synth.isOpen()) {
            synth.open();
        }
        MidiChannel[] channels = synth.getChannels();
        for (int i=0; i < channels.length; i++)
        {
            channels[i].allNotesOff();
        }
    } catch (MidiUnavailableException e)
    {
        throw new JFugueException(JFugueException.GENERAL_ERROR);
    }
}
 
开发者ID:d2fn,项目名称:passage,代码行数:20,代码来源:Player.java

示例2: main

import javax.sound.midi.Synthesizer; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    Field f = SoftSynthesizer.class.getDeclaredField("testline");
    f.setAccessible(true);
    f.set(null, new DummySourceDataLine());

    Synthesizer synth = new SoftSynthesizer();

    ReferenceCountingDevice rcd = (ReferenceCountingDevice)synth;

    // Test single open/close cycle

    Receiver recv = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test using 2 receiver cycle

    Receiver recv1 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    Receiver recv2 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");

    recv2.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    recv1.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test for explicit,implicit conflict

    synth.open();
    Receiver recv3 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv3.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    synth.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test for implicit,explicit conflict

    recv3 = rcd.getReceiverReferenceCounting();
    synth.open();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv3.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    synth.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:62,代码来源:ImplicitOpenClose.java

示例3: getSequencerConnectedToSynthesizer

import javax.sound.midi.Synthesizer; //导入方法依赖的package包/类
/**
 * Returns an instance of a Sequencer that uses the provided Synthesizer as its receiver.
 * This is useful when you have made changes to a specific Synthesizer--for example, you've
 * loaded in new patches--that you want the Sequencer to use.  You can then pass the Sequencer
 * to the Player constructor.
 *
 * @param synth The Synthesizer to use as the receiver for the returned Sequencer
 * @return a Sequencer with the provided Synthesizer as its receiver
 * @throws MidiUnavailableException
 * @version 4.0
 */
public static Sequencer getSequencerConnectedToSynthesizer(Synthesizer synth) throws MidiUnavailableException
{
    Sequencer sequencer = MidiSystem.getSequencer(false); // Get Sequencer which is not connected to new Synthesizer.
    sequencer.open();
    if (!synth.isOpen()) {
        synth.open();
    }
    sequencer.getTransmitter().setReceiver(synth.getReceiver()); // Connect the Synthesizer to our synthesizer instance.
    return sequencer;
}
 
开发者ID:d2fn,项目名称:passage,代码行数:22,代码来源:Player.java


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