loadAPI(1.0);
host.defineController("Generic","Program changer","1.0","7ab8d8ee-fd26-11e4-a322-1697f925ec7b");
host.defineMidiPorts(0,1);
function init()
{
function nameObserver(arg){
name=arg;
res = name.match(/.*PC#([0-9]+).*/);
if (res!=null)
if (!(res[1] === undefined)){
program = parseInt(res[1]);
if (program != null){
println(program);
sendProgramChange(0,program);
}
}
}
var cursorTrack = host.createCursorTrack(0,0);
cursorTrack.addNameObserver(255,"",nameObserver);
}
Save the script in your bitwig controller scripts path (see below for downloadable file), add a Generic->Program changer controller in bitwig, and connect the midi output port of the controller script to your hardware or software emulation. In my case I selected Virtual Raw MIDI/1 (I use ubuntu, so I added modprobe snd-virmidi to my /etc/rc.local file, and I can connect to rakarrack this way).
Note: you also have to connect rakarrack to the same virtual alsa port (e.g. using patchage), and check "midi program change table" in rakarrack midi preferences, but this is not the main topic of this post.
Next, change the name of some bitwig track so that it contains the string PC#nn, where nn is a controller number. The precise string may be changed by changing the regular expression used in the script. I have two tracks using two different programs.
As you can see, PC#nn is just a sub-string of the track name, which may still be descriptive. Now select one such track and watch your program change event to happen!
You can find the complete script here:
https://github.com/vincenzoml/vincenzomlBitwig
And in case you're wondering, here's some music I make, mostly with Bitwig on Linux nowadays.
https://soundcloud.com/vincenzoml