MuseScore  3.4
Music composition and notation
mididriver.h
Go to the documentation of this file.
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 {
45  unsigned char _alsaPort;
46  unsigned char _alsaClient;
47 
48  protected:
49  unsigned char alsaPort() const { return _alsaPort; }
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:
71  QList<Port> midiOutPorts;
72  Seq* seq;
73 
74  public:
75  MidiDriver(Seq* s) { seq = s; }
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 
Port()
Definition: mididriver.cpp:42
MidiDriver(Seq *s)
Definition: mididriver.h:75
Definition: pm.h:40
unsigned char _alsaPort
Definition: mididriver.h:45
unsigned char alsaPort() const
Definition: mididriver.h:49
Definition: mididriver.h:44
virtual ~MidiDriver()
Definition: mididriver.h:76
QList< Port > midiOutPorts
Definition: mididriver.h:71
Definition: mididriver.h:68
Seq * seq
Definition: mididriver.h:72
Definition: seq.h:104
enum Ms::Port::@44 type
Definition: aeolus.cpp:26
Definition: event.h:264
Port midiInPort
Definition: mididriver.h:70
bool operator<(const Port &p) const
Definition: mididriver.cpp:88
unsigned char alsaClient() const
Definition: mididriver.h:50
bool isZero() const
Definition: mididriver.cpp:67
Definition: mididriver.h:43
unsigned char _alsaClient
Definition: mididriver.h:46
bool operator==(const Port &p) const
Definition: mididriver.cpp:76
Definition: mididriver.h:44
Definition: alsamidi.h:40
void setZero()
Definition: mididriver.cpp:58