-
Notifications
You must be signed in to change notification settings - Fork 0
/
WaveCtrl.h
234 lines (208 loc) · 6.78 KB
/
WaveCtrl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
#if !defined(AFX_WAVECTRL_H__FA160AF1_5492_40A6_81D1_9CAD1516964D__INCLUDED_)
#define AFX_WAVECTRL_H__FA160AF1_5492_40A6_81D1_9CAD1516964D__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <mmsystem.h>
#define DEF_DEV_CLOSE 0
#define DEF_DEV_OPEN 1
#define DEF_CH_MONO 1
#define DEF_CH_STEREO 2
#define DEF_SAM_PHONE 8000
#define DEF_SAM_AM 11025
#define DEF_SAM_FM 22050
#define DEF_SAM_SYNTH 32000
#define DEF_SAM_CD 44100
#define DEF_RES_LOW 8
#define DEF_RES_HIGH 16
enum CHANNEL {CH_MONO = DEF_CH_MONO, CH_STEREO = DEF_CH_STEREO};
enum STATUS {DEV_CLOSE = DEF_DEV_CLOSE, DEV_OPEN = DEF_DEV_OPEN};
enum RESOLUTION {RES_LOW = DEF_RES_LOW,
RES_HIGH = DEF_RES_HIGH,
RES_USER };
enum SAMPLE {SAM_PHONE = DEF_SAM_PHONE,
SAM_AM = DEF_SAM_AM,
SAM_FM = DEF_SAM_FM,
SAM_SYNTH = DEF_SAM_SYNTH,
SAM_CD = DEF_SAM_CD,
SAM_USER };
enum HANDLETYPE {HANDLE_CALLBACK, HANDLE_WINDOW};
enum MEMERROR {ERROR_FREE, ERROR_PREPARE};
enum PROCPRIORITY {NORMAL = 0, REALTIME = 1, HIGH = 2};
typedef char WAVEBUFFER;
typedef char STRING[256];
// WaveCtrl.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CWaveIn window
class CWaveIn : public CWnd
{
// Construction
public:
CWaveIn();
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CWaveIn)
public:
protected:
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
//}}AFX_VIRTUAL
// Implementation
public:
WAVEFORMATEX GetWaveFormat();
void (*OnWaveData)(WAVEBUFFER *pBuffer, int Len, CWnd *pParent);
void (*OnWaveError)(MMRESULT ErrorCode, CWnd *pParent);
void (*OnMemError)(enum MEMERROR Err, CWnd *pParent);
void Create(CWnd* pParent);
void ResetDevice();
void SetWaveFormat(WAVEFORMATEX fmt);
void SetWaveFormat();
void SetUserSampleRate(int sam);
void SetUserResolution(int res);
void SetDeviceStatus(enum STATUS DevStatus);
void SetInitBufferNum(int num);
void SetDeviceID(int DevID);
void SetChannel(enum CHANNEL ch);
void SetSampleRate(enum SAMPLE sam);
void SetSampleResolution(enum RESOLUTION res);
void SetBufferSize(int size);
void SetHandleType(enum HANDLETYPE proc);
int GetBufferSize();
int GetBufferCount();
int GetDeviceID();
int GetDeviceCount();
int GetUserSampleRate();
int GetUserResolution();
enum PROCPRIORITY GetProcPriority();
enum RESOLUTION GetSampleResolution();
enum CHANNEL GetChannel();
enum STATUS GetDeviceStatus();
enum HANDLETYPE GetHandleType();
enum SAMPLE GetSampleRate();
bool GetCurrentPosition(MMTIME *pMMTime);
bool SetProcPriority(enum PROCPRIORITY priority);
char * GetDeviceErrorComment(MMRESULT ErrCode);
char * GetDeviceName(int DevID);
virtual ~CWaveIn();
// Generated message map functions
protected:
bool FreeHDR(WAVEHDR *pHdr,MMRESULT *ChkCode);
bool PrepareHDR(MMRESULT *ChkCode);
void ProcWaveError(MMRESULT ErrorCode);
void ProcWaveData(WAVEBUFFER *pBuffer, int Len);
void ProcMemError(enum MEMERROR Err);
void ProcCallBack(UINT uMsg, DWORD dwParam1, DWORD dwParam2);
//{{AFX_MSG(CWaveIn)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
int m_DeviceID;
int m_BufferSize;
int m_BufferCount;
int m_InitBufferNum;
int m_UserSampleRate;
int m_UserResolution;
bool m_AttemptClose;
enum HANDLETYPE m_HandleType;
enum STATUS m_DeviceStatus;
enum RESOLUTION m_Resolution;
enum SAMPLE m_Sample;
enum CHANNEL m_Channel;
enum PROCPRIORITY m_ProcPriority;
WAVEFORMATEX m_RecWaveFormat;
HWAVEIN m_hDevice;
CWnd *m_pParent;
DWORD m_OriginalPriority;
static void CALLBACK waveInProc(HWAVEIN hwi, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2);
};
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CWaveOut window
class CWaveOut : public CWnd
{
// Construction
public:
CWaveOut();
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CWaveOut)
protected:
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
//}}AFX_VIRTUAL
// Implementation
public:
WAVEFORMATEX GetWaveFormat();
void (*OnWaveDataDone)(WAVEBUFFER *pBuffer, int Len, CWnd *pParent);
void (*OnWaveError)(MMRESULT ErrorCode, CWnd *pParent);
void (*OnMemError)(enum MEMERROR Err, CWnd *pParent);
void Create(CWnd* pParent);
void SetWaveFormat();
void SetWaveFormat(WAVEFORMATEX fmt);
void SetDeviceStatus(enum STATUS DevStatus);
void SetSampleResolution(enum RESOLUTION res);
void SetSampleRate(enum SAMPLE sam);
void SetHandleType(enum HANDLETYPE proc);
void SetChannel(enum CHANNEL ch);
void SetDeviceID(int DevID);
void ResetDevice();
void SetUserSampleRate(int sam);
void SetUserResolution(int res);
bool SetHDR(WAVEBUFFER *pBuffer, int Len, MMRESULT *ChkCode);
bool GetCurrentPosition(MMTIME *pMMTime);
bool SetProcPriority(enum PROCPRIORITY priority);
enum PROCPRIORITY GetProcPriority();
enum RESOLUTION GetSampleResolution();
enum SAMPLE GetSampleRate();
enum HANDLETYPE GetHandleType();
enum STATUS GetDeviceStatus();
enum CHANNEL GetChannel();
int GetUserSampleRate();
int GetUserResolution();
int GetDeviceID();
int GetDeviceCount();
int GetBufferCount();
char * GetDeviceName(int DevID);
char * GetDeviceErrorComment(MMRESULT ErrCode);
virtual ~CWaveOut();
// Generated message map functions
protected:
void ProcessWaveDataDone(WAVEBUFFER *pBuffer, int Len);
bool FreeHDR(WAVEHDR *pHdr,MMRESULT *ChkCode);
void ProcWaveError(MMRESULT ErrorCode);
void ProcMemError(enum MEMERROR Err);
void ProcCallBack(UINT uMsg, DWORD dwParam1, DWORD dwParam2);
//{{AFX_MSG(CWaveOut)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
int m_UserResolution;
int m_UserSampleRate;
int m_DeviceID;
int m_BufferCount;
bool m_AttemptClose;
enum HANDLETYPE m_HandleType;
enum STATUS m_DeviceStatus;
enum RESOLUTION m_Resolution;
enum SAMPLE m_Sample;
enum CHANNEL m_Channel;
enum PROCPRIORITY m_ProcPriority;
WAVEFORMATEX m_PlayWaveFormat;
HWAVEOUT m_hDevice;
DWORD m_OriginalPriority;
CWnd *m_pParent;
static void CALLBACK waveOutProc(HWAVEOUT hwi, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2);
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_WAVECTRL_H__FA160AF1_5492_40A6_81D1_9CAD1516964D__INCLUDED_)