WAVEFORMATEXTENSIBLE with PlaySound sample from DirectxSDK

WAVEFORMATEXTENSIBLE with PlaySound sample from DirectxSDK

Post by RGVla3NoaX » Thu, 31 Mar 2005 14:27:02


Hi all,
can anybody point me to an example/demo project with source using
WAVEFORMATEXTENSIBLE. Or at least how to modify the PlaySound sample in
DirectX SDK to use WAVEFORMATEXTENSIBLE.

I trued the following in SetPrimaryFormat() of DXSound.cpp(common
files). But I always get E_INVALIDARG at SetFormat(). This does not
happend when I comment the code where I set wfx.Format.wFormatTag. But,
I get sound from only Front/Back Leftand Right. No Center and LFE.

Please help me

==============================================================================
WAVEFORMATEXTENSIBLE wfx;
ZeroMemory( &wfx, sizeof(WAVEFORMATEXTENSIBLE) );
wfx.Format.wFormatTag = (WORD) WAVE_FORMAT_EXTENSIBLE;;
wfx.Format.nChannels = (WORD) 6;
wfx.Format.nSamplesPerSec = (DWORD) dwPrimaryFreq;
wfx.Format.wBitsPerSample = (WORD) dwPrimaryBitRate;
wfx.Format.nBlockAlign = (WORD) (wfx.Format.wBitsPerSample / 8 *
wfx.Format.nChannels);
wfx.Format.nAvgBytesPerSec = (DWORD) (wfx.Format.nSamplesPerSec *
wfx.Format.nBlockAlign);
wfx.dwChannelMask = SPEAKER_FRONT_LEFT |
SPEAKER_FRONT_RIGHT |
SPEAKER_BACK_LEFT |
SPEAKER_BACK_RIGHT |
SPEAKER_FRONT_CENTER |
SPEAKER_LOW_FREQUENCY;
wfx.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;



if( FAILED( hr = pDSBPrimary->SetFormat((WAVEFORMATEX*)(&wfx)) ) )
{

return DXUT_ERR( L"SetFormat", hr );
}
==============================================================================

Thanks in advance
Deekshit M
 
 
 

WAVEFORMATEXTENSIBLE with PlaySound sample from DirectxSDK

Post by Richard Do » Fri, 01 Apr 2005 00:50:44

For WAVEFORMATEXTENSIBLE you also need to set wfFormat.Format.cbSize to 22.

Richard Dobson





...
...

 
 
 

WAVEFORMATEXTENSIBLE with PlaySound sample from DirectxSDK

Post by Deekshit M » Fri, 01 Apr 2005 01:11:28

Hi,
Thank you for the suggestion. Setting the cbsize didn't give me any
error this time. But I get audio from 4 of speakers, that is no audio
from Center and LFE.

Thanks
Deekshit M
 
 
 

WAVEFORMATEXTENSIBLE with PlaySound sample from DirectxSDK

Post by Deekshit M » Fri, 01 Apr 2005 01:28:02

BTW, I am setting the format of primary buffer only, does that make any
difference. I tried to set the same to normal buffers, but it failed
there. Now a different error, DSERR_INVALIDCALL.

Deekshit M
 
 
 

WAVEFORMATEXTENSIBLE with PlaySound sample from DirectxSDK

Post by Chris P. [ » Fri, 01 Apr 2005 03:05:12


You have to use the format when you create the secondary buffer, this is
important.
 
 
 

WAVEFORMATEXTENSIBLE with PlaySound sample from DirectxSDK

Post by Richard Do » Fri, 01 Apr 2005 09:25:41

There can be any number of reasons for this, ranging from only supplying 4
channels to the card to not having Windows configured for a 6-speaker system
(check Sound and Audio Devices -->Speaker Settings->Advanced and make sure you
have it set for 5.1). I even hit this problem once and found the cables had
partially pulled out from the mini-jack sockets!



Richard Dobson



..
 
 
 

WAVEFORMATEXTENSIBLE with PlaySound sample from DirectxSDK

Post by RGVla3NoaX » Fri, 01 Apr 2005 14:11:02

Hi,
here is my configuration.
sound card : Creative SBLive 5.1
Speakers : Creative inspire 5.1.
DirectX 9.0 Dec-2004 SDK
Creative speaker test is working fine. Speaker configuration is set for
5.1. I am also setiing the SpeakerConfiguration, before creating primary
buffer in my application.

Deekshit M
 
 
 

WAVEFORMATEXTENSIBLE with PlaySound sample from DirectxSDK

Post by Richard Do » Sun, 03 Apr 2005 03:31:36

Humm, does the SBLive render a known 5.1 soundifile via Media Player? I had
heard that that at least the early versions of that card really only output 5.1
when decoding AC3, but weren't really full 6-channel devices.


If it does, I don't know what else to suggest, short of saying that you
double-check that those channels are not somehow being omitted or emptied in
your code somewhere.


Richard Dobson



..
 
 
 

WAVEFORMATEXTENSIBLE with PlaySound sample from DirectxSDK

Post by Chris P. [ » Sun, 03 Apr 2005 22:41:13


If you persist to have problems with multi-channel and DirectSound you
might want to try a wrapper interface like PortAudio. Not only will it
work with DirectSound, but ASIO, winMM and soon WDM kernel streaming. It
was designed for multichannel from day 1 so it might be easier.