1 |
/*************************************************************************** |
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 |
|
45 |
/** |
46 |
* MIDI Port implementation for the MME MIDI input driver. |
47 |
*/ |
48 |
class MidiInputPortMme : public MidiInputPort { |
49 |
public: |
50 |
|
51 |
|
52 |
|
53 |
|
54 |
/** MIDI Port Parameter 'Port' |
55 |
* |
56 |
* MME MIDI ports |
57 |
* |
58 |
*/ |
59 |
class ParameterPort : public DeviceRuntimeParameterString { |
60 |
public: |
61 |
ParameterPort(MidiInputPortMme* pPort); |
62 |
virtual bool Fix(); |
63 |
virtual String Description(); |
64 |
virtual std::vector<String> PossibilitiesAsString(); |
65 |
virtual void OnSetValue(String s); |
66 |
private: |
67 |
MidiInputPortMme* pPort; |
68 |
|
69 |
}; |
70 |
|
71 |
|
72 |
protected: |
73 |
|
74 |
|
75 |
MidiInputPortMme(MidiInputDeviceMme* pDevice) throw (MidiInputException); |
76 |
~MidiInputPortMme(); |
77 |
void ConnectToMmeMidiSource(const char* MidiSource); |
78 |
void CloseMmeMidiPort(void); |
79 |
void MmeCallbackDispatcher(HMIDIIN handle, UINT uMsg, DWORD dwParam1, DWORD dwParam2); |
80 |
friend class MidiInputDeviceMme; |
81 |
private: |
82 |
MidiInputDeviceMme* pDevice; |
83 |
static void CALLBACK win32_midiin_callback(HMIDIIN handle, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2); |
84 |
HMIDIIN MidiInHandle; |
85 |
MIDIHDR midiHdr; |
86 |
bool MidiInOpened; |
87 |
int SysExOffset; |
88 |
char *SysExBuf; |
89 |
char *TmpSysExBuf; |
90 |
bool ExitFlag; |
91 |
bool FirstSysExBlock; |
92 |
bool SysExMsgComplete; |
93 |
}; |
94 |
|
95 |
MidiInputDeviceMme(std::map<String,DeviceCreationParameter*> Parameters, void* pSampler); |
96 |
~MidiInputDeviceMme(); |
97 |
|
98 |
// derived abstract methods from class 'MidiInputDevice' |
99 |
void Listen(); |
100 |
void StopListen(); |
101 |
virtual String Driver(); |
102 |
static String Name(); |
103 |
static String Description(); |
104 |
static String Version(); |
105 |
|
106 |
MidiInputPortMme* CreateMidiPort(); |
107 |
private: |
108 |
friend class MidiInputPortMme; |
109 |
friend class MidiInputPortMme::ParameterPort; |
110 |
}; |
111 |
} |
112 |
|
113 |
#endif // __LS_MIDIINPUTDEVICEMME_H__ |