Java 8 MidiDevice - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 MidiDevice class.

This code example shows how to use the following methods:close, getTransmitter, isOpen, open
     
    private void init() throws MidiUnavailableException
    { 
        try  
        { 
            if (!(device.isOpen())) {
              device.open();
            } 
     
            this.transmitter = device.getTransmitter();
            this.mrftd = new MidiReceiverForTransmitterDevice();
        } catch (MidiUnavailableException e)
        { 
            device.close();
            throw e;
        } 
    } 
     
    public Transmitter getTransmitter()
    { 
6
CodeRank
This code example shows how to use the following methods:getReceiver, isOpen, open
        init(); 
    } 
     
    private void init() throws MidiUnavailableException
    { 
        if (!(device.isOpen())) {
          device.open();
        } 
 
        this.receiver = device.getReceiver();
    } 
     
    /** 
     * Send the given sequence to the MIDI device - use this to send MIDI files 
     * to your keyboard! 
     *   
     * @param sequence The sequence to send to the MIDI device 
     */ 
    public void sendSequence(Sequence sequence)
    { 
5
CodeRank
This code example shows how to use the following methods:close, getTransmitter, isOpen, open, setSequence
	                if (metaMsg.getType() == 0x2F) {
	                    sequencer.close();
	                } 
	            } 
	        }); 
		} else if (sequencer.isOpen()) {
			sequencer.close(); // in case any other sequence is already playing
		} 
		sequencer.setSequence(MidiSystem.getSequence(file));
		sequencer.open();
 
		// slow it down just a bit 
		sequencer.setTempoFactor(tempo);
 
		sequencer.getTransmitter().setReceiver(recv);
		sequencer.start();
	} 
} 
5
CodeRank
This code example shows how to use the following methods:close, isOpen
		} 
		return false; 
	} 
 
	public void close() { 
		if (dev != null && dev.isOpen()) {
			dev.close();
		} 
	} 
 
	public static MidiDevice getMidiDevice(String name) {
 
		MidiDevice.Info[] info = MidiSystem.getMidiDeviceInfo();
 
		for (Info element : info) {
			if (element.getName().equals(name)) {
				try { 
					return MidiSystem.getMidiDevice(element);
				} catch (MidiUnavailableException e) {
					log.error("{}", e);
5
CodeRank
This code example shows how to use the following methods:isOpen, open, setLoopCount, setSequence
5
CodeRank
This code example shows how to use the following methods:isOpen, setMicrosecondPosition, stop
    /** 
     * Stops the music being played, if any. 
     */ 
    public void stop() 
    { 
        if (sequencer == null || !sequencer.isOpen())
            return; 
 
        sequencer.stop();
        sequencer.setMicrosecondPosition(0);
    } 
 
    /** 
     * Closes the device, indicating that the device should now release any 
     * system resources it is using. Once closed, no jgf.sound will be played 
     * again. 
     */ 
    public void close() 
    { 
        if (sequencer == null || !sequencer.isOpen())
4
CodeRank
This code example shows how to use the following methods:close
        }            
        //System.out.println("End of Play");         
    }         
 
	public void close() { 
		sequencer.close();
	}	 
	 
} 
4
CodeRank
This code example shows how to use the following methods:getReceiver
        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;
    } 
} 
3
CodeRank
This code example shows how to use the following methods:isOpen
 
    static String getDeviceStr(MidiDevice dev) {
        if (dev == null) {
            return "NULL"; 
        } 
        return getClassStr(dev) + ", " + (dev.isOpen() ? "OPENED" : "CLOSED");
    } 
 
    static void log(String s) {
        System.out.println(s);
    } 
 
} 
4
CodeRank
This code example shows how to use the following methods:isOpen
 
    static String getDeviceStr(MidiDevice dev) {
        if (dev == null) {
            return "NULL"; 
        } 
        return getClassStr(dev) + ", " + (dev.isOpen() ? "OPENED" : "CLOSED");
    } 
 
    static void log(String s) {
        System.out.println(s);
    } 
 
} 
4
CodeRank
See Code Examples for Java 8 MidiDevice Methods: