Directsound noise

Started by
8 comments, last by Herr_O 21 years, 10 months ago
Hi I''m trying to play wave files using directsound8 buffers. I want overlaping copies of the same sound, so my idea is this: One primary buffer as usual ~100 secondary buffers to hold the wave files, one for each file. ~30 secondary buffers to be used as channels. When I want to play a sound I first find the correct wavechannel (0-100), then I duplicate it into a non playing channelbuffer (0-30) using lpds->DuplicateSoundBuffer(wavebuf,chanbuf); After that I just play the duplicated channelbuffer. I don''t set any PCMWAVEFORMAT or DSBUFFERDESC for the duplicated buffer becouse I think it gets copied from the wave buffer.. am I right, do I need to? All this works fine except that I get an irritating "tick" noise which disapears after about 20 playbacks, then the sample plays as it should. If I try to play another sound the tick noise comes back for about 20 playbacks or so.. the number varies Has anyone else heard of this problem before, can it be fixed? Thanks! -----------------------------
Sometimes a Guru meditation must be followed by a Vulcan neck grip.
_____________________________
www.OddGames.comwww.OddGames.com/daniel
Advertisement
this "tick" noise is probaly due to your samples either being bad, or how yoru sound drivers handle mixing. the primary buffer should always be looping. check the docs and make sure you dont need to do any releases or such when doing what you are doing. dont want memory leaks.

do you get the "tick" when playing the sounds normally from the secondary buffer they are stored in? are you stopping the buffer before duplication correct. clicks will occer if the wav is of a different format then the primary buffer in some cases.

nearly ALL audio devices will generate a click/pop when started and stopped, so the primary buffer should be playing even if you dont have any sound playing for a few seconds.
Now I tried playing the primary buffer with DSBPLAY_LOOPING, but it didn''t help.. I checked the wave files and they all begin at zero. Still I get the tick noise. The primary and secondary buffers are all in the same format (16bit 22050Hz 2 channels). I''m using a SoundBlaster 1024 Live Value so there shouldn''t be any problems.

"check the docs and make sure you dont need to do any releases or such when doing what you are doing. dont want memory leaks. "

I am only releasing the buffers when I quit the app.. But I''ve seen in the dxsdk adjustsound app that they release the primary buffer after they have created it, maybe I got it wrong or missed something but it seems wrong to me... should I be doing that?

-----------------------------
Sometimes a Guru meditation must be followed by a Vulcan neck grip.
_____________________________
www.OddGames.comwww.OddGames.com/daniel
Try the release version of the DirectX runtime...


...When a buffer is created, the debug version of DSound fills that buffer with white noise so that you can detect places where you play a buffer before filling in all/some of the space in that buffer.

It could be an "off by one" type error in your buffer fill code. The "clears up after 20 runs" also hints at some error with the buffer filling.

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

I heard of that white noise before but newer really understanded it. I'm compiling the project in "release mode", I've also tried running the executable strait from windows with same results..

Where do I get this release version? (yes I've looked it up with google) Only site I could find about the problem was this:

http://www.directxfaq.com/kbase/dsound/whitenoise.htm

but that doesn't help very much...

[edited by - Herr_O on June 4, 2002 8:22:15 AM]
_____________________________
www.OddGames.comwww.OddGames.com/daniel
I was talking about the release version of the DirectX SDK rather than of your app.

some other ideas:

1. Try your wave data files with the sample programs in the SDK:

a) if the click is still there and the wave data which comes with the SDK doesn''t click, the wave data is at fault.

b) if the click doesn''t occur with the SDK samples, your code is at fault.

c) if the click also happens on the DirectX samples and with their wave data, DSound (or your sound card drivers...) could be at fault.

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

must be something wrong with the sample..it ticks in the sdk-program adjustsound also. Adding a bit of silence right at the start of the sample seems to get rid of the noise.

It''s strange that the sample works in the sound editing program without any silence at the start... they can''t be using directsound hehe

Thx alot !

-----------------------------
Sometimes a Guru meditation must be followed by a Vulcan neck grip.
_____________________________
www.OddGames.comwww.OddGames.com/daniel
The ticking is most likely from debug mode or you are starting and stopping the primary buffer between samples. To always play the primary buffer, use the DSB_LOOPING flag and make sure not to call Stop on the primary buffer. Also, to aid the mixer, try to always play samples that use the exact same format (ie 22,050hz, 16-bit, mono). Playing different formats slows down the mixer and can cause little glitches at time. I notice the most problems using 8-bit samples.



Jim Adams
home.att.net/~rpgbook
Author, Programming Role-Playing Games with DirectX
What do you mean by "debug mode"? I run my application in "release mode" (set active configuration (vs6c++)). Feels like I said this a thousand times before. Am I missing something?

-----------------------------
Sometimes a Guru meditation must be followed by a Vulcan neck grip.
_____________________________
www.OddGames.comwww.OddGames.com/daniel
quote:Original post by Herr_O
What do you mean by "debug mode"?


He''s talking about the debug version of DirectX. There''s a release and a debug version, you''ll get the debug version with the DirectX SDK.

quote:Sometimes a Guru meditation must be followed by a Vulcan neck grip.


I believe the correct term is "nerve pinch"

This topic is closed to new replies.

Advertisement