Advertisement

Direct Sound: Primary Buffer !?!!!

Started by February 15, 2000 07:01 PM
5 comments, last by Jerec 24 years, 7 months ago
I know that when you create a direct sound interface the primary buffer defaults to 8-bit 22Khz... I want to know how you can change that to, say, 16-bit 22Khz... Thanks, Jerec
JerecCM Software"Oro?"
I belive it should be something like this:

DirectSoundCreate( NULL, &m_lpDS ,NULL);

ZeroMemory(&dsbdesc, sizeof( DSBUFFERDESC ) );
m_lpDSB = NULL;

m_lpDS->SetCooperativeLevel(m_hWnd,DSSCL_PRIORITY);
//Set up DSBUFFERDESC structure.
memset( &dsbdesc, 0, sizeof( DSBUFFERDESC ) );
dsbdesc.dwSize = sizeof( DSBUFFERDESC );
dsbdesc.dwFlags = DSBCAPS_PRIMARYBUFFER;
dsbdesc.dwBufferBytes = 0; //Must be 0 for primary buffer.
dsbdesc.lpwfxFormat = NULL; //Must be NULL for primary buffer.

memset( &wfm, 0, sizeof(WAVEFORMATEX));
wfm.wFormatTag = WAVE_FORMAT_PCM;
wfm.nChannels = 1; //mono
wfm.wBitsPerSample = 16; //16-bit sound wfm.nSamplesPerSec = 22050; //22kHz
wfm.nBlockAlign = wfm.wBitsPerSample / 8 * wfm.nChannels;
wfm.nAvgBytesPerSec = wfm.nSamplesPerSec * wfm.nBlockAlign;

Actually I have no idea but this works for me.
m_grínder
Advertisement
Its all to do with the co-operative level. If you set it to DDSCL_NORMAL you can''t change the PCM format from 8bit at 22 samples per second - if you need to change it to a different format, make sure you set the co-op level to DDSCL_PRIORITY.
That did it! Thanks!

Jerec
JerecCM Software"Oro?"
That did it! Thanks!

Jerec
JerecCM Software"Oro?"
That did it! Thanks!

Jerec
JerecCM Software"Oro?"
Advertisement
Not sure what happened there... ha ha...
JerecCM Software"Oro?"

This topic is closed to new replies.

Advertisement