This discussion is archived
1 Reply Latest reply: Feb 15, 2012 12:23 PM by 810200 RSS

Realtime listening for MIDI events

917201 Newbie
Currently Being Moderated
I've found plenty of guidance for obtaining sequences of MIDI event and for reading files of MIDI data for example and for connecting sequencers to synthesizers. I've managed to write code that assembles MIDI messages and send them to ouput ports. But I can't find anything on realtime listening.

I want to write something that waits on a MIDI in port such that it can react if and when a MIDI event is received at that port. (I'm trying to write a realtime MIDI translator/mapper.) I was assuming some object would be messaged to read an event from the input port and that that thread would wait at that point until an event was received (and probably there would be some kind of exception so that you could interrupt the listener). It seems a simple thing, but I can't find it anywhere.

Any clues where to start and what to start with, please?
  • 1. Re: Realtime listening for MIDI events
    810200 Newbie
    Currently Being Moderated
    Interesting question. I haven't done this myself and am looking forward to learning the best answer as well. Meanwhile, I can offer a quick note about what I would try.

    I am assuming that the code receiving from the Port is like a TargetDataLine, and that there would be a read command in a while loop. Can you leave that running and test for the number of bytes read and use that as a condition? Or does the port return zero-filled bytes when there is no data? If so, the next option I'd consider would be to inspect the data in the read buffer for non-zero values.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points