drumstick
1.0.2
|
This document is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/
This is the reference documentation for drumstick. This library is a set of C++ MIDI related classes, using Qt5 objects, idioms and style. ALSA sequencer provides software support for MIDI technology on Linux.
This document is a work in progress, in a very early state. It will be always in development. Please visit the drumstick web site to read the latest version.
For an introduction to design and programming with C++ and Qt, see the book "An Introduction to Design Patterns in C++ with Qt" by by Alan Ezust and Paul Ezust. It is available published on dead trees, and also online.
Here is how a simple program playing a note-on MIDI message using drumstick looks like:
#include <QApplication> #include <drumstick.h> int main(int argc, char **argv) { QApplication app(argc, argv, false); // create a client object on the heap drumstick::MidiClient *client = new drumstick::MidiClient; client->open(); client->setClientName( "MyClient" ); // create the port. Pointer is owned by the client instance drumstick::MidiPort *port = client->createPort(); port->setPortName( "MyPort" ); port->setCapability( SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ ); port->setPortType( SND_SEQ_PORT_TYPE_MIDI_GENERIC ); // subscribe the port to some other client:port port->subscribeTo( "20:0" ); // or "name:port", like in "KMidimon:0" // create an event object on the stack, to send a note on message drumstick::NoteOnEvent ev( 0, 66, 100 ); // (channel, note number, velocity) ev.setSource( port->getPortId() ); ev.setSubscribers(); // deliver to all the connected ports ev.setDirect(); // not scheduled, deliver immediately client->output( &ev ); // or outputDirect() if you prefer not buffered client->drainOutput(); // flush the buffer // close and clean client->close(); delete client; return 0; }
There are more examples in the source tree, under the utils/ directory, and you can also see applications using this library, like kmetronome and kmidimon.
Parts of this documentation are copied from the ALSA library documentation, whose authors are: