drumstick  1.0.2
rtmidioutput.h
00001 /*
00002     Drumstick MIDI realtime input-output
00003     Copyright (C) 2009-2015 Pedro Lopez-Cabanillas <plcl@users.sf.net>
00004 
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License along
00016     with this program; if not, write to the Free Software Foundation, Inc.,
00017     51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00018 */
00019 
00020 #ifndef MIDIOUTPUT_H
00021 #define MIDIOUTPUT_H
00022 
00023 #include <QObject>
00024 #include <QString>
00025 #include <QStringList>
00026 #include <QtPlugin>
00027 #include <QSettings>
00028 
00029 #define MIDI_CHANNELS               16
00030 #define MIDI_GM_DRUM_CHANNEL        (10-1)
00031 #define MIDI_CTL_MSB_MAIN_VOLUME    0x07
00032 #define MIDI_CTL_ALL_SOUNDS_OFF     0x78
00033 #define MIDI_CTL_ALL_NOTES_OFF      0x7b
00034 #define MIDI_CTL_RESET_CONTROLLERS  0x79
00035 
00036 #define MIDI_STATUS_NOTEOFF         0x80
00037 #define MIDI_STATUS_NOTEON          0x90
00038 #define MIDI_STATUS_KEYPRESURE      0xa0
00039 #define MIDI_STATUS_CONTROLCHANGE   0xb0
00040 #define MIDI_STATUS_PROGRAMCHANGE   0xc0
00041 #define MIDI_STATUS_CHANNELPRESSURE 0xd0
00042 #define MIDI_STATUS_PITCHBEND       0xe0
00043 #define MIDI_STATUS_SYSEX           0xf0
00044 #define MIDI_STATUS_ENDSYSEX        0xf7
00045 #define MIDI_STATUS_REALTIME        0xf8
00046 
00047 #define MIDI_STATUS_MASK            0xf0
00048 #define MIDI_CHANNEL_MASK           0x0f
00049 
00050 #define MIDI_COMMON_QTRFRAME        0xF1
00051 #define MIDI_COMMON_SONGPP          0xF2
00052 #define MIDI_COMMON_SONSELECT       0xF3
00053 #define MIDI_COMMON_TUNEREQ         0xF6
00054 
00055 #define MIDI_REALTIME_CLOCK         0xF8
00056 #define MIDI_REALTIME_START         0xFA
00057 #define MIDI_REALTIME_CONTINUE      0xFB
00058 #define MIDI_REALTIME_STOP          0xFC
00059 #define MIDI_REALTIME_SENSING       0xFE
00060 #define MIDI_REALTIME_RESET         0xFF
00061 
00062 #define MIDI_LSB(x) (x % 0x80)
00063 #define MIDI_MSB(x) (x / 0x80)
00064 
00065 namespace drumstick {
00066 namespace rt {
00067 
00071     class MIDIOutput : public QObject
00072     {
00073         Q_OBJECT
00074 
00075     public:
00080         explicit MIDIOutput(QObject *parent = 0) : QObject(parent) {}
00084         virtual ~MIDIOutput() {}
00089         virtual void initialize(QSettings* settings) = 0;
00094         virtual QString backendName() = 0;
00099         virtual QString publicName() = 0;
00104         virtual void setPublicName(QString name) = 0;
00109         virtual QStringList connections(bool advanced = false) = 0;
00114         virtual void setExcludedConnections(QStringList conns) = 0;
00119         virtual void open(QString name) = 0;
00123         virtual void close() = 0;
00128         virtual QString currentConnection() = 0;
00129 
00130     public Q_SLOTS:
00137         virtual void sendNoteOff(int chan, int note, int vel) = 0;
00138 
00145         virtual void sendNoteOn(int chan, int note, int vel) = 0;
00146 
00153         virtual void sendKeyPressure(int chan, int note, int value) = 0;
00154 
00161         virtual void sendController(int chan, int control, int value) = 0;
00162 
00168         virtual void sendProgram(int chan, int program) = 0;
00169 
00175         virtual void sendChannelPressure(int chan, int value) = 0;
00176 
00182         virtual void sendPitchBend(int chan, int value) = 0;
00183 
00188         virtual void sendSysex(const QByteArray& data) = 0;
00189 
00194         virtual void sendSystemMsg(const int status) = 0;
00195     };
00196 }
00197 }
00198 
00199 Q_DECLARE_INTERFACE(drumstick::rt::MIDIOutput, "net.sourceforge.drumstick.rt.MIDIOutput/1.0")
00200 
00201 #endif /* MIDIOUTPUT_H */