GithubHelp home page GithubHelp logo

evildead / qmidi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from waddlesplash/qmidi

0.0 2.0 0.0 106 KB

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

License: MIT License

C++ 99.01% QMake 0.99%

qmidi's Introduction

QMidi Build Status

A simple, cross-platform way to support MIDI in Qt. MIDI Output and MIDI File I/O is supported. MIDI output is supported on Windows (Windows Multimedia), Linux (ALSA), and Haiku (Midi Kit 2).

MIDI Output

The QMidiOut class provides an interface to the system's MIDI Out.

/* devices() returns a QMap where the key is the ID and
 * the value is the user-friendly name. */
QMap<QString, QString> vals = QMidiOut::devices();
QMidiOut midi;
midi.connect(/* one of the keys (IDs) from `devices()` */);

There's an easy API for sending messages:

midi.setInstrument(/* voice */ 0, /* instrument */ 0);
midi.noteOn(/* note */ 60, /* voice */ 0 /* , velocity */);
midi.noteOff(/* note */ 60, /* voice */ 0);

Alternatively, you could just send raw MIDI messages:

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

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

QMidiEvent e;
e.setType(QMidiEvent::NoteOn);
e.setVoice(0);
e.setNote(60);
e.setVelocity(64);
midi.sendEvent(e);

Once you're done:

midi.disconnect();

MIDI File I/O

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

Quick example:

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.