Skip to main content
GameDev.net gamedev.net
🔒 Locked

Directsound help

Started by matt_j Jul 10, 2004 at 7:37 PM 3 replies 1.4k views
Original Post
matt_j
matt_j
Hello! I have an array in a header file of a small sound eg: unsigned char snd[(some number)]={0xA1, 0x44 ...}; etc... How do I load this sound using CSoundManager::CreateFromMemory ? Any help would be much appreciated! Thanks!
matt_j
matt_j
(bump)

I have it working somewhat, but I hear static at the beginning and end when the file is played or looped. Any advice?
Saandman
Saandman
HRESULT CSoundManager::CreateFromMemory( CSound** ppSound,
BYTE* pbData,
ULONG ulDataSize,
LPWAVEFORMATEX pwfx,
DWORD dwCreationFlags,
GUID guid3DAlgorithm,
DWORD dwNumBuffers )

First of all, you have to make sure that the data you pass is valid as a WAV file, cuz that's what this does - loads a WAV from memory.

And this information may seem obvious to you but what do I know :)

Well I've never used this baby cuz I want to write everything my self, but you have to pass a CSound object to hold your sound data in a sound buffer, then the actual sound data and its size in bytes, then a format description of your sound (sample rate, channels, block align etc), the creation flags are the IDirectSoundBuffer8 creation flags (DSBCAPS_XXX), the GUID is for 3d, and last is the number of buffers (apparearently they create one original buffer and then duplicate it dwNumBuffers times or create new ones if you use DSBCAPS_CTRLFX).

I would double check the WAVEFORMATEX struct if I were you!

edit: typo
________pro.gram.mer - an organism that turns caffeine into code
matt_j
matt_j
Something must be corrupt in the files. Even using the MS directsound sample with this sound file caused problems. I'm starting to think I'm going to have to devise a simple way to point directsound only to the sound data and the header. That, or use Sound Forge to re-write them.
Gyannea
Gyannea
I don't know about MFC but if you do it directly using the DirectSound API functions then what you load into the DirectSound buffer object is the sound data itself. However, you must specify the format and other tidbits of information in a structure when creating these objects (type of data, sample rate, channels (stereo/mono), bit depth (8 or 16 bit), bytes per second (samplerate * channels * bitdepth/8), etc.) Its quite straight forward and there is nothing hidden from you. When you use shells you have to be very sure that you follow instructions exactly to the tee and your supplied data complies equally as rigidly.

Brian
Brian Reinhold

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.