Archived

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

Kudaba

Direct Sound (Grrrrr)

Recommended Posts

Well, just wondering is anyone has had any experience with the "DirectX in 24 hours" code. I used it and I am getting an error with the CreateSoundBuffer() call. I basically used the EXACT same code, is there an error there or something, maybe something I should know about dsound that they don''t tell me (which seems to happen quite often with this book). Any help will be much obliged (I think that''s the right word). Retired Pokemon Master of Prgramming Problems I already had them all.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Can you paste the code which you use? Maybe I can help you

Share this post


Link to post
Share on other sites
ZeroMemory(&dsBD, sizeof(DSBUFFERDESC));
dsBD.dwSize = sizeof(DSBUFFERDESC);
dsBD.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_STATIC;

//Set up the Sound(s)
dsBD.dwBufferBytes = dwDataLen;
dsBD.lpwfxFormat = &wfFormat;

hRes = lpDS->CreateSoundBuffer(&dsBD, &lpDSBSound, NULL)
if (hRes != DS_OK)
//Check the error

The error I''m getting out of here is DSERR_CONTROLUNAVAIL. Here''s my setup code just before this:

if (DirectSoundCreate(NULL, &lpDS, NULL) != DS_OK)
error("DirectSoundCreate");

if(lpDS->SetCooperativeLevel(hWnd, DSSCL_NORMAL) != DS_OK)
error("lpDS->SetCooperativeLevel");

HRESULT hres;
CWave Sound;
CWave Music;

Sound.Create(szSound);
Music.Create(szMusic);

DWORD dwDataLen;
WAVEFORMATEX wfFormat;
DSBUFFERDESC dsBD;
BYTE* pDSBuffData;

dwDataLen = Sound.GetDataLen();
Sound.GetFormat(wfFormat);


/* That''s almost the EXACT same way they use it in the book, I thikn the only differences are the variable names. */

Retired Pokemon Master of Prgramming Problems

I already had them all.

Share this post


Link to post
Share on other sites
I have that book. I didnt use his DS code though. I just read the DS theory part. My advice is to just use the SDK''s wave reader and look at the sample that loads a .wav into a static buffer.

ECKILLER

Share this post


Link to post
Share on other sites
Why dont u try the DXSDK sample code instead? Ive copied a few bits and pieces and it works fine.


Microsoft developed DX, so im guessing they ''know'' how to use it.

Share this post


Link to post
Share on other sites
Thanks guys, using the SDK over the book sounds good seeing how the book sucks hardcore.


Retired Pokemon Master of Prgramming Problems

I already had them all.

Share this post


Link to post
Share on other sites
*lol* Perhaps it''s called DirectX in 24 hours ''cause it was written and proofread in 24 hours?


People might not remember what you said, or what you did, but they will always remember how you made them feel.
~ (V)^|) |<é!t|-| ~

Share this post


Link to post
Share on other sites