MIDI-OX User Forum (http://www.midiox.com/cgi-bin/yabb/YaBB.pl)
MIDI-OX >> Scripting Questions >> MidiInput event & GetMidiInputRaw()
(Message started by: Linus on Mar 24th, 2003, 5:58pm)

Title: MidiInput event & GetMidiInputRaw()
Post by Linus on Mar 24th, 2003, 5:58pm
Hello,
I'm trying to write a routine in C#, which maps patches to specified ports.

My problem: I need to know the channel on which a patch is changed, to correctly map all other events on this channel to the specified out port. But the MidiInput event, does not send the channel. So, I tried to use the GetMidiInputRaw() method, when the event is fired. But when I call the method, no further MidiInput events are fired. Is this by design?

My second problem: To circumgo the first problem, I tried simply to call GetMidiInputRaw() in a loop, but it seems that the status is always 192 after & 0x000000F0 (according documentation) to raw input value, although the channel and data values are changing

Title: Re: MidiInput event & GetMidiInputRaw()
Post by Jamie OConnell on Mar 25th, 2003, 11:14am

Quote:
I need to know the channel on which a patch is changed, to correctly map all other events on this channel to the specified out port. But the MidiInput event, does not send the channel.


In MIDI messages, the channel information is always supplied, but it is encoded as part of the status byte.  The low 4 bits of the status represent the channel (0 - 15, or 00 - 0F Hex).  You need to add one to this value to get the common human representation of channel (1 - 16).  

To obtain the channel in scripting, you would And the status with 0F:
channel = (status & 0x0F) + 1

If you need to use the channel in another status message, do not add one: low-level MIDI numbers channels 0 -15.





MIDI-OX User Forum » Powered by YaBB 1 Gold - SP 1.3.1!
YaBB © 2000-2003. All Rights Reserved.