1 |
senoner |
1485 |
/*************************************************************************** |
2 |
|
|
* * |
3 |
|
|
* LinuxSampler - modular, streaming capable sampler * |
4 |
|
|
* * |
5 |
|
|
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
|
|
* Copyright (C) 2005 - 2007 Christian Schoenebeck * |
7 |
|
|
* * |
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_MIDIINPUTDEVICEMME_H__ |
25 |
|
|
#define __LS_MIDIINPUTDEVICEMME_H__ |
26 |
|
|
|
27 |
|
|
#define MME_MAX_SYSEX_BUF_SIZE 32768 |
28 |
|
|
|
29 |
|
|
#include "../../common/global_private.h" |
30 |
|
|
#include "MidiInputDevice.h" |
31 |
|
|
|
32 |
|
|
#include <windows.h> |
33 |
|
|
#include <mmsystem.h> |
34 |
|
|
|
35 |
|
|
namespace LinuxSampler { |
36 |
|
|
|
37 |
|
|
/** MME MIDI input driver |
38 |
|
|
* |
39 |
|
|
* Implements MIDI input for the Windows Multimedia Extensions |
40 |
|
|
* (MME). |
41 |
|
|
*/ |
42 |
|
|
class MidiInputDeviceMme : public MidiInputDevice { |
43 |
|
|
public: |
44 |
senoner |
1500 |
|
45 |
|
|
class ParameterPorts : public DeviceCreationParameterInt { |
46 |
|
|
public: |
47 |
|
|
ParameterPorts(); |
48 |
|
|
ParameterPorts(String val); |
49 |
|
|
virtual String Description(); |
50 |
|
|
virtual bool Fix(); |
51 |
|
|
virtual bool Mandatory(); |
52 |
|
|
virtual std::map<String,DeviceCreationParameter*> DependsAsParameters(); |
53 |
|
|
virtual optional<int> DefaultAsInt(std::map<String,String> Parameters); |
54 |
|
|
virtual optional<int> RangeMinAsInt(std::map<String,String> Parameters); |
55 |
|
|
virtual optional<int> RangeMaxAsInt(std::map<String,String> Parameters); |
56 |
|
|
virtual std::vector<int> PossibilitiesAsInt(std::map<String,String> Parameters); |
57 |
|
|
virtual void OnSetValue(int i) throw (Exception); |
58 |
|
|
static String Name(); |
59 |
|
|
}; |
60 |
senoner |
1485 |
|
61 |
senoner |
1500 |
/** |
62 |
senoner |
1485 |
* MIDI Port implementation for the MME MIDI input driver. |
63 |
|
|
*/ |
64 |
|
|
class MidiInputPortMme : public MidiInputPort { |
65 |
|
|
public: |
66 |
|
|
|
67 |
|
|
|
68 |
|
|
|
69 |
|
|
|
70 |
senoner |
1500 |
/** MIDI Port Parameter 'Port' |
71 |
senoner |
1485 |
* |
72 |
|
|
* MME MIDI ports |
73 |
|
|
* |
74 |
|
|
*/ |
75 |
|
|
class ParameterPort : public DeviceRuntimeParameterString { |
76 |
|
|
public: |
77 |
|
|
ParameterPort(MidiInputPortMme* pPort); |
78 |
|
|
virtual bool Fix(); |
79 |
|
|
virtual String Description(); |
80 |
|
|
virtual std::vector<String> PossibilitiesAsString(); |
81 |
|
|
virtual void OnSetValue(String s); |
82 |
|
|
private: |
83 |
|
|
MidiInputPortMme* pPort; |
84 |
|
|
|
85 |
|
|
}; |
86 |
|
|
|
87 |
|
|
|
88 |
|
|
protected: |
89 |
|
|
|
90 |
|
|
|
91 |
|
|
MidiInputPortMme(MidiInputDeviceMme* pDevice) throw (MidiInputException); |
92 |
|
|
~MidiInputPortMme(); |
93 |
|
|
void ConnectToMmeMidiSource(const char* MidiSource); |
94 |
|
|
void CloseMmeMidiPort(void); |
95 |
|
|
void MmeCallbackDispatcher(HMIDIIN handle, UINT uMsg, DWORD dwParam1, DWORD dwParam2); |
96 |
|
|
friend class MidiInputDeviceMme; |
97 |
|
|
private: |
98 |
|
|
MidiInputDeviceMme* pDevice; |
99 |
|
|
static void CALLBACK win32_midiin_callback(HMIDIIN handle, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2); |
100 |
|
|
HMIDIIN MidiInHandle; |
101 |
|
|
MIDIHDR midiHdr; |
102 |
|
|
bool MidiInOpened; |
103 |
|
|
int SysExOffset; |
104 |
|
|
char *SysExBuf; |
105 |
|
|
char *TmpSysExBuf; |
106 |
|
|
bool ExitFlag; |
107 |
|
|
bool FirstSysExBlock; |
108 |
|
|
bool SysExMsgComplete; |
109 |
|
|
}; |
110 |
|
|
|
111 |
|
|
MidiInputDeviceMme(std::map<String,DeviceCreationParameter*> Parameters, void* pSampler); |
112 |
|
|
~MidiInputDeviceMme(); |
113 |
|
|
|
114 |
|
|
// derived abstract methods from class 'MidiInputDevice' |
115 |
|
|
void Listen(); |
116 |
|
|
void StopListen(); |
117 |
|
|
virtual String Driver(); |
118 |
|
|
static String Name(); |
119 |
|
|
static String Description(); |
120 |
|
|
static String Version(); |
121 |
|
|
|
122 |
|
|
MidiInputPortMme* CreateMidiPort(); |
123 |
|
|
private: |
124 |
|
|
friend class MidiInputPortMme; |
125 |
|
|
friend class MidiInputPortMme::ParameterPort; |
126 |
|
|
}; |
127 |
|
|
} |
128 |
|
|
|
129 |
|
|
#endif // __LS_MIDIINPUTDEVICEMME_H__ |