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


Java Synthesizer.close方法代码示例

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


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

示例1: main

import javax.sound.midi.Synthesizer; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    // the internal synthesizer needs a soundcard to work properly
    if (!isSoundcardInstalled()) {
        return;
    }
    Synthesizer theSynth = MidiSystem.getSynthesizer();
    System.out.println("Got synth: "+theSynth);
    theSynth.open();
    try {
        Soundbank theSoundbank = theSynth.getDefaultSoundbank();
        System.out.println("Got soundbank: "+theSoundbank);
        theSynth.loadAllInstruments(theSoundbank);
        try {
                if (!checkInstrumentNames(theSynth)) {
                        throw new Exception("Test failed");
                }
        } finally {
                theSynth.unloadAllInstruments(theSoundbank);
        }
    } finally {
        theSynth.close();
    }
    System.out.println("Test passed.");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:ExtraCharInSoundbank.java

示例2: main

import javax.sound.midi.Synthesizer; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
			
	Synthesizer synth = MidiSystem.getSynthesizer();
	synth.open();
	synth.unloadAllInstruments(synth.getDefaultSoundbank());
	synth.loadAllInstruments(new MyOscillator());
	Sequence seq = MidiSystem.getSequence(FMTest1.class.getResource("/FMTest1.mid"));
	Sequencer seqr = MidiSystem.getSequencer(false);
	seqr.open();
	seqr.getTransmitter().setReceiver(synth.getReceiver());
	seqr.setSequence(seq);
	seqr.start();
	
	System.out.println();
	System.out.println("Is active, press enter to stop");
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	br.readLine();
	System.out.println("Stop...");
	
	seqr.stop();
	seqr.close();
	synth.close();
	
	System.exit(0);
}
 
开发者ID:bluenote10,项目名称:gervill,代码行数:26,代码来源:FMTest1.java

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

示例4: main

import javax.sound.midi.Synthesizer; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
    Synthesizer synth = null;
    boolean failed = false;
    boolean notexec = false;
    try {
        synth = MidiSystem.getSynthesizer();
        System.out.println("Got synth: "+synth);
        synth.open();

        int latency = (int) synth.getLatency();
        System.out.println("  -> latency: "
                           +latency
                           +" microseconds");
        if (latency < 5000 && latency > 0) {
            System.out.println("## This latency is VERY small, probably due to this bug.");
            System.out.println("## This causes failure of this test.");
            failed = true;
        }
    } catch (MidiUnavailableException mue) {
        System.err.println("MidiUnavailableException was "
                           +"thrown: " + mue);
        System.out.println("could not test.");
        notexec = true;
    } catch(SecurityException se) {
        se.printStackTrace();
        System.err.println("Sound access is not denied but "
        + "SecurityException was thrown!");
        notexec = true;
    } finally {
        if (synth != null) synth.close();
    }


    if (failed) {
        throw new Exception("Test FAILED!");
    }
    if (notexec) {
        System.out.println("Test not failed.");
    } else {
        System.out.println("Test Passed.");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:43,代码来源:SynthesizerGetLatency.java


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