1 //============================================================================= 2 // MuseScore 3 // Linux Music Score Editor 4 // 5 // Copyright (C) 2008-2009 Werner Schweer and others 6 // 7 // AlsaDriver based on code from Fons Adriaensen (clalsadr.cc) 8 // Copyright (C) 2003 Fons Adriaensen 9 // partly based on original work from Paul Davis 10 // 11 // This program is free software; you can redistribute it and/or modify 12 // it under the terms of the GNU General Public License version 2. 13 // 14 // This program is distributed in the hope that it will be useful, 15 // but WITHOUT ANY WARRANTY; without even the implied warranty of 16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 // GNU General Public License for more details. 18 // 19 // You should have received a copy of the GNU General Public License 20 // along with this program; if not, write to the Free Software 21 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 //============================================================================= 23 24 #ifndef __MIDIDRIVER_H__ 25 #define __MIDIDRIVER_H__ 26 27 #if !defined(Q_OS_WIN) 28 #include <poll.h> 29 #endif 30 31 #include "config.h" 32 #include "driver.h" 33 34 namespace Ms { 35 36 class Event; 37 class Seq; 38 39 //--------------------------------------------------------- 40 // Port 41 //--------------------------------------------------------- 42 43 class Port { 44 enum { ALSA_TYPE, ZERO_TYPE } type; 45 unsigned char _alsaPort; 46 unsigned char _alsaClient; 47 48 protected: alsaPort()49 unsigned char alsaPort() const { return _alsaPort; } alsaClient()50 unsigned char alsaClient() const { return _alsaClient; } 51 52 public: 53 Port(); 54 Port(unsigned char client, unsigned char port); 55 void setZero(); 56 bool isZero() const; 57 bool operator==(const Port& p) const; 58 bool operator<(const Port& p) const; 59 friend class MidiDriver; 60 friend class AlsaMidiDriver; 61 friend class PortMidiDriver; 62 }; 63 64 //--------------------------------------------------------- 65 // MidiDriver 66 //--------------------------------------------------------- 67 68 class MidiDriver { 69 protected: 70 Port midiInPort; 71 QList<Port> midiOutPorts; 72 Seq* seq; 73 74 public: MidiDriver(Seq * s)75 MidiDriver(Seq* s) { seq = s; } ~MidiDriver()76 virtual ~MidiDriver() {} 77 virtual bool init() = 0; 78 virtual void getInputPollFd(struct pollfd**, int* n) = 0; 79 virtual void getOutputPollFd(struct pollfd**, int* n) = 0; 80 virtual void read() = 0; 81 virtual void write(const Event&) = 0; 82 }; 83 84 #ifdef USE_ALSA 85 86 //--------------------------------------------------------- 87 // AlsaPort 88 //--------------------------------------------------------- 89 90 struct AlsaPort { 91 unsigned char _alsaPort; 92 unsigned char _alsaClient; 93 }; 94 95 #endif 96 97 98 } // namespace Ms 99 100 #endif 101 102