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


Java Receiver.close方法代碼示例

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


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

示例1: testReceiverSend

import javax.sound.midi.Receiver; //導入方法依賴的package包/類
/**
 * Execute Receiver.send() and expect that there is no exception.
 */
private static boolean testReceiverSend() {
    boolean result = true;

    Receiver receiver;
    ShortMessage shMsg = new ShortMessage();

    try {
        receiver = MidiSystem.getReceiver();
        shMsg.setMessage(ShortMessage.NOTE_ON, 0,60, 93);
        try {
            receiver.send( shMsg, -1 );
        } catch(IllegalStateException ilEx) {
            ilEx.printStackTrace(System.out);
            out("IllegalStateException was thrown incorrectly!");
            result = false;
        }
        receiver.close();
    } catch(MidiUnavailableException e) {
        out("Midi unavailable, cannot test.");
    } catch(InvalidMidiDataException ine) {
        out("InvalidMidiDataException, cannot test.");
    }
    return result;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:28,代碼來源:ClosedReceiver.java

示例2: captureMidiMessages

import javax.sound.midi.Receiver; //導入方法依賴的package包/類
@Override
protected void captureMidiMessages(final Receiver receiver) throws MidiUnavailableException {
	// Modify all MidiMessages so that they specify channel 10 (encoded as 9,
	// which I suppose means that 0 indicates midi channel 1)
	Receiver setChannelReceiver = new Receiver() {
		@Override
		public void send(MidiMessage message, long timeStamp) {
			if (message instanceof ShortMessage) {
				ShortMessage sm = (ShortMessage) message;
				byte[] data = sm.getMessage();
				byte orig = data[0];
				data[0] = (byte) ((orig | 9) & 0xff);
				message = Midi.createShortMessage(data);
			}
			receiver.send(message, timeStamp);
		}
		
		@Override
		public void close() {
			receiver.close();
		}
	};
	
	super.captureMidiMessages(setChannelReceiver);
}
 
開發者ID:daveho,項目名稱:Gervill4Beads,代碼行數:26,代碼來源:DemoPercussion.java

示例3: close

import javax.sound.midi.Receiver; //導入方法依賴的package包/類
/**
 * Closes the MIDI receiver.
 *
 * @param receiver the MIDI receiver.
 */
public static void close(Receiver receiver) {
    try {
        if (receiver != null) {
            receiver.close();
        }
    } catch (Exception e) {
        logger.warn("close", e);
    }
}
 
開發者ID:softelnet,項目名稱:sponge,代碼行數:15,代碼來源:MidiUtils.java

示例4: main

import javax.sound.midi.Receiver; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    AudioSynthesizer synth = new SoftSynthesizer();
    synth.open(new DummySourceDataLine(), null);
    assertTrue(synth.getReceivers().size() == 0);
    Receiver recv = synth.getReceiver();
    assertTrue(synth.getReceivers().size() == 1);
    recv.close();
    assertTrue(synth.getReceivers().size() == 0);
    synth.close();

}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:12,代碼來源:GetReceivers.java

示例5: closeAllTransmittersAndReceivers

import javax.sound.midi.Receiver; //導入方法依賴的package包/類
/**
 * Closes all transmitters and receivers of the midi device
 * 
 * @param device
 */
public static void closeAllTransmittersAndReceivers(MidiDevice device) {

	for (Transmitter transmitter : device.getTransmitters()) {
		transmitter.close();
	}

	for (Receiver receiver : device.getReceivers()) {
		receiver.close();

	}
}
 
開發者ID:aguelle,項目名稱:MIDI-Automator,代碼行數:17,代碼來源:MidiUtils.java

示例6: createMessageSource

import javax.sound.midi.Receiver; //導入方法依賴的package包/類
private void createMessageSource(final Instrument liveInstr) throws MidiUnavailableException,
		IOException {
	this.liveSynth = getInstrumentInfo(liveInstr);

	// Filter incoming MidiMessages to:
	// - change to channel 10 (if this is a percussion instrument)
	// - add them to capturedEvents list
	final Receiver delegate = liveSynth.source;
	liveSynth.source = new Receiver() {
		@Override
		public void send(MidiMessage message, long timeStamp) {
			if (liveInstr.getType() == InstrumentType.MIDI_PERCUSSION) {
				// Percussion messages should on channel 10
				if (message instanceof ShortMessage) {
					ShortMessage smsg = (ShortMessage) message;
					message = Midi.createShortMessage(smsg.getStatus()|9, smsg.getData1(), smsg.getData2());
				}
			}

			capturedEvents.add(new MidiMessageAndTimeStamp(message, timeStamp));
			
			delegate.send(message, timeStamp);
		}
		
		@Override
		public void close() {
			delegate.close();
		}
	};
}
 
開發者ID:daveho,項目名稱:FunWithSound,代碼行數:31,代碼來源:Player.java

示例7: main

import javax.sound.midi.Receiver; //導入方法依賴的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

示例8: close

import javax.sound.midi.Receiver; //導入方法依賴的package包/類
/**
 * Closes the Core MIDI Device, which also closes all of its receivers
 * 
 */

@Override
public void close() {

  if ( isOpen.compareAndSet(true, false) ) {

    // Reset the context data
    startTime.set(0);

    // Close all our receivers, which will also clear the list.
    // We iterate on a copy of the receiver list to avoid issues with concurrent modification.
    for ( Receiver receiver : getReceivers() ) {

      receiver.close();

    }

  }

}
 
開發者ID:DerekCook,項目名稱:CoreMidi4J,代碼行數:25,代碼來源:CoreMidiDestination.java


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