57 HMIXER h =
reinterpret_cast<HMIXER
>(m_hMix);
70 bool Open(UINT mxid = 0, HWND hCallbackWnd = NULL)
74 DWORD dwCallback =
reinterpret_cast<DWORD
>(hCallbackWnd);
75 DWORD dwFlag = MIXER_OBJECTF_MIXER;
76 if ( dwCallback != 0 )
78 dwFlag |= CALLBACK_WINDOW;
80 if ( m_res(::mixerOpen(&h, mxid, dwCallback, 0, dwFlag)) )
82 m_hMix =
reinterpret_cast<HMIXEROBJ
>(h);
84 m_mixerLine.cbStruct =
sizeof(MIXERLINE);
85 if ( m_res(::mixerGetLineInfo(m_hMix, &m_mixerLine, MIXER_GETLINEINFOF_DESTINATION | MIXER_OBJECTF_HMIXER)) )
101 return (m_hMix == NULL) ? NULL : m_mixerLine.Target.szPname;
110 return (m_hMix == NULL) ? 0 : m_mixerLine.cConnections;
164 return m_LineParam(_prm, line, 0,
true);
178 return m_LineParam(_prm, 0, componentType,
true);
207 bool SetLineVolume(
size_t line, DWORD left, DWORD right,
bool isMute =
false)
209 if ( line == INVALID_INDEX ) {
return SetMasterVolume(left, right, isMute); }
214 return m_LineParam(p, line, 0,
false);
234 return m_LineParam(p, 0, componentType,
false);
252 return ::mixerGetNumDevs();
266 bool m_LineParam(TParam& _prm,
size_t line, DWORD compType,
bool isGet)
const
268 if ( m_hMix == NULL )
270 m_res(MMSYSERR_ERROR);
273 MIXERLINE ml = { 0 };
274 ml.cbStruct =
sizeof(MIXERLINE);
275 DWORD info = MIXER_OBJECTF_HMIXER;
278 ml.dwComponentType = compType;
279 info |= MIXER_GETLINEINFOF_COMPONENTTYPE;
284 info |= MIXER_GETLINEINFOF_SOURCE;
286 if ( ! m_res(::mixerGetLineInfo(m_hMix, &ml, info)) )
290 MemCopy(_prm.szLineName, ml.szName, MIXER_LONG_NAME_CHARS);
291 _prm.componentType = ml.dwComponentType;
293 loop ( i, ml.cControls )
295 amc[i].cbStruct =
sizeof(MIXERCONTROL);
297 MIXERLINECONTROLS mlc = { 0 };
298 mlc.cbStruct =
sizeof(mlc);
299 mlc.dwLineID = ml.dwLineID;
300 mlc.cControls = ml.cControls;
301 mlc.cbmxctrl =
sizeof(MIXERCONTROL);
303 if ( ! m_res(::mixerGetLineControls(m_hMix, &mlc, MIXER_GETLINECONTROLSF_ALL | MIXER_OBJECTF_HMIXER)) )
307 loop ( i, ml.cControls )
309 MIXERCONTROL* P = &amc[i];
310 MIXERCONTROLDETAILS mcd = { 0 };
311 mcd.cMultipleItems = P->cMultipleItems;
312 if ( (P->fdwControl & MIXERCONTROL_CONTROLF_MULTIPLE) == 0 )
314 mcd.cMultipleItems = 0;
316 mcd.cChannels = ml.cChannels;
317 if ( (P->fdwControl & MIXERCONTROL_CONTROLF_UNIFORM) != 0 )
321 MIXERCONTROLDETAILS_BOOLEAN bn = { 0 };
322 MIXERCONTROLDETAILS_UNSIGNED us[2] = { 0 };
323 if ( P->dwControlType == MIXERCONTROL_CONTROLTYPE_VOLUME )
326 mcd.cbDetails =
sizeof(MIXERCONTROLDETAILS_UNSIGNED);
327 us[0].dwValue = _prm.left;
328 us[1].dwValue = _prm.right;
330 else if ( P->dwControlType == MIXERCONTROL_CONTROLTYPE_MUTE )
333 mcd.cbDetails =
sizeof(MIXERCONTROLDETAILS_BOOLEAN);
335 bn.fValue = _prm.isMute;
341 mcd.dwControlID = P->dwControlID;
342 mcd.cbStruct =
sizeof(mcd);
346 if ( ! m_res(::mixerGetControlDetails(m_hMix, &mcd, MIXER_GETCONTROLDETAILSF_VALUE | MIXER_OBJECTF_HMIXER)) )
350 if ( P->dwControlType == MIXERCONTROL_CONTROLTYPE_VOLUME )
352 MemCopy(_prm.szVolumeName, P->szName, MIXER_LONG_NAME_CHARS);
353 _prm.left = us[0].dwValue;
354 _prm.right = us[1].dwValue;
355 if ( ml.cChannels == 1 )
357 _prm.right = DWORD_MAX;
359 _prm.minimum = P->Bounds.dwMinimum;
360 _prm.maximum = P->Bounds.dwMaximum;
362 else if ( P->dwControlType == MIXERCONTROL_CONTROLTYPE_MUTE )
364 MemCopy(_prm.szMuteName, P->szName, MIXER_LONG_NAME_CHARS);
365 _prm.isMute = !! bn.fValue;
370 if ( ! m_res(::mixerSetControlDetails(m_hMix, &mcd, MIXER_SETCONTROLDETAILSF_VALUE | MIXER_OBJECTF_HMIXER)) )
379 bool m_res(MMRESULT r)
const
382 return r == MMSYSERR_NOERROR;
385 mutable MMRESULT m_result;
386 MIXERLINE m_mixerLine;
#define loop(VAR, CNT)
loop構文.
static size_t GetDevicesNumber(void)
[取得] デバイス数取得
size_t GetLinesNumber(void) const
[取得] ライン数取得
MMRESULT GetLastError(void) const
[取得] エラーコード取得.
bool GetLineVolume(TParam &_prm, size_t line) const
[取得] ラインボリューム取得.
CMixerVolume(void)
コンストラクタ
void Close(void)
[設定] クローズ
bool Open(UINT mxid=0, HWND hCallbackWnd=NULL)
[設定] オープン
bool GetMasterVolume(TParam &_prm) const
[取得] マスターボリューム取得.
bool SetMasterVolume(DWORD left, DWORD right, bool isMute=false)
[設定] マスターボリューム設定.
~CMixerVolume(void)
デストラクタ
LPCTSTR GetDeviceName(void)
[取得] デバイス名取得.
bool SetLineVolume(size_t line, DWORD left, DWORD right, bool isMute=false)
[設定] ラインボリューム設定.
bool SetComponentTypeVolume(DWORD componentType, DWORD left, DWORD right, bool isMute=false)
[設定] コンポーネントタイプボリューム設定.
bool GetComponentTypeVolume(TParam &_prm, DWORD componentType) const
[取得] コンポーネントタイプボリューム取得.
void Zero(V &value)
[設定] ゼロクリア.
void MemCopy(T *_pDst, const void *pSrc, size_t len)
[複製] メモリコピー
TCHAR szMuteName[MIXER_LONG_NAME_CHARS]
ミュート名
DWORD componentType
コンポーネントタイプ
TCHAR szVolumeName[MIXER_LONG_NAME_CHARS]
ボリューム名
TCHAR szLineName[MIXER_LONG_NAME_CHARS]
ライン名