[chuck-users] Midi program change problem.

Kassen signal.automatique at gmail.com
Sun Jan 14 09:57:51 EST 2007

\Piccolos wrote:
> Hi all,

Hi there!

I'm a new Chuck user


> It works perfectly for noton and noteoff events but when I send A
> program Change,
> an error occurs :
> [chuck](via RtMidi): RtMidiOut::sendMessage: event parsing error!

Yeah, it should work for CC changes as well.

The issue relates to Program Change messages being two bytes while note and
cc messages (the ones which ChucK anticipates) are three bytes.

The good news is that it *can* work right now.

Anyway; if the first byte (.data1) is 192 the MIDI message will be a program
change and the receiving end (your synth and apparently rtmidiout) will
anticipate one data byte (holding the program number) after this. Sending a
second data byte (.data3) is bad midi syntax and this is probably what
RtMidiOut is complaining about. In the case of your code the second data
byte is probably the .data3 of the last three-byte message you got as your
input but I'm a little unsure there because to me it seemed that ChucK's
MIDI in doesn't realy like two byte input messages  either (and I think it
ignores single byte clock messages).

To get back to your problem; I got the output of Program Change messages to
work fine with the .data3 set to "0" so I think this should work;
msgin.data1 => msgout.data1;
msgin.data2 => msgout.data2;

//this range just covers program change messages
if ( (msgin.data3 > 191 ) && (msgin.data3 < 208) ) 0 => msgout.data3;
else msgin.data3 => msgout.data3;


...but right now stuff isn't pluged in here so I can't test meaning no
refunds or waranty in case of fire, crashes or both. I got it to work with
.data3 zero-ed out on Windows at least.

Hope that helps,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20070114/77b68da1/attachment.htm 

More information about the chuck-users mailing list