Jump to content

  • Log In with Google      Sign In   
  • Create Account


Direct Sound: Primary Buffer !?!!!


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 Jerec   Members   -  Reputation: 122

Like
Likes
Like

Posted 15 February 2000 - 01:01 PM

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

Sponsor:

#2 m_grinder   Members   -  Reputation: 122

Like
Likes
Like

Posted 15 February 2000 - 09:53 PM

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

#3 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 16 February 2000 - 12:26 AM

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.

#4 Jerec   Members   -  Reputation: 122

Like
Likes
Like

Posted 16 February 2000 - 04:33 AM

That did it! Thanks!

Jerec

#5 Jerec   Members   -  Reputation: 122

Like
Likes
Like

Posted 16 February 2000 - 04:33 AM

That did it! Thanks!

Jerec

#6 Jerec   Members   -  Reputation: 122

Like
Likes
Like

Posted 16 February 2000 - 04:33 AM

That did it! Thanks!

Jerec

#7 Jerec   Members   -  Reputation: 122

Like
Likes
Like

Posted 16 February 2000 - 04:33 AM

Not sure what happened there... ha ha...




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS