drumstick  1.0.2
drumstick Documentation
Author:
Copyright © 2009-2014 Pedro López-Cabanillas <plcl AT users.sf.net>
Date:
2014-08-30
Version:
1.0.0

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/

Abstract

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.

See also:
http://qt-project.org/doc/qt-5/index.html
http://www.alsa-project.org/alsa-doc/alsa-lib/seq.html
http://www.ics.com/design-patterns
http://www.midi.org/aboutmidi/tutorials.php

Disclaimer

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.

See also:
http://drumstick.sourceforge.net

Introduction

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.

See also:
http://kmetronome.sourceforge.net
http://kmidimon.sourceforge.net
http://kmid2.sourceforge.net
http://vmpk.sourceforge.net

Acknowledgments

Parts of this documentation are copied from the ALSA library documentation, whose authors are:

  • Jaroslav Kysela <perex AT perex.cz>
  • Abramo Bagnara <abramo AT alsa-project.org>
  • Takashi Iwai <tiwai AT suse.de>
  • Frank van de Pol <fvdpol AT coil.demon.nl>