#define STRICT
#include <windows.h>
#include "resource.h"
#include <basetsd.h>
#include <commdlg.h>
#include <mmreg.h>
#include <dxerr9.h>
#include <dsound.h>
#include <DSUtil.h>
#include <DXUtil.h>
#include <DSUtil.cpp>
#include <DXUtil.cpp>
#pragma comment(lib,"comctl32.lib")
#pragma comment(lib,"dxerr9.lib")
#pragma comment(lib,"winmm.lib")
#pragma comment(lib,"dsound.lib")
#pragma comment(lib,"dxguid.lib")
#pragma comment(lib,"odbc32.lib")
#pragma comment(lib,"odbccp32.lib")
#define NUM_PLAY_NOTIFICATIONS 16
CSoundManager * g_pSoundManager=new CSoundManager();
CStreamingSound * g_pStreamingSound = NULL;
CSound * g_pSound = NULL;
HANDLE g_hNotificationEvent=NULL;
BOOL g_bLooped=FALSE;
DWORD WINAPI NotificationProc(LPVOID lpParameter)
{
HWND hWnd = (HWND) lpParameter;
BOOL bDone=FALSE;
while(!bDone)
{
WaitForSingleObject(g_hNotificationEvent,INFINITE);
if(FAILED(g_pStreamingSound->HandleWaveStreamNotification(g_bLooped)))
bDone=TRUE;
}
return NULL;
}
INT_PTR CALLBACK DialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
UNREFERENCED_PARAMETER(lParam);
switch (message)
{
case WM_INITDIALOG:
return (INT_PTR)TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return (INT_PTR)TRUE;
}
break;
case WM_DESTROY:
//SAFE_DELETE(g_pStreamingSound);
SAFE_DELETE(g_pSound);
SAFE_DELETE(g_pSoundManager);
CloseHandle(g_hNotificationEvent);
break;
case WM_LBUTTONDOWN:
g_hNotificationEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
g_pSoundManager->Initialize(hDlg,DSSCL_PRIORITY);
g_pSoundManager->SetPrimaryBufferFormat(2,22050,16);
CreateThread(NULL,0,NotificationProc,hDlg,0,0);
LPTSTR szFileName=_T("D:\\Windows.wav");
CWaveFile WaveFileTest;
WaveFileTest.Open(szFileName,NULL,WAVEFILE_READ);
WAVEFORMATEX* pWFEx = WaveFileTest.GetFormat();
if(pWFEx->wFormatTag != WAVE_FORMAT_PCM)printf("不是PCM格式,无法应该特效\n");
WaveFileTest.Close();
//---------->>>>>关键
g_pSoundManager->Create(&g_pSound,szFileName,DSBCAPS_CTRLFX,GUID_NULL);
LPDIRECTSOUNDBUFFER pDSB = g_pSound->GetBuffer(0);
//LPDIRECTSOUNDBUFFER pDSB = g_pStreamingSound->GetBuffer(0);//使用动态缓冲区
LPDIRECTSOUNDBUFFER8 pDSB8;
pDSB->QueryInterface(IID_IDirectSoundBuffer8,(LPVOID*)&pDSB8);
/* 和声特技:不是指很多人合唱,而是指声音的重叠,即通过原声和回声的重叠,使得声音加宽,加厚。
DSEFFECTDESC DsEffectDesc;
ZeroMemory(&DsEffectDesc,sizeof(DSEFFECTDESC));
DsEffectDesc.dwSize = sizeof(DSEFFECTDESC);
DsEffectDesc.dwFlags = 0;
DsEffectDesc.guidDSFXClass = GUID_DSFX_STANDARD_CHORUS;
DWORD dwResults;
pDSB8->SetFX(1,&DsEffectDesc,&dwResults);
LPDIRECTSOUNDFXCHORUS pDirectSoundFxChorus = NULL;//和声特技接口
pDSB8->GetObjectInPath(DsEffectDesc.guidDSFXClass,0,
IID_IDirectSoundFXChorus,
(LPVOID*)&pDirectSoundFxChorus);
DSFXChorus DsFxChorus;
DsFxChorus.fWetDryMix = 50.0f;//干湿混合//湿信号(处理过的信号)对干信号(未处理的信号)的比率
//范围:[DSFXCHORUS_WETDRYMIX_MIN - DSFXCHORUS_WETDRYMIX_MAX] 即 [0.0f - 100.0f]
DsFxChorus.fDepth = 50.0f;//深度//低频振荡器调整延迟的百分比
//范围:[DSFXCHORUS_DEPTH_MIN - DSFXCHORUS_DEPTH_MAX] 即 [0.0f - 100.0f]
DsFxChorus.fFeedback = -50.0f;//反馈//输出信号反馈到输入信号的百分比
//范围:[DSFXCHORUS_FEEDBACK_MIN - DSFXCHORUS_FEEDBACK_MAX] 即 [-99.0f - 99.0f]
DsFxChorus.fFrequency = 5.0f;//频率//低频振荡器的频率
//范围:[DSFXCHORUS_FREQUENCY_MIN - DSFXCHORUS_FREQUENCY_MAX] 即 [0.0f - 10.0f]
DsFxChorus.fDelay = 10.0f;//延迟//播放之前的延迟,以毫秒作单位
//范围:[DSFXCHORUS_DELAY_MIN - DSFXCHORUS_DELAY_MAX] 即 [0.0f - 20.0f]
DsFxChorus.lWaveform = DSFXCHORUS_WAVE_TRIANGLE;//波形//低频振荡器的波形
//DSFXCHORUS_WAVE_TRIANGLE:三角回声;
//DSFXCHORUS_WAVE_SIN:正弦回声;
DsFxChorus.lPhase = DSFXCHORUS_PHASE_NEG_180;//相位//左右低频振荡器之间的微分相位
//DSFXCHORUS_PHASE_NEG_180 -180度
//DSFXCHORUS_PHASE_NEG_90 -90度
//DSFXCHORUS_PHASE_ZERO 0度
//DSFXCHORUS_PHASE_90 90度
//DSFXCHORUS_PHASE_180 180度
pDirectSoundFxChorus->SetAllParameters(&DsFxChorus);
SAFE_RELEASE(pDirectSoundFxChorus);
*/
/* 压限特技:是针对声音不同部分的音量进行增减,可以对某段音频中音量低于某一限度的部分进行平滑的音量提升(其余部分不变);对音量高于某一限度的部分进行平滑的音量衰减(其余部分不变),或二者同时作用,简单说,就是平衡音量
DSEFFECTDESC DsEffectDesc;
ZeroMemory(&DsEffectDesc,sizeof(DSEFFECTDESC));
DsEffectDesc.dwSize = sizeof(DSEFFECTDESC);
DsEffectDesc.dwFlags = 0;
DsEffectDesc.guidDSFXClass = GUID_DSFX_STANDARD_COMPRESSOR;
DWORD dwResults;
pDSB8->SetFX(1,&DsEffectDesc,&dwResults);
LPDIRECTSOUNDFXCOMPRESSOR pDirectSoundFxCompressor = NULL;//压限特技接口
pDSB8->GetObjectInPath(DsEffectDesc.guidDSFXClass,0,
IID_IDirectSoundFXCompressor,
(LPVOID*)&pDirectSoundFxCompressor);
DSFXCompressor DsFxCompressor;
DsFxCompressor.fGain = 20.0f;//压限后输出信号的强度,缺省值是 0 db
//范围:[DSFXCOMPRESSOR_GAIN_MIN - DSFXCOMPRESSOR_GAIN_MAX] 即 [-60.0f - 60.0f]
DsFxCompressor.fGain = 20.0f;//压限达到最大值的时间,缺省是 10 ms
//范围:[DSFXCOMPRESSOR_ATTACK_MIN - DSFXCOMPRESSOR_ATTACK_MAX] 即 [0.01f - 500.0f]
DsFxCompressor.fRelease = 1000.0f;//输入小于fThreshold后,压缩停止的时间,缺省是200ms
//范围:[DSFXCOMPRESSOR_RELEASE_MIN - DSFXCOMPRESSOR_RELEASE_MAX] 即 [50.0f - 3000.0f]
DsFxCompressor.fThreshold = 1000.0f;//压缩开始的临界点的db值,缺省是-20db
//范围:[DSFXCOMPRESSOR_THRESHOLD_MIN - DSFXCOMPRESSOR_THRESHOLD_MAX] 即 [-60.0f - 0.0f]
DsFxCompressor.fRatio = 1000.0f;//压缩的比率,缺省是3,即3:1
//范围:[DSFXCOMPRESSOR_RATIO_MIN - DSFXCOMPRESSOR_RATIO_MAX] 即 [1.0f - 100.0f]
DsFxCompressor.fPredelay = 2.0f;//lThreshold达到临界点,Attackphase开始前的延迟时间
//范围:[DSFXCOMPRESSOR_PREDELAY_MIN - DSFXCOMPRESSOR_PREDELAY_MAX] 即 [0.0f - 4.0f]
pDirectSoundFxCompressor->SetAllParameters(&DsFxCompressor);
SAFE_RELEASE(pDirectSoundFxCompressor);
*/
/* 失真特技
DSEFFECTDESC DsEffectDesc;
ZeroMemory(&DsEffectDesc,sizeof(DSEFFECTDESC));
DsEffectDesc.dwSize = sizeof(DSEFFECTDESC);
DsEffectDesc.dwFlags = 0;
DsEffectDesc.guidDSFXClass = GUID_DSFX_STANDARD_DISTORTION;
DWORD dwResults;
pDSB8->SetFX(1,&DsEffectDesc,&dwResults);
LPDIRECTSOUNDFXDISTORTION pDirectSoundFxDistortion = NULL;
pDSB8->GetObjectInPath(DsEffectDesc.guidDSFXClass,0,
IID_IDirectSoundFXDistortion,
(LPVOID*)&pDirectSoundFxDistortion);
DSFXDistortion DsFxDistortion;
DsFxDistortion.fGain = -30.0f;//信号失真后的音量的强度变化,缺省是比原来衰减18db。
//范围:[DSFXDISTORTION_GAIN_MIN - DSFXDISTORTION_GAIN_MAX] 即 [-60.0f - 0.0f]
DsFxDistortion.fEdge = -30.0f;//失真的强度,用百分比来表示,缺省值是15
//范围:[DSFXDISTORTION_EDGE_MIN - DSFXDISTORTION_EDGE_MAX] 即 [0.0f - 100.0f]
DsFxDistortion.fPostEQCenterFrequency = 2000.0f;//信号叠加的中心频率,缺省是2400hz
//范围:[DSFXDISTORTION_POSTEQCENTERFREQUENCY_MIN - DSFXDISTORTION_POSTEQCENTERFREQUENCY_MAX] 即 [100.0f - 8000.0f]
DsFxDistortion.fPostEQBandwidth = 2000.0f;//信号的带宽,缺省是2400hz
//范围:[DSFXDISTORTION_POSTEQBANDWIDTH_MIN - DSFXDISTORTION_POSTEQBANDWIDTH_MAX] 即 [100.0f - 8000.0f]
DsFxDistortion.fPreLowpassCutoff = 8000.0f;//高通滤波的最高值,缺省是8000hz
//范围:[DSFXDISTORTION_PRELOWPASSCUTOFF_MIN - DSFXDISTORTION_PRELOWPASSCUTOFF_MAX] 即 [100.0f - 8000.0f]
pDirectSoundFxDistortion->SetAllParameters(&DsFxDistortion);
SAFE_RELEASE(pDirectSoundFxDistortion);
*/
/* 回声特技:模拟声音被远处的平面反射回来的效果
DSEFFECTDESC DsEffectDesc;
ZeroMemory(&DsEffectDesc,sizeof(DSEFFECTDESC));
DsEffectDesc.dwSize = sizeof(DSEFFECTDESC);
DsEffectDesc.dwFlags = 0;
DsEffectDesc.guidDSFXClass = GUID_DSFX_STANDARD_ECHO;
DWORD dwResults;
pDSB8->SetFX(1,&DsEffectDesc,&dwResults);
LPDIRECTSOUNDFXECHO pDirectSoundFxEcho = NULL;//回声特技接口
pDSB8->GetObjectInPath(DsEffectDesc.guidDSFXClass,0,
IID_IDirectSoundFXEcho,
(LPVOID*)&pDirectSoundFxEcho);
DSFXEcho DsFxEcho;
DsFxEcho.fWetDryMix = 50.0f;//处理过的信号和没有处理的信号的比率,缺省值是50
//范围:[DSFXECHO_WETDRYMIX_MIN - DSFXECHO_WETDRYMIX_MAX] 即 [0.0f - 100.0f]
DsFxEcho.fFeedback = 50.0f;//输出信号反馈到输入信号的百分比,缺省值是50
//范围:[DSFXECHO_FEEDBACK_MIN - DSFXECHO_FEEDBACK_MAX] 即 [0.0f - 100.0f]
DsFxEcho.fLeftDelay = 500.0f;//左声道延迟的时间,缺省值500ms
//范围:[DSFXECHO_LEFTDELAY_MIN - DSFXECHO_LEFTDELAY_MAX] 即 [1.0f - 2000.0f]
DsFxEcho.fRightDelay = 500.0f;//右声道延迟的时间,缺省值500ms
//范围:[DSFXECHO_RIGHTDELAY_MIN - DSFXECHO_RIGHTDELAY_MAX] 即 [1.0f - 2000.0f]
DsFxEcho.lPanDelay = 0.0f;//是否左右声道交替延迟,缺省值0,左右声道不交替
//范围:[DSFXECHO_PANDELAY_MIN - DSFXECHO_PANDELAY_MAX] 即 [0.0f - 100.0f]
pDirectSoundFxEcho->SetAllParameters(&DsFxEcho);
SAFE_RELEASE(pDirectSoundFxEcho);
*/
/* 混响特技:简单说就是声音余韵,音源在空间反射出来的声音。适当设置混响,可以更真实、更有现场感的再现声音源,也可以起到修饰、美化的作用。表现宽阔的,传声真实的效果。
DSEFFECTDESC DsEffectDesc;
ZeroMemory(&DsEffectDesc,sizeof(DSEFFECTDESC));
DsEffectDesc.dwSize = sizeof(DSEFFECTDESC);
DsEffectDesc.dwFlags = 0;
DsEffectDesc.guidDSFXClass = GUID_DSFX_WAVES_REVERB;
DWORD dwResults;
pDSB8->SetFX(1,&DsEffectDesc,&dwResults);
LPDIRECTSOUNDFXWAVESREVERB pDirectSoundFxWavesErverb = NULL;//混响特技接口
pDSB8->GetObjectInPath(DsEffectDesc.guidDSFXClass,0,
IID_IDirectSoundFXWavesReverb,
(LPVOID*)&pDirectSoundFxWavesErverb);
DSFXWavesReverb DsFxWavesReverb;
DsFxWavesReverb.fInGain = -45.0f;//输入信号的音量的大小,即db值,缺省值是0db
//范围:[DSFX_WAVESREVERB_INGAIN_MIN - DSFX_WAVESREVERB_INGAIN_MAX] 即 [-96.0f - 0.0f]
DsFxWavesReverb.fReverbMix = -45.0f;//回响混合音量强度大小,用db值来表示,缺省值是0db。
//范围:[DSFX_WAVESREVERB_REVERBMIX_MIN - DSFX_WAVESREVERB_REVERBMIX_MAX] 即 [-96.0f - 0.0f]
DsFxWavesReverb.fReverbTime = 1000.0f;//回响的时间,单位是ms,缺省值是1000.0fms
//范围:[DSFX_WAVESREVERB_REVERBTIME_MIN - DSFX_WAVESREVERB_REVERBTIME_MAX] 即 [0.001f - 3000.0f]
DsFxWavesReverb.fInGain = 0.500f;//高频回响所占时间的比率,缺省值0.001f。TRatio;
//范围:[DSFX_WAVESREVERB_HIGHFREQRTRATIO_MIN - DSFX_WAVESREVERB_HIGHFREQRTRATIO_MAX] 即 [0.001f - 0.999f]
pDirectSoundFxWavesErverb->SetAllParameters(&DsFxWavesReverb);
SAFE_RELEASE(pDirectSoundFxWavesErverb);
*/
/* 波浪特技:一般翻译为波浪特技,用于设置变调效果,通过拷贝失调的声音,或者把某个频率点改变,调节声音分离的时间、音调深度。可以用来产生颤动、急促的声音。
DSEFFECTDESC DsEffectDesc;
ZeroMemory(&DsEffectDesc,sizeof(DSEFFECTDESC));
DsEffectDesc.dwSize = sizeof(DSEFFECTDESC);
DsEffectDesc.dwFlags = 0;
DsEffectDesc.guidDSFXClass = GUID_DSFX_STANDARD_FLANGER;
DWORD dwResults;
pDSB8->SetFX(1,&DsEffectDesc,&dwResults);
LPDIRECTSOUNDFXFLANGER pDirectSoundFxFlanger = NULL;//波浪特技接口
pDSB8->GetObjectInPath(DsEffectDesc.guidDSFXClass,0,
IID_IDirectSoundFXFlanger,
(LPVOID*)&pDirectSoundFxFlanger);
DSFXFlanger DsFxFlanger;
DsFxFlanger.fWetDryMix = 50.0f;//处理过的信号和没有处理的信号的比率,缺省值是50
//范围:[DSFXFLANGER_WETDRYMIX_MIN - DSFXFLANGER_WETDRYMIX_MAX] 即 [0.0f - 100.0f]
DsFxFlanger.fDepth = 50.0f;//低频振荡器调整延迟时间的百分比,缺省值是100
//范围:[DSFXFLANGER_DEPTH_MIN - DSFXFLANGER_DEPTH_MAX] 即 [0.0f - 100.0f]
DsFxFlanger.fFeedback = -50.0f;//输出信号反馈到输入信号的百分比,缺省值是-50
//范围:[DSFXFLANGER_FEEDBACK_MIN - DSFXFLANGER_FEEDBACK_MAX] 即 [-99.0f - 99.0f]
DsFxFlanger.fFrequency = 0.5f;//低频振荡器的频率,缺省值是0.25
//范围:[DSFXFLANGER_FREQUENCY_MIN - DSFXFLANGER_FREQUENCY_MAX] 即 [0.0f - 10.0f]
DsFxFlanger.fDelay = 2.0f;//播放之前的延迟,以毫秒作单位,缺省值是2ms
//范围:[DSFXFLANGER_DELAY_MIN - DSFXFLANGER_DELAY_MAX] 即 [0.0f - 4.0f]
DsFxFlanger.lWaveform = DSFXFLANGER_WAVE_TRIANGLE;//低频振荡器的波形,分为三角形,和正弦波形
//取值:[DSFXFLANGER_WAVE_TRIANGLE ,DSFXFLANGER_WAVE_SIN] 即 [三角波,正弦波]
DsFxFlanger.lPhase = DSFXFLANGER_PHASE_ZERO;//相位
//取值:[DSFXFLANGER_PHASE_NEG_180 , //-180度
// DSFXFLANGER_PHASE_NEG_90 , //-90度
// DSFXFLANGER_PHASE_ZERO , //0度
// DSFXFLANGER_PHASE_90 , //90度
// DSFXFLANGER_PHASE_180 ] //180度
pDirectSoundFxFlanger->SetAllParameters(&DsFxFlanger);
SAFE_RELEASE(pDirectSoundFxFlanger);
*/
/* 咕噜特技[机械化]:咕噜效果处理。一种可以试音源产生咕噜声的调幅处理模式。
DSEFFECTDESC DsEffectDesc;
ZeroMemory(&DsEffectDesc,sizeof(DSEFFECTDESC));
DsEffectDesc.dwSize = sizeof(DSEFFECTDESC);
DsEffectDesc.dwFlags = 0;
DsEffectDesc.guidDSFXClass = GUID_DSFX_STANDARD_GARGLE;
DWORD dwResults;
pDSB8->SetFX(1,&DsEffectDesc,&dwResults);
LPDIRECTSOUNDFXGARGLE pDirectSoundFxGargle = NULL;//咕噜特技接口
pDSB8->GetObjectInPath(DsEffectDesc.guidDSFXClass,0,
IID_IDirectSoundFXGargle,
(LPVOID*)&pDirectSoundFxGargle);
DSFXGargle DsFxGargle;
DsFxGargle.dwRateHz = 500;//调制波频率,缺省值是20hz
//范围:[DSFXGARGLE_RATEHZ_MIN - DSFXGARGLE_RATEHZ_MAX] 即 [1 - 1000]
DsFxGargle.dwWaveShape = DSFXGARGLE_WAVE_TRIANGLE;
//取值:[DSFXGARGLE_WAVE_SQUARE ,DSFXGARGLE_WAVE_TRIANGLE] 即 [方波,三角波]
pDirectSoundFxGargle->SetAllParameters(&DsFxGargle);
SAFE_RELEASE(pDirectSoundFxGargle);
*/
/* 参数平衡特技:参数平衡,用于为音频设置参数均衡器。强化或衰减指定的频率。对于增强音乐的效果特别有效。
DSEFFECTDESC DsEffectDesc;
ZeroMemory(&DsEffectDesc,sizeof(DSEFFECTDESC));
DsEffectDesc.dwSize = sizeof(DSEFFECTDESC);
DsEffectDesc.dwFlags = 0;
DsEffectDesc.guidDSFXClass = GUID_DSFX_STANDARD_PARAMEQ;
DWORD dwResults;
pDSB8->SetFX(1,&DsEffectDesc,&dwResults);
LPDIRECTSOUNDFXPARAMEQ pDirectSoundFxParamEq = NULL;//参数平衡特技接口
pDSB8->GetObjectInPath(DsEffectDesc.guidDSFXClass,0,
IID_IDirectSoundFXParamEq,
(LPVOID*)&pDirectSoundFxParamEq);
DSFXParamEq DsFxParamEq;
DsFxParamEq.fCenter = 8000.0f;//中心的频率,缺省值是8000hz
//范围:[DSFXPARAMEQ_CENTER_MIN - DSFXPARAMEQ_CENTER_MAX] 即 [80.0f - 16000.0f]
DsFxParamEq.fBandwidth = 12.0f;//音的带宽,以半音为单位,缺省值是12
//范围:[DSFXPARAMEQ_BANDWIDTH_MIN - DSFXPARAMEQ_BANDWIDTH_MAX] 即 [1.0f - 36.0f]
DsFxParamEq.fGain = 0.0f;//音频的音量,缺省值是0db
//范围:[DSFXPARAMEQ_GAIN_MIN - DSFXPARAMEQ_GAIN_MAX] 即 [-15.0f - 15.0f]
pDirectSoundFxParamEq->SetAllParameters(&DsFxParamEq);
SAFE_RELEASE(pDirectSoundFxParamEq);
*/
/* 多个特效同时使用
const int iFxCount = 3;
DSEFFECTDESC pDsEffectDesc[iFxCount];
ZeroMemory(pDsEffectDesc,sizeof(DSEFFECTDESC) * iFxCount);
pDsEffectDesc[0].dwSize = sizeof(DSEFFECTDESC);
pDsEffectDesc[0].dwFlags = 0;
pDsEffectDesc[0].guidDSFXClass = GUID_DSFX_STANDARD_ECHO;
pDsEffectDesc[1].dwSize = sizeof(DSEFFECTDESC);
pDsEffectDesc[1].dwFlags = 0;
pDsEffectDesc[1].guidDSFXClass = GUID_DSFX_STANDARD_GARGLE;
pDsEffectDesc[2].dwSize = sizeof(DSEFFECTDESC);
pDsEffectDesc[2].dwFlags = 0;
pDsEffectDesc[2].guidDSFXClass = GUID_DSFX_STANDARD_FLANGER;
DWORD pdwResults[iFxCount];
pDSB8->SetFX(iFxCount,pDsEffectDesc,pdwResults);
//第三个特技使用默认值
LPDIRECTSOUNDFXECHO pDirectSoundFxEcho = NULL;//回声特技接口
pDSB8->GetObjectInPath(pDsEffectDesc[0].guidDSFXClass,0,
IID_IDirectSoundFXEcho,
(LPVOID*)&pDirectSoundFxEcho);
DSFXEcho DsFxEcho;
DsFxEcho.fWetDryMix = 50.0f;
DsFxEcho.fFeedback = 50.0f;
DsFxEcho.fLeftDelay = 500.0f;
DsFxEcho.fRightDelay = 500.0f;
DsFxEcho.lPanDelay = 0.0f;
pDirectSoundFxEcho->SetAllParameters(&DsFxEcho);
SAFE_RELEASE(pDirectSoundFxEcho);
LPDIRECTSOUNDFXGARGLE pDirectSoundFxGargle = NULL;//咕噜特技接口
pDSB8->GetObjectInPath(pDsEffectDesc[1].guidDSFXClass,0,
IID_IDirectSoundFXGargle,
(LPVOID*)&pDirectSoundFxGargle);
DSFXGargle DsFxGargle;
DsFxGargle.dwRateHz = 1000;
DsFxGargle.dwWaveShape = DSFXGARGLE_WAVE_TRIANGLE;
pDirectSoundFxGargle->SetAllParameters(&DsFxGargle);
SAFE_RELEASE(pDirectSoundFxGargle);
*/
SAFE_RELEASE(pDSB8);
//<<<<<<<----------
g_pSound->Play();
break;
}
return (INT_PTR)FALSE;
}
int _tmain(int argc, _TCHAR* argv[])
{
CoInitialize(NULL);
DialogBox(NULL,MAKEINTRESOURCE(IDD_DIALOGDEMO),NULL,DialogProc);
CoUninitialize();
return 0;
}
#include <windows.h>
#include "resource.h"
#include <basetsd.h>
#include <commdlg.h>
#include <mmreg.h>
#include <dxerr9.h>
#include <dsound.h>
#include <DSUtil.h>
#include <DXUtil.h>
#include <DSUtil.cpp>
#include <DXUtil.cpp>
#pragma comment(lib,"comctl32.lib")
#pragma comment(lib,"dxerr9.lib")
#pragma comment(lib,"winmm.lib")
#pragma comment(lib,"dsound.lib")
#pragma comment(lib,"dxguid.lib")
#pragma comment(lib,"odbc32.lib")
#pragma comment(lib,"odbccp32.lib")
#define NUM_PLAY_NOTIFICATIONS 16
CSoundManager * g_pSoundManager=new CSoundManager();
CStreamingSound * g_pStreamingSound = NULL;
CSound * g_pSound = NULL;
HANDLE g_hNotificationEvent=NULL;
BOOL g_bLooped=FALSE;
DWORD WINAPI NotificationProc(LPVOID lpParameter)
{
HWND hWnd = (HWND) lpParameter;
BOOL bDone=FALSE;
while(!bDone)
{
WaitForSingleObject(g_hNotificationEvent,INFINITE);
if(FAILED(g_pStreamingSound->HandleWaveStreamNotification(g_bLooped)))
bDone=TRUE;
}
return NULL;
}
INT_PTR CALLBACK DialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
UNREFERENCED_PARAMETER(lParam);
switch (message)
{
case WM_INITDIALOG:
return (INT_PTR)TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return (INT_PTR)TRUE;
}
break;
case WM_DESTROY:
//SAFE_DELETE(g_pStreamingSound);
SAFE_DELETE(g_pSound);
SAFE_DELETE(g_pSoundManager);
CloseHandle(g_hNotificationEvent);
break;
case WM_LBUTTONDOWN:
g_hNotificationEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
g_pSoundManager->Initialize(hDlg,DSSCL_PRIORITY);
g_pSoundManager->SetPrimaryBufferFormat(2,22050,16);
CreateThread(NULL,0,NotificationProc,hDlg,0,0);
LPTSTR szFileName=_T("D:\\Windows.wav");
CWaveFile WaveFileTest;
WaveFileTest.Open(szFileName,NULL,WAVEFILE_READ);
WAVEFORMATEX* pWFEx = WaveFileTest.GetFormat();
if(pWFEx->wFormatTag != WAVE_FORMAT_PCM)printf("不是PCM格式,无法应该特效\n");
WaveFileTest.Close();
//---------->>>>>关键
g_pSoundManager->Create(&g_pSound,szFileName,DSBCAPS_CTRLFX,GUID_NULL);
LPDIRECTSOUNDBUFFER pDSB = g_pSound->GetBuffer(0);
//LPDIRECTSOUNDBUFFER pDSB = g_pStreamingSound->GetBuffer(0);//使用动态缓冲区
LPDIRECTSOUNDBUFFER8 pDSB8;
pDSB->QueryInterface(IID_IDirectSoundBuffer8,(LPVOID*)&pDSB8);
/* 和声特技:不是指很多人合唱,而是指声音的重叠,即通过原声和回声的重叠,使得声音加宽,加厚。
DSEFFECTDESC DsEffectDesc;
ZeroMemory(&DsEffectDesc,sizeof(DSEFFECTDESC));
DsEffectDesc.dwSize = sizeof(DSEFFECTDESC);
DsEffectDesc.dwFlags = 0;
DsEffectDesc.guidDSFXClass = GUID_DSFX_STANDARD_CHORUS;
DWORD dwResults;
pDSB8->SetFX(1,&DsEffectDesc,&dwResults);
LPDIRECTSOUNDFXCHORUS pDirectSoundFxChorus = NULL;//和声特技接口
pDSB8->GetObjectInPath(DsEffectDesc.guidDSFXClass,0,
IID_IDirectSoundFXChorus,
(LPVOID*)&pDirectSoundFxChorus);
DSFXChorus DsFxChorus;
DsFxChorus.fWetDryMix = 50.0f;//干湿混合//湿信号(处理过的信号)对干信号(未处理的信号)的比率
//范围:[DSFXCHORUS_WETDRYMIX_MIN - DSFXCHORUS_WETDRYMIX_MAX] 即 [0.0f - 100.0f]
DsFxChorus.fDepth = 50.0f;//深度//低频振荡器调整延迟的百分比
//范围:[DSFXCHORUS_DEPTH_MIN - DSFXCHORUS_DEPTH_MAX] 即 [0.0f - 100.0f]
DsFxChorus.fFeedback = -50.0f;//反馈//输出信号反馈到输入信号的百分比
//范围:[DSFXCHORUS_FEEDBACK_MIN - DSFXCHORUS_FEEDBACK_MAX] 即 [-99.0f - 99.0f]
DsFxChorus.fFrequency = 5.0f;//频率//低频振荡器的频率
//范围:[DSFXCHORUS_FREQUENCY_MIN - DSFXCHORUS_FREQUENCY_MAX] 即 [0.0f - 10.0f]
DsFxChorus.fDelay = 10.0f;//延迟//播放之前的延迟,以毫秒作单位
//范围:[DSFXCHORUS_DELAY_MIN - DSFXCHORUS_DELAY_MAX] 即 [0.0f - 20.0f]
DsFxChorus.lWaveform = DSFXCHORUS_WAVE_TRIANGLE;//波形//低频振荡器的波形
//DSFXCHORUS_WAVE_TRIANGLE:三角回声;
//DSFXCHORUS_WAVE_SIN:正弦回声;
DsFxChorus.lPhase = DSFXCHORUS_PHASE_NEG_180;//相位//左右低频振荡器之间的微分相位
//DSFXCHORUS_PHASE_NEG_180 -180度
//DSFXCHORUS_PHASE_NEG_90 -90度
//DSFXCHORUS_PHASE_ZERO 0度
//DSFXCHORUS_PHASE_90 90度
//DSFXCHORUS_PHASE_180 180度
pDirectSoundFxChorus->SetAllParameters(&DsFxChorus);
SAFE_RELEASE(pDirectSoundFxChorus);
*/
/* 压限特技:是针对声音不同部分的音量进行增减,可以对某段音频中音量低于某一限度的部分进行平滑的音量提升(其余部分不变);对音量高于某一限度的部分进行平滑的音量衰减(其余部分不变),或二者同时作用,简单说,就是平衡音量
DSEFFECTDESC DsEffectDesc;
ZeroMemory(&DsEffectDesc,sizeof(DSEFFECTDESC));
DsEffectDesc.dwSize = sizeof(DSEFFECTDESC);
DsEffectDesc.dwFlags = 0;
DsEffectDesc.guidDSFXClass = GUID_DSFX_STANDARD_COMPRESSOR;
DWORD dwResults;
pDSB8->SetFX(1,&DsEffectDesc,&dwResults);
LPDIRECTSOUNDFXCOMPRESSOR pDirectSoundFxCompressor = NULL;//压限特技接口
pDSB8->GetObjectInPath(DsEffectDesc.guidDSFXClass,0,
IID_IDirectSoundFXCompressor,
(LPVOID*)&pDirectSoundFxCompressor);
DSFXCompressor DsFxCompressor;
DsFxCompressor.fGain = 20.0f;//压限后输出信号的强度,缺省值是 0 db
//范围:[DSFXCOMPRESSOR_GAIN_MIN - DSFXCOMPRESSOR_GAIN_MAX] 即 [-60.0f - 60.0f]
DsFxCompressor.fGain = 20.0f;//压限达到最大值的时间,缺省是 10 ms
//范围:[DSFXCOMPRESSOR_ATTACK_MIN - DSFXCOMPRESSOR_ATTACK_MAX] 即 [0.01f - 500.0f]
DsFxCompressor.fRelease = 1000.0f;//输入小于fThreshold后,压缩停止的时间,缺省是200ms
//范围:[DSFXCOMPRESSOR_RELEASE_MIN - DSFXCOMPRESSOR_RELEASE_MAX] 即 [50.0f - 3000.0f]
DsFxCompressor.fThreshold = 1000.0f;//压缩开始的临界点的db值,缺省是-20db
//范围:[DSFXCOMPRESSOR_THRESHOLD_MIN - DSFXCOMPRESSOR_THRESHOLD_MAX] 即 [-60.0f - 0.0f]
DsFxCompressor.fRatio = 1000.0f;//压缩的比率,缺省是3,即3:1
//范围:[DSFXCOMPRESSOR_RATIO_MIN - DSFXCOMPRESSOR_RATIO_MAX] 即 [1.0f - 100.0f]
DsFxCompressor.fPredelay = 2.0f;//lThreshold达到临界点,Attackphase开始前的延迟时间
//范围:[DSFXCOMPRESSOR_PREDELAY_MIN - DSFXCOMPRESSOR_PREDELAY_MAX] 即 [0.0f - 4.0f]
pDirectSoundFxCompressor->SetAllParameters(&DsFxCompressor);
SAFE_RELEASE(pDirectSoundFxCompressor);
*/
/* 失真特技
DSEFFECTDESC DsEffectDesc;
ZeroMemory(&DsEffectDesc,sizeof(DSEFFECTDESC));
DsEffectDesc.dwSize = sizeof(DSEFFECTDESC);
DsEffectDesc.dwFlags = 0;
DsEffectDesc.guidDSFXClass = GUID_DSFX_STANDARD_DISTORTION;
DWORD dwResults;
pDSB8->SetFX(1,&DsEffectDesc,&dwResults);
LPDIRECTSOUNDFXDISTORTION pDirectSoundFxDistortion = NULL;
pDSB8->GetObjectInPath(DsEffectDesc.guidDSFXClass,0,
IID_IDirectSoundFXDistortion,
(LPVOID*)&pDirectSoundFxDistortion);
DSFXDistortion DsFxDistortion;
DsFxDistortion.fGain = -30.0f;//信号失真后的音量的强度变化,缺省是比原来衰减18db。
//范围:[DSFXDISTORTION_GAIN_MIN - DSFXDISTORTION_GAIN_MAX] 即 [-60.0f - 0.0f]
DsFxDistortion.fEdge = -30.0f;//失真的强度,用百分比来表示,缺省值是15
//范围:[DSFXDISTORTION_EDGE_MIN - DSFXDISTORTION_EDGE_MAX] 即 [0.0f - 100.0f]
DsFxDistortion.fPostEQCenterFrequency = 2000.0f;//信号叠加的中心频率,缺省是2400hz
//范围:[DSFXDISTORTION_POSTEQCENTERFREQUENCY_MIN - DSFXDISTORTION_POSTEQCENTERFREQUENCY_MAX] 即 [100.0f - 8000.0f]
DsFxDistortion.fPostEQBandwidth = 2000.0f;//信号的带宽,缺省是2400hz
//范围:[DSFXDISTORTION_POSTEQBANDWIDTH_MIN - DSFXDISTORTION_POSTEQBANDWIDTH_MAX] 即 [100.0f - 8000.0f]
DsFxDistortion.fPreLowpassCutoff = 8000.0f;//高通滤波的最高值,缺省是8000hz
//范围:[DSFXDISTORTION_PRELOWPASSCUTOFF_MIN - DSFXDISTORTION_PRELOWPASSCUTOFF_MAX] 即 [100.0f - 8000.0f]
pDirectSoundFxDistortion->SetAllParameters(&DsFxDistortion);
SAFE_RELEASE(pDirectSoundFxDistortion);
*/
/* 回声特技:模拟声音被远处的平面反射回来的效果
DSEFFECTDESC DsEffectDesc;
ZeroMemory(&DsEffectDesc,sizeof(DSEFFECTDESC));
DsEffectDesc.dwSize = sizeof(DSEFFECTDESC);
DsEffectDesc.dwFlags = 0;
DsEffectDesc.guidDSFXClass = GUID_DSFX_STANDARD_ECHO;
DWORD dwResults;
pDSB8->SetFX(1,&DsEffectDesc,&dwResults);
LPDIRECTSOUNDFXECHO pDirectSoundFxEcho = NULL;//回声特技接口
pDSB8->GetObjectInPath(DsEffectDesc.guidDSFXClass,0,
IID_IDirectSoundFXEcho,
(LPVOID*)&pDirectSoundFxEcho);
DSFXEcho DsFxEcho;
DsFxEcho.fWetDryMix = 50.0f;//处理过的信号和没有处理的信号的比率,缺省值是50
//范围:[DSFXECHO_WETDRYMIX_MIN - DSFXECHO_WETDRYMIX_MAX] 即 [0.0f - 100.0f]
DsFxEcho.fFeedback = 50.0f;//输出信号反馈到输入信号的百分比,缺省值是50
//范围:[DSFXECHO_FEEDBACK_MIN - DSFXECHO_FEEDBACK_MAX] 即 [0.0f - 100.0f]
DsFxEcho.fLeftDelay = 500.0f;//左声道延迟的时间,缺省值500ms
//范围:[DSFXECHO_LEFTDELAY_MIN - DSFXECHO_LEFTDELAY_MAX] 即 [1.0f - 2000.0f]
DsFxEcho.fRightDelay = 500.0f;//右声道延迟的时间,缺省值500ms
//范围:[DSFXECHO_RIGHTDELAY_MIN - DSFXECHO_RIGHTDELAY_MAX] 即 [1.0f - 2000.0f]
DsFxEcho.lPanDelay = 0.0f;//是否左右声道交替延迟,缺省值0,左右声道不交替
//范围:[DSFXECHO_PANDELAY_MIN - DSFXECHO_PANDELAY_MAX] 即 [0.0f - 100.0f]
pDirectSoundFxEcho->SetAllParameters(&DsFxEcho);
SAFE_RELEASE(pDirectSoundFxEcho);
*/
/* 混响特技:简单说就是声音余韵,音源在空间反射出来的声音。适当设置混响,可以更真实、更有现场感的再现声音源,也可以起到修饰、美化的作用。表现宽阔的,传声真实的效果。
DSEFFECTDESC DsEffectDesc;
ZeroMemory(&DsEffectDesc,sizeof(DSEFFECTDESC));
DsEffectDesc.dwSize = sizeof(DSEFFECTDESC);
DsEffectDesc.dwFlags = 0;
DsEffectDesc.guidDSFXClass = GUID_DSFX_WAVES_REVERB;
DWORD dwResults;
pDSB8->SetFX(1,&DsEffectDesc,&dwResults);
LPDIRECTSOUNDFXWAVESREVERB pDirectSoundFxWavesErverb = NULL;//混响特技接口
pDSB8->GetObjectInPath(DsEffectDesc.guidDSFXClass,0,
IID_IDirectSoundFXWavesReverb,
(LPVOID*)&pDirectSoundFxWavesErverb);
DSFXWavesReverb DsFxWavesReverb;
DsFxWavesReverb.fInGain = -45.0f;//输入信号的音量的大小,即db值,缺省值是0db
//范围:[DSFX_WAVESREVERB_INGAIN_MIN - DSFX_WAVESREVERB_INGAIN_MAX] 即 [-96.0f - 0.0f]
DsFxWavesReverb.fReverbMix = -45.0f;//回响混合音量强度大小,用db值来表示,缺省值是0db。
//范围:[DSFX_WAVESREVERB_REVERBMIX_MIN - DSFX_WAVESREVERB_REVERBMIX_MAX] 即 [-96.0f - 0.0f]
DsFxWavesReverb.fReverbTime = 1000.0f;//回响的时间,单位是ms,缺省值是1000.0fms
//范围:[DSFX_WAVESREVERB_REVERBTIME_MIN - DSFX_WAVESREVERB_REVERBTIME_MAX] 即 [0.001f - 3000.0f]
DsFxWavesReverb.fInGain = 0.500f;//高频回响所占时间的比率,缺省值0.001f。TRatio;
//范围:[DSFX_WAVESREVERB_HIGHFREQRTRATIO_MIN - DSFX_WAVESREVERB_HIGHFREQRTRATIO_MAX] 即 [0.001f - 0.999f]
pDirectSoundFxWavesErverb->SetAllParameters(&DsFxWavesReverb);
SAFE_RELEASE(pDirectSoundFxWavesErverb);
*/
/* 波浪特技:一般翻译为波浪特技,用于设置变调效果,通过拷贝失调的声音,或者把某个频率点改变,调节声音分离的时间、音调深度。可以用来产生颤动、急促的声音。
DSEFFECTDESC DsEffectDesc;
ZeroMemory(&DsEffectDesc,sizeof(DSEFFECTDESC));
DsEffectDesc.dwSize = sizeof(DSEFFECTDESC);
DsEffectDesc.dwFlags = 0;
DsEffectDesc.guidDSFXClass = GUID_DSFX_STANDARD_FLANGER;
DWORD dwResults;
pDSB8->SetFX(1,&DsEffectDesc,&dwResults);
LPDIRECTSOUNDFXFLANGER pDirectSoundFxFlanger = NULL;//波浪特技接口
pDSB8->GetObjectInPath(DsEffectDesc.guidDSFXClass,0,
IID_IDirectSoundFXFlanger,
(LPVOID*)&pDirectSoundFxFlanger);
DSFXFlanger DsFxFlanger;
DsFxFlanger.fWetDryMix = 50.0f;//处理过的信号和没有处理的信号的比率,缺省值是50
//范围:[DSFXFLANGER_WETDRYMIX_MIN - DSFXFLANGER_WETDRYMIX_MAX] 即 [0.0f - 100.0f]
DsFxFlanger.fDepth = 50.0f;//低频振荡器调整延迟时间的百分比,缺省值是100
//范围:[DSFXFLANGER_DEPTH_MIN - DSFXFLANGER_DEPTH_MAX] 即 [0.0f - 100.0f]
DsFxFlanger.fFeedback = -50.0f;//输出信号反馈到输入信号的百分比,缺省值是-50
//范围:[DSFXFLANGER_FEEDBACK_MIN - DSFXFLANGER_FEEDBACK_MAX] 即 [-99.0f - 99.0f]
DsFxFlanger.fFrequency = 0.5f;//低频振荡器的频率,缺省值是0.25
//范围:[DSFXFLANGER_FREQUENCY_MIN - DSFXFLANGER_FREQUENCY_MAX] 即 [0.0f - 10.0f]
DsFxFlanger.fDelay = 2.0f;//播放之前的延迟,以毫秒作单位,缺省值是2ms
//范围:[DSFXFLANGER_DELAY_MIN - DSFXFLANGER_DELAY_MAX] 即 [0.0f - 4.0f]
DsFxFlanger.lWaveform = DSFXFLANGER_WAVE_TRIANGLE;//低频振荡器的波形,分为三角形,和正弦波形
//取值:[DSFXFLANGER_WAVE_TRIANGLE ,DSFXFLANGER_WAVE_SIN] 即 [三角波,正弦波]
DsFxFlanger.lPhase = DSFXFLANGER_PHASE_ZERO;//相位
//取值:[DSFXFLANGER_PHASE_NEG_180 , //-180度
// DSFXFLANGER_PHASE_NEG_90 , //-90度
// DSFXFLANGER_PHASE_ZERO , //0度
// DSFXFLANGER_PHASE_90 , //90度
// DSFXFLANGER_PHASE_180 ] //180度
pDirectSoundFxFlanger->SetAllParameters(&DsFxFlanger);
SAFE_RELEASE(pDirectSoundFxFlanger);
*/
/* 咕噜特技[机械化]:咕噜效果处理。一种可以试音源产生咕噜声的调幅处理模式。
DSEFFECTDESC DsEffectDesc;
ZeroMemory(&DsEffectDesc,sizeof(DSEFFECTDESC));
DsEffectDesc.dwSize = sizeof(DSEFFECTDESC);
DsEffectDesc.dwFlags = 0;
DsEffectDesc.guidDSFXClass = GUID_DSFX_STANDARD_GARGLE;
DWORD dwResults;
pDSB8->SetFX(1,&DsEffectDesc,&dwResults);
LPDIRECTSOUNDFXGARGLE pDirectSoundFxGargle = NULL;//咕噜特技接口
pDSB8->GetObjectInPath(DsEffectDesc.guidDSFXClass,0,
IID_IDirectSoundFXGargle,
(LPVOID*)&pDirectSoundFxGargle);
DSFXGargle DsFxGargle;
DsFxGargle.dwRateHz = 500;//调制波频率,缺省值是20hz
//范围:[DSFXGARGLE_RATEHZ_MIN - DSFXGARGLE_RATEHZ_MAX] 即 [1 - 1000]
DsFxGargle.dwWaveShape = DSFXGARGLE_WAVE_TRIANGLE;
//取值:[DSFXGARGLE_WAVE_SQUARE ,DSFXGARGLE_WAVE_TRIANGLE] 即 [方波,三角波]
pDirectSoundFxGargle->SetAllParameters(&DsFxGargle);
SAFE_RELEASE(pDirectSoundFxGargle);
*/
/* 参数平衡特技:参数平衡,用于为音频设置参数均衡器。强化或衰减指定的频率。对于增强音乐的效果特别有效。
DSEFFECTDESC DsEffectDesc;
ZeroMemory(&DsEffectDesc,sizeof(DSEFFECTDESC));
DsEffectDesc.dwSize = sizeof(DSEFFECTDESC);
DsEffectDesc.dwFlags = 0;
DsEffectDesc.guidDSFXClass = GUID_DSFX_STANDARD_PARAMEQ;
DWORD dwResults;
pDSB8->SetFX(1,&DsEffectDesc,&dwResults);
LPDIRECTSOUNDFXPARAMEQ pDirectSoundFxParamEq = NULL;//参数平衡特技接口
pDSB8->GetObjectInPath(DsEffectDesc.guidDSFXClass,0,
IID_IDirectSoundFXParamEq,
(LPVOID*)&pDirectSoundFxParamEq);
DSFXParamEq DsFxParamEq;
DsFxParamEq.fCenter = 8000.0f;//中心的频率,缺省值是8000hz
//范围:[DSFXPARAMEQ_CENTER_MIN - DSFXPARAMEQ_CENTER_MAX] 即 [80.0f - 16000.0f]
DsFxParamEq.fBandwidth = 12.0f;//音的带宽,以半音为单位,缺省值是12
//范围:[DSFXPARAMEQ_BANDWIDTH_MIN - DSFXPARAMEQ_BANDWIDTH_MAX] 即 [1.0f - 36.0f]
DsFxParamEq.fGain = 0.0f;//音频的音量,缺省值是0db
//范围:[DSFXPARAMEQ_GAIN_MIN - DSFXPARAMEQ_GAIN_MAX] 即 [-15.0f - 15.0f]
pDirectSoundFxParamEq->SetAllParameters(&DsFxParamEq);
SAFE_RELEASE(pDirectSoundFxParamEq);
*/
/* 多个特效同时使用
const int iFxCount = 3;
DSEFFECTDESC pDsEffectDesc[iFxCount];
ZeroMemory(pDsEffectDesc,sizeof(DSEFFECTDESC) * iFxCount);
pDsEffectDesc[0].dwSize = sizeof(DSEFFECTDESC);
pDsEffectDesc[0].dwFlags = 0;
pDsEffectDesc[0].guidDSFXClass = GUID_DSFX_STANDARD_ECHO;
pDsEffectDesc[1].dwSize = sizeof(DSEFFECTDESC);
pDsEffectDesc[1].dwFlags = 0;
pDsEffectDesc[1].guidDSFXClass = GUID_DSFX_STANDARD_GARGLE;
pDsEffectDesc[2].dwSize = sizeof(DSEFFECTDESC);
pDsEffectDesc[2].dwFlags = 0;
pDsEffectDesc[2].guidDSFXClass = GUID_DSFX_STANDARD_FLANGER;
DWORD pdwResults[iFxCount];
pDSB8->SetFX(iFxCount,pDsEffectDesc,pdwResults);
//第三个特技使用默认值
LPDIRECTSOUNDFXECHO pDirectSoundFxEcho = NULL;//回声特技接口
pDSB8->GetObjectInPath(pDsEffectDesc[0].guidDSFXClass,0,
IID_IDirectSoundFXEcho,
(LPVOID*)&pDirectSoundFxEcho);
DSFXEcho DsFxEcho;
DsFxEcho.fWetDryMix = 50.0f;
DsFxEcho.fFeedback = 50.0f;
DsFxEcho.fLeftDelay = 500.0f;
DsFxEcho.fRightDelay = 500.0f;
DsFxEcho.lPanDelay = 0.0f;
pDirectSoundFxEcho->SetAllParameters(&DsFxEcho);
SAFE_RELEASE(pDirectSoundFxEcho);
LPDIRECTSOUNDFXGARGLE pDirectSoundFxGargle = NULL;//咕噜特技接口
pDSB8->GetObjectInPath(pDsEffectDesc[1].guidDSFXClass,0,
IID_IDirectSoundFXGargle,
(LPVOID*)&pDirectSoundFxGargle);
DSFXGargle DsFxGargle;
DsFxGargle.dwRateHz = 1000;
DsFxGargle.dwWaveShape = DSFXGARGLE_WAVE_TRIANGLE;
pDirectSoundFxGargle->SetAllParameters(&DsFxGargle);
SAFE_RELEASE(pDirectSoundFxGargle);
*/
SAFE_RELEASE(pDSB8);
//<<<<<<<----------
g_pSound->Play();
break;
}
return (INT_PTR)FALSE;
}
int _tmain(int argc, _TCHAR* argv[])
{
CoInitialize(NULL);
DialogBox(NULL,MAKEINTRESOURCE(IDD_DIALOGDEMO),NULL,DialogProc);
CoUninitialize();
return 0;
}