Search in sources :

Example 1 with MidiMetaMessageEvent

use of org.openksavi.sponge.midi.event.MidiMetaMessageEvent in project sponge by softelnet.

the class MidiSpongeEventReceiver method send.

@Override
public void send(MidiMessage message, long timeStamp) {
    try {
        if (sound) {
            midiPlugin.sound(message);
        }
        MidiMessageEvent<?> event;
        if (message instanceof ShortMessage) {
            event = MidiUtils.createShortMessageEvent(midiPlugin, (ShortMessage) message, timeStamp);
        } else if (message instanceof SysexMessage) {
            event = new MidiSysexMessageEvent(midiPlugin.getMidiSysexMessageEventName(), midiPlugin.getEngine().getDefaultParameters().getEventClonePolicy(), (SysexMessage) message, timeStamp);
        } else if (message instanceof MetaMessage) {
            event = new MidiMetaMessageEvent(midiPlugin.getMidiMetaMessageEventName(), midiPlugin.getEngine().getDefaultParameters().getEventClonePolicy(), (MetaMessage) message, timeStamp);
        } else {
            throw new SpongeException("Unknown MIDI message type: " + message.getClass());
        }
        midiPlugin.getEngine().getOperations().event(event).send();
    } catch (Exception e) {
        logger.error("send", e);
    }
}
Also used : ShortMessage(javax.sound.midi.ShortMessage) SpongeException(org.openksavi.sponge.SpongeException) SysexMessage(javax.sound.midi.SysexMessage) MetaMessage(javax.sound.midi.MetaMessage) MidiMetaMessageEvent(org.openksavi.sponge.midi.event.MidiMetaMessageEvent) SpongeException(org.openksavi.sponge.SpongeException) MidiSysexMessageEvent(org.openksavi.sponge.midi.event.MidiSysexMessageEvent)

Aggregations

MetaMessage (javax.sound.midi.MetaMessage)1 ShortMessage (javax.sound.midi.ShortMessage)1 SysexMessage (javax.sound.midi.SysexMessage)1 SpongeException (org.openksavi.sponge.SpongeException)1 MidiMetaMessageEvent (org.openksavi.sponge.midi.event.MidiMetaMessageEvent)1 MidiSysexMessageEvent (org.openksavi.sponge.midi.event.MidiSysexMessageEvent)1