We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSound,  Music Libraries › program change in midibus
Page Index Toggle Pages: 1
program change in midibus (Read 719 times)
program change in midibus
Mar 19th, 2009, 3:36pm
 
hello,
I am very happy to join the community of this excitiong language !
I would like to send a program change message (modify the midi instrument) in midibus. Is it possible?
Thanks!
Re: program change in midibus
Reply #1 - Mar 22nd, 2009, 5:13am
 
Hey mchr,

You can definitely do that with themidibus. It would look something like this ...

Code:

import themidibus.*;
MidiBus myBus;

void setup() {
myBus = new MidiBus(this, "MyInput", "MyOutput");
}

void draw() {
int status_byte = 0xC0;
// This is the status byte for a program change
int channel = 0;
// We'll use channel 0
int byte1 = 64;
// This will be the preset you are sending with your program change
int byte2 = 0;
// This is not used for program change so ignore it and set it to 0

myBus.sendMessage(status_byte, channel, byte1, byte2);
//Send the custom message

delay(1000); // Take a break
}


I like to use http://www.srm.com/qtma/davidsmidispec.html as a reference for the Midi spec. It's handy to find out the status byte of the command you want to send and to know what bytes 1 and 2 do in each case.

Sparky
Re: program change in midibus
Reply #2 - Mar 23rd, 2009, 7:24am
 
Thanks for your reply!
The midi messages' syntax is very complex (at least for me) without a precise exemple, and yours is very comprehensible. I think you are this library's creator. Congratulations for your work! It is surprising to me that in processing we can select among numerous midi libraries, because in other languages i spent too much time to find only one! Furthermore, processing is cross-platform, but very simple in comparison with java.
Page Index Toggle Pages: 1