Skip to main content
gamedev.net
🔒 Locked

AudioFX problem

Started by peter86 0 replies 250+ views
Original Post
peter86
peter86
I´ve applied an echo effect on an audiopath but I can´t hear the effect. I´m sure that the program won´t exit until DirectAudio has stopped playing the sound so what´s wrong? Here´s the code:
  
// Create a standard audiopath

if( FAILED( hr = g_pPerformance->CreateStandardAudioPath( DMUS_APATH_DYNAMIC_3D, 
	64, FALSE, &g_pAudioPath ) ) )
{
	DXTRACE_ERR( g_lpAppTitle, hr );
	return hr;
}

// Get the buffer in the audiopath

if( FAILED( hr = g_pAudioPath->GetObjectInPath( DMUS_PCHANNEL_ALL, DMUS_PATH_BUFFER, 
	0, GUID_NULL, 0, IID_IDirectSoundBuffer8, (LPVOID*) &g_pDSBuffer ) ) )
{
	DXTRACE_ERR( g_lpAppTitle, hr );
	return hr;
}

// Describe the effect

DSEFFECTDESC dsEffect;
memset( &dsEffect, 0, sizeof(dsEffect) );
dsEffect.dwSize			= sizeof(dsEffect);
dsEffect.guidDSFXClass	= GUID_DSFX_STANDARD_ECHO;

// Apply the effect

if( FAILED( hr = g_pDSBuffer->SetFX( 1, &dsEffect, NULL ) ) )
{
	DXTRACE_ERR( g_lpAppTitle, hr );
	return hr;
}

// Activate the audiopath

g_pAudioPath->Activate( TRUE );

// Get the interface of the effect

if( FAILED( hr = g_pAudioPath->GetObjectInPath( DMUS_PCHANNEL_ALL, DMUS_PATH_BUFFER_DMO, 
	0, GUID_All_Objects, 0, IID_IDirectSoundFXEcho8, (LPVOID*) &g_pDSFXEcho ) ) )
{
	DXTRACE_ERR( g_lpAppTitle, hr );
	return hr;
}

// Set the parameters of the effect

g_FXEchoParams.fWetDryMix	= 30;
g_FXEchoParams.fFeedback	= 30;
g_FXEchoParams.fLeftDelay	= 1000;
g_FXEchoParams.fRightDelay	= 1000;
if( FAILED( hr = g_pDSFXEcho->SetAllParameters( &g_FXEchoParams ) ) )
{
	DXTRACE_ERR( g_lpAppTitle, hr );
	return hr;
}

// Time to play some sound

char	cFileName[MAX_PATH] = "ding.wav";
char	cPath[MAX_PATH] = "C:\\Windows\\Media";
WCHAR	wszFileName[MAX_PATH];
WCHAR	wszPath[MAX_PATH];

DXUtil_ConvertGenericStringToWide( wszFileName, cFileName, sizeof(wszFileName) );
DXUtil_ConvertGenericStringToWide( wszPath, cPath, sizeof(wszPath) );

// Set the search directory

if( FAILED( hr = g_pLoader->SetSearchDirectory( GUID_DirectMusicAllTypes, 
	wszPath, TRUE ) ) )
{
	DXTRACE_ERR( g_lpAppTitle, hr );
	return hr;
}

// Load the file

if( FAILED( hr = g_pLoader->LoadObjectFromFile( CLSID_DirectMusicSegment, 
	IID_IDirectMusicSegment8, wszFileName, (void**) &g_pSegment ) ) )
{
	DXTRACE_ERR( g_lpAppTitle, hr );
	return hr;
}

// Download the band

if( FAILED( hr = g_pSegment->Download( g_pPerformance ) ) )
{
	DXTRACE_ERR( g_lpAppTitle, hr );
	return hr;
}

// Play the file

if( FAILED( hr = g_pPerformance->PlaySegmentEx( g_pSegment, NULL, NULL, 
	0, 0, NULL, NULL, NULL ) ) )
{
	DXTRACE_ERR( g_lpAppTitle, hr );
	return hr;
}
  

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.