C++/VB - crazy noise in Directsound

Asked By Ji
24-Mar-08 05:57 AM
I'm using Directsound to play two wavs.  Sound 1 is a looped wav and is run
with the looped flag set in Play().  Sound 2 is a sound that lasts about a
second and isn't looped.  Sound 1 turns off asynchronously via a button
control (using Stop()).  The next occurrance of sound 1 after sound 2 is
turned off has a loud unwanted pop that happens at the beginning of it.

I've tried everything I can think of and have started shooting in the dark.
Set the play position in the buffers to zero when turning sound 1 off,
polling sound 1 and waiting to turn it off until it's at a place I know is a
zero crossing.  I even tried releasing all the buffers and then
reinitializing everything after turning sound 1 off, but still get the pop
that goes along with the next occurrance of sound 2.  How to fix?  At least
one demo I've seen of how to use Directsound also has a similar problem.
Soundblaster
(1)
Directsound
(1)
Newcomer
(1)
Windows
(1)
AA3F52123DB5
(1)
Occurrance
(1)
Phenomenon
(1)
Magnitude
(1)
  Mark Salsbery [MVP] replied...
24-Mar-08 04:12 PM
You may want to post this question here as well:

microsoft.public.win32.programmer.directx.audio

Mark

--
Mark Salsbery
Microsoft MVP - Visual C++
  Joseph M. Newcomer replied...
24-Mar-08 10:19 PM
Even in ordinary playing, I've heard an odd "pop" now and again as the sound card is
activated.  Have you tried it on another machine to see if there is something related to
this phenomenon that may be driver-related?
joe


Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
  Ji replied...
25-Mar-08 12:31 AM
Hi Joe, hope all is well.

I've tried it on two pretty dissimilar machines.  HP/98/Soundblaster vs
laptop/newish/Dell.

Incidently the pop is at the beginning of sound 2, not as I typo'ed below.

It seems to becaused by looping.  If I run sound 1 unlooped, then no problem
at the beginning of sound 2.  If I run sound 1 looped, but stop it at the
same place it stops when running unlooped, then I get the problem.  If I stop
sound 1 at random places,  I get the problem as well of course.
  Joseph M. Newcomer replied...
25-Mar-08 10:31 AM
I'll see if I can replicate this in the non-DirectSound world, but it will take me a while
to get the program installed on my desktop (it seemed to do this on my old desktop while
looping, but doesn't do it on my laptop).  I'll see what I can find out.
joe


Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
  David Ching replied...
25-Mar-08 12:24 PM
A pop occurs when a high magnitude sample is started playing.  It seems in
your case there is some stale data from the first sample still in the
playback buffer that is popping.

I believe when you start playback, Windows normally starts the playback at
volume 0 and quickly ramps it up so that whatever you are playing does not
pop.  It seems in your case this is not happening; playback starts at full
volume and pops.

You may want to flush the DirectSound device or open/close it as necessary.
I use the wave API's and that's what I do.  I've not used DirectSound too
much.

-- David
  Ji replied...
26-Mar-08 02:00 AM
Keeping a loop of silence running, at the suggestion of Chris P., has solved
the problem. This is apparently a Directsound bug.  Thanks, all.

Jim
Create New Account
help
few seconds as it normally does under XP. Interestingly enough, it does not happen under Windows 7 on the same box no matter how hard I try. Some say it is Athlon 2, X4 620 CPU, 4 Gigs of DDR2 ram by Team Extreme. Running on Windows XP SP3. - - Programmer's Goldmine collections: http: / / preciseinfo.org Win32 Kernel Discussions Windows NT 3.51 (1) Windows XP (1) Windows 7 (1) Python (1) Linux (1) SystemTimeToFileTime (1) UNIX (1) XP (1) I'd say you can bet it is a driver causing the problem. Most likely, the difference in Windows 7 has nothing to do with Firefox, but a better driver for some piece of able to help further. Good luck, - -pa Yep. That is what I thought first. Except Windows is not trully multi-tasking system and I saw plenty of times the system is that one is a stretch. Because mouse is one of the top priority items in Windows. Well, except I am not sure what the issue is. As far as I can
bottleneck is memory bandwidth rather than CPU cycles. Is this analysis correct? VC MFC Discussions Windows XP (1) PowerPoint (1) Windows 7 (1) Vista (1) XP (1) CMemoryMapFile (1) MapViewOfFile (1) GlobalMemoryStatus (1) Geez, and here based on your L1 / L2 / L3 cache accessses, whatever they may be. joe * ** * Joseph M. Newcomer [MVP] email: newcomer@flounder.com Web: http: / / www.flounder.com MVP Tips: http: / / www.flounder.com / mvp_tips.htm the i7 is more than a clock speed and a memory speed. joe * ** * Joseph M. Newcomer [MVP] email: newcomer@flounder.com Web: http: / / www.flounder.com (1) Machine A performs process B in X d tell us he did not need to understand that. Sad, really. joe * ** Joseph M. Newcomer [MVP] email: newcomer@flounder.com Web: http: / / www.flounder.com MVP Tips: http: / / www.flounder.com / mvp_tips.htm
8301-13860_3-20004109-56.htm Mike P VC MFC Discussions Microsoft Exchange (1) Joseph M. Newcomer (1) Windows 7 (1) Outlook (1) Python (1) Oracle (1) Perl (1) NNTP newsgroups (1) This is days). Anyone who demands to use their Web site it is sick. joe Joseph M. Newcomer [MVP] email: newcomer@flounder.com Web: http: / / www.flounder.com MVP Tips: http: / / www.flounder.com / mvp_tips.htm site, and only a moron would use it to replace a simple joe Joseph M. Newcomer [MVP] email: newcomer@flounder.com Web: http: / / www.flounder.com MVP Tips: http: / / www.flounder.com / mvp_tips.htm any adult supervision is not a good combination for producing quality interfaces. joe * ** Joseph M. Newcomer [MVP] email: newcomer@flounder.com Web: http: / / www.flounder.com MVP Tips: http: / / www.flounder.com / mvp_tips.htm
it was design purely for WIN32 and never had to worry about the version of windows users had. That seem to change now. So I guess, the deeper questions and answers WPF over MFC? - - HLS VC MFC Discussions SQL Server (1) Visual Studio (1) Silverlight (1) Windows 7 (1) Office (1) Linux (1) Adobe (1) Perl (1) I am using the RC how to build a text editor!), and everything else is much better. joe Joseph M. Newcomer [MVP] email: newcomer@flounder.com Web: http: / / www.flounder.com MVP Tips: http: / / www.flounder.com / mvp_tips.htm no meaningless dependencies introduced in the build. I find this deeply offensive. joe Joseph M. Newcomer [MVP] email: newcomer@flounder.com Web: http: / / www.flounder.com MVP Tips: http: / / www.flounder.com / mvp_tips.htm in VS2010. VS2010 has the VC6-style ClassWizard, a welcome-back addition. It also has Windows 7-oriented enhancements to MFC. And an MFC ribbon designer (for the ribbon that debuted machine to run it. Build times are pretty quick. MFC is a GUI framework, requiring Windows. WPF is a GUI framework requiring .NET. WinForms is another GUI framework requiring .NET. WPF
UTF-8, it is more likely to be UTF-16 (this is the case for Windows) as UTF-16 is more space efficient than UTF-8 when support for non-Latin the native Chinese programmers, so they were lost on me even then. joe * ** * Joseph M. Newcomer [MVP] email: newcomer@flounder.com Web: http: / / www.flounder.com MVP Tips: http: / / www.flounder.com / mvp_tips.htm an important measure), the whole design seems just flat-out wrong. joe * ** * joe * ** ** Joseph M. Newcomer [MVP] email: newcomer@flounder.com Web: http: / / www.flounder.com MVP Tips: http: / / www.flounder.com / mvp_tips.htm the noise". We used to worry about optimizing things that actually MATTERED. joe Joseph M. Newcomer [MVP] email: newcomer@flounder.com Web: http: / / www.flounder.com MVP Tips: http: / / www.flounder.com / mvp_tips.htm have confirmed my original decision to use UTF-32 as my internal representation, and MS Windows only has a 16 bit std::wstring. Writing such a free function is not rocket