On Friday 06 May 2011, alessandro.filippo@xxxxxxxxxxx wrote: > You could use KASEQ in shell > scripts. http://kmetronome.sourceforge.net/kaseq.shtml Thanks for mentioning Kaseq. I thought that nobody was using this program anymore. The problem with Kaseq is that DCOP is deprecated. I'm planning to migrate it to DBus and release a new version some day, time permitting. > --------- Original Message -------- > Da: "Atte André Jensen" <atte@xxxxxxxx> > To: "linux audio users" <linux-audio-user@xxxxxxxxxxxxxxxxxxxx> > Oggetto: sending program change from the commandline > Data: 05/05/11 23:21 > > > > Hi > > Is there an commandline application that'll allow me to send program > change (and bank select) from the commandline? I'm trying to setup > something to flip programs on my hardware synths quickly between songs > in a live setting... It is easy to make this utility in C++ with Drumstick, like the attached one. The destination is hard-coded to "KMidimon:0", but I'm sure that you can change or add your own MIDI interface easily. To build it, you need to install Qt4 and Drumstick development libraries first. Put both files: sndpgmchg.pro and sndpgmchg.cpp, at some directory and compile the program using the commands: $ qmake $ make Regards, Pedro
Attachment:
sndpgmchg.pro
Description: application/vnd.nokia.qt.qmakeprofile
/* * sndpgmchg.cpp * Sends MIDI bank change and program change ALSA messages * * Drumstick library documentation: * http://drumstick.sourceforge.net/docs/ * * usage: * sndpgmchg CHAN CC0 CC32 PGM * * CHAN: MIDI channel (0..15) * CC0: bank change, MSB (0..127) * CC32: bank change, LSB (0..127) * PGM: program change (0..127) * * example: sndpgmchg 0 1 0 2 * * by: Pedro Lopez-Cabanillas * This code is in the public domain */ #include <QCoreApplication> #include <QTextStream> #include <QStringList> #include <QList> #include <drumstick.h> int main (int argc, char **argv) { QCoreApplication app(argc, argv); QTextStream cout (stdout, QIODevice::WriteOnly); int chan = 0, cc0 = 0, cc32 = 0, pgm = 0; // get the command line arguments QStringList arglist = app.arguments (); if (arglist.count () < 5) { cout << "Usage: " << arglist.at (0) << " CHAN CC0 CC32 PGM" << endl; return 1; } chan = arglist.at (1).toInt (); cc0 = arglist.at (2).toInt (); cc32 = arglist.at (3).toInt (); pgm = arglist.at (4).toInt (); // create a client object on the heap drumstick::MidiClient *client = new drumstick::MidiClient; client->open (); client->setClientName ("sndpgmchg"); // create the port drumstick::MidiPort *port = client->createPort (); port->setPortName ("output port"); port->setCapability (SND_SEQ_PORT_CAP_READ); port->setPortType (SND_SEQ_PORT_TYPE_MIDI_GENERIC); // subscribe the output port to some destination(s) port->subscribeTo ("KMidimon:0"); // client-name:port-id // port->subscribeTo ("129:0"); // client-id:port-id // create a list of sequencer events QList<drumstick::SequencerEvent*> lst; lst << new drumstick::ControllerEvent (chan, 0, cc0); // bank change, MSB lst << new drumstick::ControllerEvent (chan, 32, cc32); // bank change, LSB lst << new drumstick::ProgramChangeEvent (chan, pgm); // program change // send events foreach (drumstick::SequencerEvent *ev, lst) { ev->setSource (port->getPortId ()); ev->setSubscribers (); // deliver to all the connected ports ev->setDirect (); // not scheduled, deliver immediately client->outputDirect (ev); // not buffered } // close and clean client->close (); delete client; return 0; }
_______________________________________________ Linux-audio-user mailing list Linux-audio-user@xxxxxxxxxxxxxxxxxxxx http://lists.linuxaudio.org/listinfo/linux-audio-user