Archived

This topic is now archived and is closed to further replies.

adriano_usp

playing sounds: DirectShow vs DirectSound

Recommended Posts

Hi programmers, I played a wav sound using DirectSound and using DirectShow... result: DirectShow was the fastest. Question: Is DirectShow faster than DirectSound? The problem with DirectSound is your initialization. Maybe I am making something wrong. My DSound initialization function is:
BOOL InicializaDS( HWND hWnd )
{
	// Criando o objeto de performance

    if (FAILED ( CoCreateInstance( CLSID_DirectMusicPerformance, NULL, CLSCTX_INPROC, 
                      IID_IDirectMusicPerformance8, (VOID**)&m_pDirectAudioPerformance ) ) )
	{
		MessageBox( NULL, "Não foi possível criar o objeto m_pDirectAudioPerformance","erro", MB_OK );
		return FALSE;
	}

	// Criando o objeto carregador

    if (FAILED ( CoCreateInstance( CLSID_DirectMusicLoader, NULL, CLSCTX_INPROC, 
                      IID_IDirectMusicLoader8, (VOID**)&m_pDirectAudioLoader ) ) )
	{
		MessageBox( NULL, "Não foi possível criar o objeto m_pDirectAudioLoader","erro", MB_OK );
		return FALSE;
	}

    // Inicializando o objeto de performance

    if (FAILED ( m_pDirectAudioPerformance->InitAudio(	NULL, NULL, hWnd, 
														DMUS_APATH_SHARED_STEREOPLUSREVERB,
														64, DMUS_AUDIOF_ALL, NULL ) ) )
	{
		MessageBox( NULL, "Não foi possível inicializar o objeto m_pDirectAudioPerformance","erro", MB_OK );
		return FALSE;
	}

	// Indicando o caminho para o diretório "Sons"

	CHAR strPath[MAX_PATH];
    if (GetCurrentDirectory( MAX_PATH, strPath ) == 0 )
		return FALSE;
    strcat( strPath, "\\Sons" );

	// Convertendo o caminho para unicode

	WCHAR wstrPath[MAX_PATH];
    MultiByteToWideChar( CP_ACP, 0, strPath, -1, wstrPath, MAX_PATH );

	// Configurando o diretório

	if (FAILED ( m_pDirectAudioLoader->SetSearchDirectory( GUID_DirectMusicAllTypes, 
												wstrPath, FALSE ) ) )
	{
		MessageBox( NULL, "Não foi possível configurar o diretório de sons","erro", MB_OK );
		return FALSE;
	}


	return TRUE;

}

It works perfectly, but slow... Any ideas? Thanks.

Share this post


Link to post
Share on other sites
hmmm i havent gotten very far into it but its my (possible Ignorant) belief that DirectSound is used where you need to do things like positional sound or more direct control over the sound, And DirectShow is used for playing things like mp3''s. Maybe DirectSound is slower becouse it offers more 3d(sound) features.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
guys, DirectSound cannot be slower than DirectShow because DShow is built upon DSound (DShow uses "wrap" filters to DSound to play sounds). the problem is probably not in DSoubd initialization but with DSound buffers attributes. The music buffer should be created w/o 3D flags. Another problem is that you are trying to play entire large file (above 500k-1mb) instead of playing it by pieces (streaming sound). And if you are using streaming sound model check that you are using correct threads synchronization (WaitForSingleObject for example, not waiting for kind of variable flag)

Share this post


Link to post
Share on other sites