Skip to content

Qt library for MIDI output & MIDI file I/O.

License

Notifications You must be signed in to change notification settings

midi-pascal/qtmidi

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QMidi Build Status

A simple, cross-platform way to support MIDI. Classes for MIDI Output and MIDI File I/O are supported. MIDI output is supported on Windows (via mmsystem), Linux (via ALSA), and Haiku (via MidiKit2).

MIDI Output

To output MIDI, simply initialize the QMidiOut class...

QMap<QString,QString> vals = QMidiOut::devices();
/* outDeviceNames() returns a QMap where the key is the ID and
 * the value is the user-friendly name. */
QMidiOut midi;
midi.connect("key goes here");

...and then send messages:

midi.setInstr(0, 0);
/* Voice (0-15), Instrument (0-127) */
midi.noteOn(60,0);
/* Note (0-127), Voice (0-15) [, Velocity (0-127)] */
midi.noteOff(60,0);
/* Note (0-127), Voice (0-15) */

Alternatively, you could just send MIDI note data:

midi.sendMsg(0x90+0 | 60<<8 | 64<<16);
/* note on, voice 0; middle C (60); velocity 64 */

Or construct a QMidiEvent (from QMidiFile.h) and send it:

QMidiEvent* e = new QMidiEvent();
e->setType(QMidiEvent::NoteOn);
e->setVoice(0);
e->setNote(60);
e->setVelocity(64);
midi.sendEvent(e);

Before your application closes or if you want to open output on a different port...

midi.disconnect();

MIDI File I/O

Classes for MIDI file I/O were rewritten from Div's Midi Utilities (homepage | Google Code) into Qt/C++.

Use the classes like so:

QMidiFile f;
f.load(" .. some filename .. ");
f.save(" .. some filename .. ");

You can get the events using f.events() which returns a QList<QMidiEvent*>*. For information on using these classes in conjuction with the MIDI output class to play files, see the qtplaysmf example in the examples folder.

About

Qt library for MIDI output & MIDI file I/O.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 99.3%
  • QMake 0.7%