1 |
schoenebeck |
201 |
/*************************************************************************** |
2 |
|
|
* * |
3 |
|
|
* LinuxSampler - modular, streaming capable sampler * |
4 |
|
|
* * |
5 |
|
|
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
schoenebeck |
476 |
* Copyright (C) 2005 Christian Schoenebeck * |
7 |
schoenebeck |
201 |
* * |
8 |
|
|
* This program is free software; you can redistribute it and/or modify * |
9 |
|
|
* it under the terms of the GNU General Public License as published by * |
10 |
|
|
* the Free Software Foundation; either version 2 of the License, or * |
11 |
|
|
* (at your option) any later version. * |
12 |
|
|
* * |
13 |
|
|
* This program is distributed in the hope that it will be useful, * |
14 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
15 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
16 |
|
|
* GNU General Public License for more details. * |
17 |
|
|
* * |
18 |
|
|
* You should have received a copy of the GNU General Public License * |
19 |
|
|
* along with this program; if not, write to the Free Software * |
20 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * |
21 |
|
|
* MA 02111-1307 USA * |
22 |
|
|
***************************************************************************/ |
23 |
|
|
|
24 |
|
|
#ifndef __LS_MIDIINPUTDEVICEALSA_H__ |
25 |
|
|
#define __LS_MIDIINPUTDEVICEALSA_H__ |
26 |
|
|
|
27 |
|
|
#include <alsa/asoundlib.h> |
28 |
|
|
|
29 |
|
|
#include "../../common/global.h" |
30 |
|
|
#include "../../common/Thread.h" |
31 |
|
|
#include "MidiInputDevice.h" |
32 |
|
|
|
33 |
|
|
namespace LinuxSampler { |
34 |
|
|
|
35 |
|
|
/** ALSA MIDI input driver |
36 |
|
|
* |
37 |
|
|
* Implements MIDI input for the Advanced Linux Sound Architecture |
38 |
|
|
* (ALSA). |
39 |
|
|
*/ |
40 |
|
|
class MidiInputDeviceAlsa : public MidiInputDevice, public Thread { |
41 |
|
|
public: |
42 |
schoenebeck |
221 |
|
43 |
|
|
/** |
44 |
|
|
* MIDI Port implementation for the ALSA MIDI input driver. |
45 |
|
|
*/ |
46 |
|
|
class MidiInputPortAlsa : public MidiInputPort { |
47 |
|
|
public: |
48 |
|
|
/** MIDI Port Parameter 'NAME' |
49 |
|
|
* |
50 |
|
|
* Used to assign an arbitrary name to the MIDI port. |
51 |
|
|
*/ |
52 |
|
|
class ParameterName : public MidiInputPort::ParameterName { |
53 |
|
|
public: |
54 |
|
|
ParameterName(MidiInputPort* pPort) throw (LinuxSamplerException); |
55 |
|
|
virtual void OnSetValue(String s) throw (LinuxSamplerException); |
56 |
|
|
}; |
57 |
|
|
|
58 |
|
|
/** MIDI Port Parameter 'ALSA_SEQ_BINDINGS' |
59 |
|
|
* |
60 |
|
|
* Used to connect to other Alsa sequencer clients. |
61 |
|
|
*/ |
62 |
|
|
class ParameterAlsaSeqBindings : public DeviceRuntimeParameterStrings { |
63 |
|
|
public: |
64 |
|
|
ParameterAlsaSeqBindings(MidiInputPortAlsa* pPort); |
65 |
|
|
virtual String Description(); |
66 |
|
|
virtual bool Fix(); |
67 |
|
|
virtual std::vector<String> PossibilitiesAsString(); |
68 |
|
|
virtual void OnSetValue(std::vector<String> vS) throw (LinuxSamplerException); |
69 |
|
|
protected: |
70 |
|
|
MidiInputPortAlsa* pPort; |
71 |
|
|
}; |
72 |
|
|
|
73 |
schoenebeck |
476 |
/** MIDI Port Parameter 'ALSA_SEQ_ID' |
74 |
|
|
* |
75 |
|
|
* Reflects the ALSA sequencer ID of this MIDI port, |
76 |
|
|
* e.g. "128:0". |
77 |
|
|
*/ |
78 |
|
|
class ParameterAlsaSeqId : public DeviceRuntimeParameterString { |
79 |
|
|
public: |
80 |
|
|
ParameterAlsaSeqId(MidiInputPortAlsa* pPort); |
81 |
|
|
virtual String Description(); |
82 |
|
|
virtual bool Fix(); |
83 |
|
|
virtual std::vector<String> PossibilitiesAsString(); |
84 |
|
|
virtual void OnSetValue(String s); |
85 |
|
|
}; |
86 |
|
|
|
87 |
schoenebeck |
221 |
void ConnectToAlsaMidiSource(const char* MidiSource); |
88 |
|
|
protected: |
89 |
|
|
MidiInputPortAlsa(MidiInputDeviceAlsa* pDevice) throw (MidiInputException); |
90 |
|
|
~MidiInputPortAlsa(); |
91 |
|
|
friend class MidiInputDeviceAlsa; |
92 |
|
|
private: |
93 |
|
|
MidiInputDeviceAlsa* pDevice; |
94 |
schoenebeck |
277 |
|
95 |
|
|
friend class ParameterName; |
96 |
|
|
friend class ParameterAlsaSeqBindings; |
97 |
schoenebeck |
221 |
}; |
98 |
|
|
|
99 |
schoenebeck |
551 |
MidiInputDeviceAlsa(std::map<String,DeviceCreationParameter*> Parameters, void* pSampler); |
100 |
schoenebeck |
201 |
~MidiInputDeviceAlsa(); |
101 |
|
|
|
102 |
|
|
// derived abstract methods from class 'MidiInputDevice' |
103 |
|
|
void Listen(); |
104 |
|
|
void StopListen(); |
105 |
schoenebeck |
221 |
virtual String Driver(); |
106 |
|
|
static String Name(); |
107 |
|
|
static String Description(); |
108 |
|
|
static String Version(); |
109 |
schoenebeck |
201 |
|
110 |
schoenebeck |
221 |
MidiInputPortAlsa* CreateMidiPort(); |
111 |
schoenebeck |
201 |
protected: |
112 |
|
|
int Main(); ///< Implementation of virtual method from class Thread |
113 |
|
|
private: |
114 |
|
|
snd_seq_t* hAlsaSeq; |
115 |
|
|
int hAlsaSeqClient; ///< Alsa Sequencer client ID |
116 |
schoenebeck |
277 |
|
117 |
|
|
friend class MidiInputPortAlsa; |
118 |
|
|
friend class MidiInputPortAlsa::ParameterName; |
119 |
|
|
friend class MidiInputPortAlsa::ParameterAlsaSeqBindings; |
120 |
schoenebeck |
201 |
}; |
121 |
|
|
} |
122 |
|
|
|
123 |
|
|
#endif // __LS_MIDIINPUTDEVICEALSA_H__ |