DevMaster.net Forums
[[ Home | Forums | 3D Engines Database | Wiki | Articles/Tutorials | Game Dev Jobs | IRC Chat Network | Contact Us ]]

Go Back   DevMaster.net Forums > Programming & Development > Sound and Music Programming
User Name
Password
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
Old 08-25-2005, 09:27 PM   #1
Onikhaosifix
Valued Member
 
Join Date: Jul 2005
Posts: 117
Default

Hello,

Earlier today I decided to take a crack at DirectX Audio, more specifically, DirectSound. Some very low level stuff but I figured after I read some documentation on it carefully I could get it up and running in no time. However, this isn't the case for me here.

I get tons of compiling errors and most of them are in dsound.h so I figured it isn't me. The type of errors I get include syntax, missing-storage type(LPCWAVEFORMATEX), and all that jazz.

At first, I suspected it had something to do with defining INITGUID but I already did that weeks ago because I was using DirectX Input8. So I tried the alternative by linking to dxguid.lib and the errors are still there.

It's strange how Direct3D doesn't need this crap. Also, it's weird how the object creation function in DirectSound is DirectSoundCreate8 and in DirectInput it's DirectInput8Create. You would think that the naming conventions between the APIs were consistent. I guess the API designers....aren't good API designers
___________________________________________
"God is dead." -- Nietsche
"Nietsche is dead" -- God
Onikhaosifix is offline   Reply With Quote
Old 08-25-2005, 10:27 PM   #2
bladder
DevMaster Staff
 
bladder's Avatar
 
Join Date: Sep 2003
Location: Hell
Posts: 1,109
Default

Try including windows.h before dsound.h. IIRC that was the fix to this problem.
___________________________________________
- TripleBuffer
- Me blog
bladder is offline   Reply With Quote
Old 08-26-2005, 10:24 AM   #3
Onikhaosifix
Valued Member
 
Join Date: Jul 2005
Posts: 117
Default

Nevermind, I forgot to define DIRECTSOUND_VERSION. It compiles fine now. I'm having some more trouble now with setting the playback format of the primary sound buffer. Here is my code snippet.

Code:
VOID framework::InitDSound( DWORD dwLevel, WORD nChannels, WORD nBitsPerSample, WORD nFrequency ) { if( FAILED(DirectSoundCreate8( NULL, &_pDS, NULL )) ) *_pELog << "Unable to create DSound object."; if( FAILED(_pDS->SetCooperativeLevel( _pW->GetHandle(), dwLevel )) ) *_pELog << "Unable to set cooperative of this application for the sound device."; DSBUFFERDESC dbd; ZeroMemory( &dbd, sizeof(DSBUFFERDESC) ); dbd.dwSize = sizeof(DSBUFFERDESC); dbd.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_CTRLVOLUME; dbd.dwBufferBytes = 0; dbd.lpwfxFormat = NULL; if( FAILED(_pDS->CreateSoundBuffer( &dbd, &_pDSPrimary, NULL )) ) *_pELog << "Unable to create primary sound buffer."; WAVEFORMATEX wf; ZeroMemory( &wf, sizeof(WAVEFORMATEX) ); wf.wFormatTag = WAVE_FORMAT_PCM; wf.nChannels = nChannels; wf.nSamplesPerSec = nFrequency; wf.nAvgBytesPerSec = nFrequency * (nChannels * nBitsPerSample); // samples per second * block alignment. wf.nBlockAlign = 4 /*nChannels * nBitsPerSample / 8*/; // # of channels * bits per sample / 8. wf.wBitsPerSample = nBitsPerSample; if( FAILED(_pDSPrimary->SetFormat( &wf )) ) *_pELog << "Unable to set playback format of primary sound buffer."; } ////////////////////////////////////////////////////////////////////////////////////////////////

'_pELog' is of type LPLOGERROR which is my error log class. Anyways, the last if statement in that function is true which isn't good. Am I doing something wrong with setting up the WAVEFORMATEX structure?
___________________________________________
"God is dead." -- Nietsche
"Nietsche is dead" -- God
Onikhaosifix is offline   Reply With Quote
Old 08-29-2005, 11:48 AM   #4
bignobody
Valued Member
 
bignobody's Avatar
 
Join Date: Sep 2004
Location: Ontario, Canada
Posts: 155
Default

I had a look through my own DSound code, and it seems I never set the format for any sound buffer directly (meaning it gets it from the lpwfxFormat parameter of the DSBUFFERDESC struct that gets passed in on Initialize).

The first thing to try is to determine what error code is being reported (don't just hand the result of the function to the FAILED macro. Assign the method's return value to a variable so you can find out what's gone wrong).

One possibility from the the SDK documentation:

Since primary sound buffers do not support the IDirectSoundBuffer8 interface, this method must be called on IDirectSoundBuffer.


Other than that, do you really need to do this? Another nugget from the docs:


When you obtain write access to the primary buffer, other DirectSound features become unavailable. Secondary buffers are not mixed, so hardware-accelerated mixing is unavailable.

Most applications should use secondary buffers instead of directly accessing the primary buffer.




That's all I can offer at the moment. Good luck!

-bignobody
___________________________________________
-bignobody
notsoftgames.com - Creator of Shlongg!
bignobody is offline   Reply With Quote
Old 08-31-2005, 09:08 PM   #5
Onikhaosifix
Valued Member
 
Join Date: Jul 2005
Posts: 117
Default

Ah thanks I already solved the problem ages ago.
___________________________________________
"God is dead." -- Nietsche
"Nietsche is dead" -- God
Onikhaosifix is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Forum Jump


All times are GMT -7. The time now is 01:26 AM.


Powered by vBulletin
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.