1 |
/*************************************************************************** |
2 |
* * |
3 |
* Copyright (C) 2008 Andreas Persson * |
4 |
* * |
5 |
* This program is free software; you can redistribute it and/or modify * |
6 |
* it under the terms of the GNU General Public License as published by * |
7 |
* the Free Software Foundation; either version 2 of the License, or * |
8 |
* (at your option) any later version. * |
9 |
* * |
10 |
* This program is distributed in the hope that it will be useful, * |
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
13 |
* GNU General Public License for more details. * |
14 |
* * |
15 |
* You should have received a copy of the GNU General Public License * |
16 |
* along with this program; if not, write to the Free Software * |
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * |
18 |
* MA 02110-1301 USA. * |
19 |
***************************************************************************/ |
20 |
|
21 |
#ifndef LS_MIDIINPUTDEVICEJACK_H |
22 |
#define LS_MIDIINPUTDEVICEJACK_H |
23 |
|
24 |
#include <jack/midiport.h> |
25 |
|
26 |
#include "MidiInputDevice.h" |
27 |
|
28 |
namespace LinuxSampler { |
29 |
|
30 |
class JackClient; |
31 |
|
32 |
/** JACK MIDI input driver |
33 |
* |
34 |
* Implements MIDI input for the JACK Audio Connection Kit (JACK). |
35 |
*/ |
36 |
class MidiInputDeviceJack : public MidiInputDevice { |
37 |
public: |
38 |
|
39 |
/** |
40 |
* MIDI Port implementation for the JACK MIDI input driver. |
41 |
*/ |
42 |
class MidiInputPortJack : public MidiInputPort { |
43 |
public: |
44 |
/** MIDI Port Parameter 'NAME' |
45 |
* |
46 |
* Used to assign an arbitrary name to the MIDI port. |
47 |
*/ |
48 |
class ParameterName : public MidiInputPort::ParameterName { |
49 |
public: |
50 |
ParameterName(MidiInputPortJack* pPort) throw (Exception); |
51 |
virtual void OnSetValue(String s) throw (Exception); |
52 |
protected: |
53 |
MidiInputPortJack* pPort; |
54 |
}; |
55 |
|
56 |
/** MIDI Port Parameter 'JACK_BINDINGS' |
57 |
* |
58 |
* Used to connect to other JACK clients. |
59 |
*/ |
60 |
class ParameterJackBindings : public DeviceRuntimeParameterStrings { |
61 |
public: |
62 |
ParameterJackBindings(MidiInputPortJack* pPort); |
63 |
virtual String Description(); |
64 |
virtual bool Fix(); |
65 |
virtual std::vector<String> PossibilitiesAsString(); |
66 |
virtual void OnSetValue(std::vector<String> vS); |
67 |
static String Name(); |
68 |
protected: |
69 |
MidiInputPortJack* pPort; |
70 |
std::vector<String> Bindings; |
71 |
}; |
72 |
|
73 |
protected: |
74 |
MidiInputPortJack(MidiInputDeviceJack* pDevice) throw (MidiInputException); |
75 |
~MidiInputPortJack(); |
76 |
friend class MidiInputDeviceJack; |
77 |
private: |
78 |
MidiInputDeviceJack* pDevice; |
79 |
jack_port_t* hJackPort; |
80 |
}; |
81 |
|
82 |
/** MIDI Device Parameter 'NAME' |
83 |
* |
84 |
* Used to assign an arbitrary name to the JACK client of this |
85 |
* MIDI device. |
86 |
*/ |
87 |
class ParameterName : public DeviceCreationParameterString { |
88 |
public: |
89 |
ParameterName(); |
90 |
ParameterName(String s); |
91 |
virtual String Description(); |
92 |
virtual bool Fix(); |
93 |
virtual bool Mandatory(); |
94 |
virtual std::map<String,DeviceCreationParameter*> DependsAsParameters(); |
95 |
virtual std::vector<String> PossibilitiesAsString(std::map<String,String> Parameters); |
96 |
virtual optional<String> DefaultAsString(std::map<String,String> Parameters); |
97 |
virtual void OnSetValue(String s) throw (Exception); |
98 |
static String Name(); |
99 |
}; |
100 |
|
101 |
MidiInputDeviceJack(std::map<String,DeviceCreationParameter*> Parameters, void* pSampler); |
102 |
~MidiInputDeviceJack(); |
103 |
|
104 |
// derived abstract methods from class 'MidiInputDevice' |
105 |
void Listen(); |
106 |
void StopListen(); |
107 |
String Driver(); |
108 |
static String Name(); |
109 |
static String Description(); |
110 |
static String Version(); |
111 |
|
112 |
MidiInputPortJack* CreateMidiPort(); |
113 |
|
114 |
void Process(int nsamples); |
115 |
private: |
116 |
jack_client_t* hJackClient; |
117 |
JackClient* pJackClient; |
118 |
}; |
119 |
} |
120 |
#endif |