An Overview of Windows Sound and Music "Glitching" Issues

The following post comes from my colleague Steve Ball, Senior Program Manager for Sound in Windows Vista, and continues his team's on-going series on how Windows Vista treats various forms of audio.

-----

Part I: Why does my Windows sound sometimes "glitch?"

Windows is a rich and complex OS designed for multi-tasking users whose tasks must share access to scarce system hardware and resources.  Unfortunately, despite multiple decades of incredible advances in PC and CPU architectures, there are non-trivial, complex interactions between applications, processes, and devices in even the most advanced personal computers that make a supposedly "easy" task -- like playing back music without occasional glitches -- much more difficult than it may seem at first glance.

Another way of thinking about this:  it seems odd that a modern >$2000 PC may sometimes have trouble seamlessly playing back music when $20 CD players can effortlessly playback music without glitches. 

So why do many $2000 PCs occasionally glitch while playing back music?  The quick answer is this:  Windows is not a single-function device like a CD player.

A slightly longer answer goes like this:  even an average Windows machine today is commonly used simultaneously as a media player, word processor, presentation projector, spreadsheet number cruncher, authoring tool, photo editor, media server, video recorder, music composition tool, communications device, search engine, virus detector, data compressor and decompressor, and backup manager.  And these are only a few of the possible tasks and processes that are run at the same time on the hundreds of millions of Windows machines that are in use today.  Each of these tasks or processes, in isolation, would hardly tax the resources of modern PC hardware.  But in our multi-tasking world, unavoidable resource conflicts do sometimes occur between the huge and diverse ecosystem of Windows hardware that enables these tasks.  Even on the most expensive, brand-new machine, occasional glitches can occur if and when the system attempts to divide its finite resources among these multiple, diverse, independent, power-hungry activities.

What is a glitch?

A glitch is a perceivable error, gap or pop in the sound caused by discontinuities in the audio signal during playback or recording which result from processing or timing problems.  Glitches during music playback can sound like a loud "pop" or like a brief slice of silence randomly inserted where your music should have been.  Some customers have also described what "glitching" in their own words as:

  • audio stops a little bit
  • breaks up
  • choppy
  • clicking
  • corruption
  • crackle/crackling/crackly
  • interruption
  • jitters
  • jumpy
  • skipping/skip/skips

For the purpose of this discussion, let's lump all of these descriptions together under one general class of problems and call these "glitching."  While a glitch that happens during music playback can be annoying and unsettling, a glitch that occurs while you are recording or communicating with someone can result in frustrating and unacceptable data loss.

What causes my Windows sound and music to glitch?

Digital media processing is time-sensitive.  Playback requires specific work to be performed by a given deadline -- otherwise presentation or data loss can occur.  A "glitch" occurs when a deadline for time-sensitive processing is missed or when time-sensitive data is lost.

For example, in Windows Vista, playing back music involves "work" that must be done at least every 10 milliseconds so that there can be a continuous stream of music out to your speakers.  The "simple" task of playing back music consists of the following steps, all of which must be completed before a strict deadline:

  1. a small chunk of data from a music file needs to be read from a disc (CD or hard drive)
  2. this data needs to be "decompressed" or "decoded" (usually in system memory) so it can be streamed out to your speakers in a format that your sound hardware understands
  3. the decompressed sound data needs to be copied from system memory to your sound hardware memory
  4. the data in your sound hardware needs to be sent to your speakers at the appropriate time
  5. repeat steps 1-4 flawlessly every 10 milliseconds (ms)

In this example, if any of these steps aren't completed on time, then the user could hear a glitch in the music playback.

Elliot Omiya, Architect on the Sound dev team, puts this 10ms cycle into perspective:  "it's just slightly longer than the time it takes a nerve impulse to travel from the end of your finger to your brain (~8ms), known as NCV (nerve conduction velocity).  Because synapses are like network switches, there is switching time involved before the nerve impulse gets to the brain, i.e., switching time adds to latency."

There is some good news in this story:  Windows developers have made significant progress over the years in reducing glitching across key multimedia scenarios.  For example, music playback on an otherwise "lightly loaded" system can be generally as smooth as that $20 CD player.

But because of the multi-tasking nature of Windows and the vast array of new and legacy hardware in the ~1B PCs that are used to playback music today, this allegedly simple process is made more complex by the resource sharing that occurs between applications and hardware.  For example, it is not uncommon for certain older devices driver to occasionally "lock out" the CPU for 10-50ms, thereby causing obvious audio glitches.  This is just one example of the kinds of complex hardware, driver, and OS interactions that can cause glitches.

In summary, some of the common sources of glitches today include:

  • CPU starvation
  • GPU starvation
  • Resource contention from devices and drivers (sometimes called "IO contention")
  • Network devices
  • And, of course ... bugs in applications, OS, drivers and/or hardware

My colleague on the Windows Sound team, Larry Osterman, also pointed out to me recently that humans are actually "hard-wired" to be disturbed by audio glitches.  In an exchange about this topic, Larry observed that audio glitches are more obvious than video glitches because the ear's tuned to notice high frequency transients -- his visceral example of this idea is an image of a stick snapping in the woods behind you as an audio event that wakes you up before a bear wanders into your path. 

In my second post on this topic, I'll go a bit deeper in sharing details of work we’ve done in Windows Vista to address some of the known sources of potential sound glitches, including some additional background about a recent discovery of an apparent connection between multimedia playback and network throughput.

I wish to acknowledge the contributions and suggestions from my colleagues Hakon Strande, Richard Fricks, Alex Ferreira, Lan Ye, Larry Osterman and Elliot Omiya for this series of posts.


Comments

  1. Posted on: October 30, 2007 at 3:34AM  

    All I do know that while Vista is *supposed to* suck less than XP for audio, it definitely sucks more than OS X's Core Audio or Linux's ALSA/JACK. MS is so enterprise-focussed that they ignore audio and video pros who're in minority compared to business users worldwide.

  2. Posted on: October 30, 2007 at 5:47AM  

    My thoughts exactly, atehrani.

    I don't suppose we're going to see the good, ol', free-from-DRM Sound Stack from Windows XP being reintroduced in Vista SP1?

  3. Posted on: October 30, 2007 at 11:07AM  

    slimCODE: To slightly elaborate on what Steve said, more buffering == more delay between what you see on the screen and what you hear.

    For example, if there is a 1s buffer, when you play music it will take 1 second until you start hearing music.  If you hit pause or stop music will continue playing for an extra second before it pauses or stops.

    Videos will be ~990ms out of sync (unless the video app offers a method to resync audio and video) because it expects the 10ms buffer and you create a huge compatibility problem for ALL programs there.  Of course it wouldn't surprise me if many video apps don't compensate for the 10ms... it's not noticeable anyways.

    Then we have games, where the audio is dynamically generated based on what happens in the world... because of this there is no way to predict in advance what sound effects should be playing.  So you end up with enemies firing at you with no appropriate sound effects playing until 1 second later.  Good for a sci-fi game where the speed of sound has been drastically slowed by some inexplicable occurrence, but not much else.

    There are actually some programs (I know a couple game console emulators) which allow you to adjust a software audio buffer size... this can be done to demonstrate that the audio easily becomes noticeably out of sync with the video with larger buffer sizes.  And the reason usually these programs allow adjustment is to let you balance the delay from longer buffers with hitching from shorter ones (ideally you'd experiment to find the shortest buffer that doesn't hitch).

    Erwin: That menu is intentionally processed ahead of music data because if your computer is slowed down by a CPU hogging app, you still want C+A+D to respond fast.  So it goes above all other processes (or so I imagine) and so you might get some hitching.

    However repeatedly pressing C+A+D and dismissing the dialog is not something many users will be doing often, so if that is the best you can come up with I guess Vista doesn't handle multimedia TOO badly...

  4. Posted on: October 30, 2007 at 3:29PM  

    I get glitches when media player switches from one song to next if I *Enable Enhancements* for my sound card. My sound card is *Sigmatel High Definition Audio CODEC* and here is screenshot of what I am talking about - http://i33.photobucket.com/albums/d74/chaks_2k/vista-sound-enhancements.png. The screenshot shows that the Enhancements are disabled.

    Any idea why is this happening? I have installed up-to-date Vista SP1 Pre Patches and also checked this installing SP1 Beta. The problem still persists.

    Regards,

    Chakkaradeep

  5. Posted on: October 30, 2007 at 4:45PM  

    To “The MAZZter”:

    Thanks for your comments.

    1) WinAMP could use the Multimedia Class Scheduler (sometimes abbreviated MMCSS) in Vista - it automatically provides guaranteed CPU time slices through special thread priority mechanisms to media apps without the need to fight for priority with other non-media apps.

    2) All of Vista's improvements to the audio pipeline are IMO not moot for the millions of Vista users who have Vista logo compliant PC hardware. The nForce2 is based on a legacy integrated audio device technology called AC-97 which is now replaced in Vista Logo’d systems with what Intel ships as “HD Audio” hardware. “HD Audio” is the name of a hardware specification and is an evolution of the older AC-97 standard. It allows higher quality audio from integrated solutions (when designed well) and also enables the Microsoft WaveRT audio driver model which is among the innovations in  Windows Vista that helps enable audio driver (and thus system) stability, lower roundtrip latency and improved glitch resilience.

    3) Yes, bad kernel mode drivers can still starve the Windows OS audio pipeline by holding the system off for tens or even several hundreds of  milliseconds in long DPCs/ISRs but the culprit can be the storage driver, the network driver, the modem driver, the graphics drivers, the virus scanner, etc - just as easily as the audio driver.

    4) nVIDIA made a business decision to not support your system’s chipset for Windows Vista and that is their prerogative. Many OEMs and ODMs make similar decisions in the system or device context when a new OS arrives. If your OEM does not support the new OS on your system (i.e they do not have drivers for the new OS on their web site) that may be a motivation to stick with your current OS until you get a new machine that has the Microsoft stamp of approval for that OS; the Designed for Windows Vista Logo in this case. The logo is our only way to tell the consumer that the machine has been tested to a certain degree with the new OS and enables the experiences and the SW innovation in this new OS. Look for the Windows Vista logo on the device and system to ensure you get the best Windows Vista experience.

    5) BTW, there is no "Microsoft" audio driver for the nForce2 Audio Processing Unit. All audio driver software for that chipset comes from nVIDIA and the drivers are Windows XP tested and certified only.

  6. Posted on: October 30, 2007 at 11:12PM  

    Here is the solution for music playback:

    - Decode the entire music file (or at least a big chunk of it)

    - Send the entire thing into soundcard/system memory (no latency here... takes no time to copy a few megabytes)

    - Tell the soundcard to play it

    - Soundcard plays the music with no interaction with the O/S, uses DMA etc to read from memory

    - O/S sends messages to soundcard to stop/start playback etc.

    Now, presumably we would need new APIs to do this, and there will be other problems, but essentially I can't see why this can't be accomplished. Soundcards used to even have embedded memory... should be able to use it for asynchronous MP3 playback!

  7. Posted on: October 31, 2007 at 12:09AM  

    Steve - Thanks for posting this article.. I'm hoping that in the second part of the series you will mention how and why "glitching" is appearing (sounding) on Windows Vista computers when those same exact computers when Windows XP was installed had no issues with sound quality.

    Previous to Windows Vista, i had rarely - if ever experienced glitching - be it on a brand new machine, or an old machine on its way out, and the times it did occur, it occured when many programs were open or the computer was going through a processing intensive task... Now on my Windows Vista machine it occurs when i scroll in internet explorer, alt+tab between programs, and many other non-trivial things..

    You can go on and on about how vista is more complex than XP, and programs take up more memory, etc.. but quite honestly what it comes down to is this - for a RTM operating system from microsoft to experience these issues on a daily and regular basis during trivial actions - even on a brand new computer - that is completely unacceptable.

  8. Posted on: October 31, 2007 at 7:19AM  

    I never experienced glitching in music or sound playback until Windows Vista. The article above states that a "Windows machine today is commonly used simultaneously as..." listing many functions. No machine has EVER been used simultaneously for all those things.

    When MS first announced that Vista could guarantee glitch-free media playback because of new kernel scheduling APIs my first thought was "what glitching?" since I'd never experienced it outside of DOS on slow machines. Now ironically, with Vista, I do get that wonderful experience. On a new PC.

  9. Posted on: October 31, 2007 at 8:31AM  

    My have no qualms about Vista except when it comes to how it handles audio, specifically its speaker management.

    I have a 6.1 speaker system that I used successfully in XP. When I got a new Vista computer, I installed my sound card into the new computer and updated my drivers. However, I am only able to use 2 front speakers and I can't utlize the other speakers.

    Everytime, I tried to set the speakers options to 5.1 and attempt to test the speakers, the sound would crap out and the options would revert to stereo instead of 5.1. (Unfortunately, there is no 6.1 option even though I have a 6.1 speaker system. )

    Microsoft's stance on this kind of subject is that the fault of the driver and the manufacturer (Creative in this case) needs to update the driver. Unfortunately, Creative has updated its driver in March 2007, so either they updated their drivers but they didn't address my specific problem, or Microsoft changed the audio architecture so much that audio manufacturers CAN'T fix these finds of problems. It has to come from Microsoft.

  10. Posted on: October 31, 2007 at 12:13PM  

    Jtu100, that works as long as nobody would ever listen to a larger music file.. say.. a 200-megabyte live mix.

Trackbacks

  1. Posted by: Larry Osterman's WebLog on October 30, 2007 at 7:49PM

    Nick White over at the Windows Vista Blog just posted an article written by Steve Ball , the PM in charge

  2. Posted by: Noticias externas on October 30, 2007 at 8:25PM

    Nick White over at the Windows Vista Blog just posted an article written by Steve Ball , the PM in charge

  3. Posted by: Where are we going, and what's with the handbasket? on October 31, 2007 at 4:29AM

    Steve Ball posted an article about some "glitching" issues in Vista . I can't resist adding my two cents.

  4. Posted by: Noticias externas on October 31, 2007 at 4:39AM

    Steve Ball posted an article about some "glitching" issues in Vista . I can't resist adding

  5. Posted by: Microsoft on January 09, 2008 at 4:31PM

    Steve Ball of Microsoft has a very interesting blog started on the Windows Vista Blog site about audio

  6. Posted by: pcpartfinder on January 31, 2008 at 7:59PM

    Last fall , Steve Ball, Microsoft's program manager for sound in Vista, posted a blog entry explaining

  7. Posted by: how to sell digital products on ebay on July 17, 2008 at 11:02AM

    Fujifilm is one of the leading providers of imaging and information products. Fujifilm and its employees are committed to providing consumers and professionals with the most innovative and highest- quality imaging and information products and services.

  8. Posted by: Pulse Audio on Ubuntu.Working Fine for you? - Page 2 - Open Source - TechEnclave on March 07, 2009 at 1:01AM

    Pingback from  Pulse Audio on Ubuntu.Working Fine for you? - Page 2 - Open Source - TechEnclave