1 /*********************************************************************************/
2 /*!
3 @file           MidiDeviceRt.h
4 
5 @author         L. J. Barman
6 
7     Copyright (c)   2008-2020, L. J. Barman, all rights reserved
8 
9     This file is part of the PianoBooster application
10 
11     PianoBooster is free software: you can redistribute it and/or modify
12     it under the terms of the GNU General Public License as published by
13     the Free Software Foundation, either version 3 of the License, or
14     (at your option) any later version.
15 
16     PianoBooster is distributed in the hope that it will be useful,
17     but WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19     GNU General Public License for more details.
20 
21     You should have received a copy of the GNU General Public License
22     along with PianoBooster.  If not, see <http://www.gnu.org/licenses/>.
23 
24 */
25 /*********************************************************************************/
26 
27 #ifndef __MIDI_DEVICE_RT_H__
28 #define __MIDI_DEVICE_RT_H__
29 
30 #include "MidiDeviceBase.h"
31 #include "rtmidi/RtMidi.h"
32 
33 class CMidiDeviceRt : public CMidiDeviceBase
34 {
35     virtual void init();
36     //! add a midi event to be played immediately
37     virtual void playMidiEvent(const CMidiEvent & event);
38     virtual int checkMidiInput();
39     virtual CMidiEvent readMidiInput();
40 
41     virtual QStringList getMidiPortList(midiType_t type);
42 
43     virtual bool openMidiPort(midiType_t type, QString portName);
44     virtual void closeMidiPort(midiType_t type, int index);
45 
validMidiConnection()46     virtual bool validMidiConnection() {return m_validConnection;}
47 
48     // based on the fluid synth settings
49     virtual int     midiSettingsSetStr(QString name, QString str);
50     virtual int     midiSettingsSetNum(QString name, double val);
51     virtual int     midiSettingsSetInt(QString name, int val);
52     virtual QString midiSettingsGetStr(QString name);
53     virtual double  midiSettingsGetNum(QString name);
54     virtual int     midiSettingsGetInt(QString name);
55 
56 public:
57     CMidiDeviceRt();
58     ~CMidiDeviceRt();
59 
60 
61 private:
62 
63     RtMidiOut *m_midiout;
64     RtMidiIn *m_midiin;
65 
66     double m_stamp;
67 
68     // 0 for input, 1 for output
69     int m_midiPorts[2];      // select which MIDI output port to open
70     std::vector<unsigned char> m_inputMessage;
71     unsigned char m_savedRawBytes[40]; // Raw data is used for used for a SYSTEM_EVENT
72     unsigned int m_rawDataIndex;
73 
74     // kotechnology added function to create indexed string. Format: "1 - Example"
75     QString addIndexToString(QString name, int index);
76 
77     bool m_validConnection;
78 };
79 
80 #endif //__MIDI_DEVICE_RT_H__
81