List of usage examples for javax.sound.midi Receiver send
void send(MidiMessage message, long timeStamp);
From source file:de.ailis.midi4js.Midi4JS.java
/** * Sends a MIDI message to a receiver.//from w ww .j a v a 2 s.co m * * @param receiverHandle * The handle of the receiver. * @param jsonMessageStr * Then message encoded as a JSON string * @param timeStamp * The message timestamp * @throws InvalidMidiDataException * When the midi data is invalid. * @throws JSONException * When JSON data could not be parsed. */ public void sendMessage(final int receiverHandle, final String jsonMessageStr, final long timeStamp) throws InvalidMidiDataException, JSONException { final Receiver receiver = resolveReceiverHandle(receiverHandle); final JSONObject json = new JSONObject(jsonMessageStr); final JSONArray jsonData = json.getJSONArray("data"); final int length = jsonData.length(); final byte[] data = new byte[length]; for (int i = 0; i < length; i++) data[i] = (byte) (jsonData.getInt(i) & 0xff); final RawMidiMessage message = new RawMidiMessage(data); receiver.send(message, timeStamp); }
From source file:org.monome.pages.configuration.MonomeConfiguration.java
public void sendMidi(ShortMessage midiMsg, int index) { String[] midiOutOptions = getMidiOutOptions(index); for (int i = 0; i < midiOutOptions.length; i++) { if (midiOutOptions[i] == null) { continue; }// ww w .ja v a 2 s . c om Receiver recv = getMidiReceiver(midiOutOptions[i]); if (recv != null) { recv.send(midiMsg, MidiDeviceFactory.getDevice(recv).getMicrosecondPosition()); } } }