This content has been marked as final. Show 3 replies
I don't do MIDI, but it seems to me that adding a ControllerEventListener for the controillers corresponding to noteOn (1000nnnn) and noteOff (1001nnnn) should do the trick.
| References: | [url http://download.oracle.com/javase/6/docs/api/javax/sound/midi/Sequencer.html#addControllerEventListener%28javax.sound.midi.ControllerEventListener, int%29]Sequencer.addControllerEventListener(ControllerEventListener listener, int controllers) |
| | [url http://www.midi.org/techspecs/midimessages.php]Summary of MIDI Messages |
Edited by: Darryl Burke -- dratted link syntax
I believe adding a controller listener will give you events from Table 3 (Control Change Messages, from your link), rather than from Table 2 (Expanded Messages List) which contains the note on/off events.
803100 wrote:I don't know that it's "easier", but, I know of a better approach than that...
This seems like it should be a trivial task using Java Midi. I simply want to add a listener to a Sequencer to be alerted when note on/off events occur. The only solution I've seen is to add a Meta listener and make a separate track with meta events that mimic note on/off events on other tracks.
Is there an easier way?
The problem with tracking note on and note off "events" is that those are consumable events. IE, the synthesizer eats them and poops out sound. If you want to see those events, you need to detect them before they're given to a synthesizer.
The best approach I've been able to advise people to detect those events is centered around the concept of a "pass-through" receiver-transmitter pair. So, rather than directly connecting some transmitter to a Synthesizer, you create a receiver to receive the MIDI messages, do whatever processing you want to do based on the events, and then send them off to the Synthesizer...
So you know when a note-on or off event occurs because you'll receive it before the synthesizer does.