Direct Sound

Started by
7 comments, last by Kudaba 23 years, 6 months ago
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). And finally, it this where dsound questions go, I couldn''t figure out where else to put them? Retired Pokemon Master of Prgramming Problems I already had them all.
This Space for rent.
Advertisement
Maybe it should go in the API specific section with Direct X I dunno though, and for your question I''m sorry I''m not familiar with that code (Direct X in 24 hours)


Maketty
(Matthew FitzGerald)
Knightvision Games

Maketty (Matthew FitzGerald) The meaning of Life part 5:Live organ transplants...
i''d be glad to try to help you; i''ve got the book right in front of me.. i never used the code directly, though, just looked at it and wrote my own..

what''s the error it''s giving you?
i think the most likely problem is with the DSBUFFERDESC parameter.. either you''re setting a field wrong (or not setting a vital one), or you''re not zeroing it out and setting the struct size. if it''s the last, that''s easily fixed, just do the same thing you did with DDSURFACEDESC struct for DirectDraw, i.e.

DSBUFFERDESC dsbd;
memset(&dsbd,0,sizeof(dsbd));
dsbd.dwSize = sizeof(dsbd);

if that''s not it, please post the error the compiler gives you, and i''ll try to help

------------------------
IUnknown *pUnkOuter

"Just do your best and
don't worry"
--Morrissey

"Try the best you can
try the best you can
the best you can is good enough"
--Radiohead

"Are you looking for new ways
to do better than your worst"
--Nick Drake
------------------------IUnknown *pUnkOuter"Try the best you cantry the best you canthe best you can is good enough" --Radiohead
My bad, I was confused, I thought the dx/ogl/etc section was graphics or something, sorry for the mispost.

Retired Pokemon Master of Prgramming Problems

I already had them all.
This Space for rent.
No Problem!


Maketty
(Matthew FitzGerald)
Knightvision Games

Maketty (Matthew FitzGerald) The meaning of Life part 5:Live organ transplants...
ZeroMemory(&dsBD, sizeof(DSBUFFERDESC));
dsBD.dwSize = sizeof(DSBUFFERDESC);
dsBD.dwFlags = DSBCAPS_CTRLDEFAULT | DSBCAPS_STATIC;

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

if(lpDS->CreateSoundBuffer(&dsBD, &lpDSBSound, NULL) != DS_OK)
error("lpDS->CreateSoundBuffer (Sound)");

There's the stuff I'm doin' with the buffer descripter, the only difference between that and the book is the CTRL_DEFAULT, in the book it uses three things that DEFAULT adds anyway.

Is there a way to retrieve the error, 'cause I was looking through that book and Tricks of the Windows Game programming book and neither had any way to retrieve error codes.

/********
I should have specified the first time, it's a runtime error. When it calls CreateSoundBuffer() it doen't go through as DS_OK.
********/

Retired Pokemon Master of Prgramming Problems

I already had them all.

Edited by - Kudaba on October 7, 2000 2:18:59 AM
This Space for rent.
the function returns the error code, like with all parts of DirectX.. see the DirectX SDK Help for more details on the code, but here they are:
DSERR_ALLOCATED
DSERR_CONTROLUNAVAIL
DSERR_BADFORMAT
DSERR_INVALIDPARAM
DSERR_NOAGGREGATION
DSERR_OUTOFMEMORY
DSERR_UNINITIALIZED
DSERR_UNSUPPORTED

you can check like this
        HRESULT result;if( (result = lpDS->CreateSoundBuffer(&dsbd,&lpdsb,NULL)) != DD_OK){    switch(result)    {        case DSERR_ALLOCATED:            // etc.....        

oh, and you're getting an error at run time, or compile time?
(nevermind, answered the question while i was answering yours )

------------------------
IUnknown *pUnkOuter

"Just do your best and
don't worry"
--Morrissey

"Try the best you can
try the best you can
the best you can is good enough"
--Radiohead

"Are you looking for new ways
to do better than your worst"
--Nick Drake


Edited by - pUnkOuter on October 7, 2000 2:26:34 AM
------------------------IUnknown *pUnkOuter"Try the best you cantry the best you canthe best you can is good enough" --Radiohead
DSBCAPS_DEFAULT is obsolete in dx7.

change it back.


a2k
------------------General Equation, this is Private Function reporting for duty, sir!a2k
Well, getting closer, thanks a lot for the help so far, I took out DSBCAPS_DEFAULT, now the error that it''s giving me is DSERR_CONTROLUNAVAIL, I took out frequency volume, and pan and it still gives it to me. I wish DX i 24 would explain things a little better.

Retired Pokemon Master of Prgramming Problems

I already had them all.
This Space for rent.

This topic is closed to new replies.

Advertisement