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 29, 2007 at 6:20PM  

    Actually, I think there is more to this scenario that is described.  

    IE: The thread scheduler seems to be a little wonky.

    Why do I say this?  Simple. Take a dual core machine running idle, say both cpus below 10% usage.  Now, run a single threaded task that is exceptionally CPU intensive.  

    What would you expect to see?  One CPU at 10%, the other CPU at 100%.  What do you actually see?  Usually both CPUs peaked.

    Tells me that the thread scheduler is doing something very very strange making it that much harder to get your 10ms job done in time.

  2. Posted on: October 29, 2007 at 6:48PM  

    Winamp's solution to glitching is to move it's process priority up to High, thus ensuring even if another process starts hogging the CPU, winamp will still be allocated the CPU time it needs.

    It works because Winamp also manages to keep its CPU usage low.  If it didn't, it could slow down or hang the entire OS when it ran (not a desirable outcome).

    At this point I would like to stop presenting useful information and blow some steam in a bit of a rant, FYI.  You can stop reading now if you want to.

    Of course, all of Vista's work on multimedia glitches is moot from my point of view since nVidia stopped supporting my integrated audio (nForce 2) starting with Vista, the drivers Microsoft provides are botched (sound continuously glitches regardless of CPU load or other factors).  The nForce XP drivers don't work either (same sound problem).

    The odd thing is I used to have the same problem on XP with both Microsoft and nVidia made drivers but then it went away with an nVidia driver update.

  3. Posted on: October 29, 2007 at 6:50PM  

    Xepol: That tells me that Windows is actually somehow running the single threaded process on both cores.

    This indicates one of the following (to me at least):

    - 1) It's not actually single threaded

    - 2) The CPU display is lying

    - 3) I accidentally ran the process twice

    My fix would probably be to try again but this time lock the process into a specific processor affinity, limiting it to one core.

  4. Posted on: October 29, 2007 at 9:15PM  

    "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"

    You won't convince me that in today's machines (and even the ones a little older), a sound card can't buffer more than 10 milliseconds worth of sound. I'd like some explanations on this one!

  5. Posted on: October 29, 2007 at 9:32PM  

    <b>Hey slimCODE </b> -

    Great comment.  You are correct that buffering more data is relatively trivial and could easily solve many classes of glitching issues... however, this buffering also comes with a significant cost: increased latency.

    Increased latency can also cause serious issues for communications apps, games, and pro/prosumer audio applications, so 10ms is a sort of middle ground -- and this is still too high for many applications such as pro recording apps.

    Also, there are many ill-behaved device drivers in use today that may occasionally lock out the CPU for, in some extreme cases, even hundreds of milliseconds.  

    I'll get more into these issues in my second post in this series.

    -Steve

    * * *  

  6. Posted on: October 29, 2007 at 9:42PM  

    Hey Xepol -

    The general consenus is that we need more data to actually understand what you are seeing on your dual core hardware.  

    From LarryO, regarding your comment:

    “Without more information on what your compute bound thread is doing, there’s no way of explaining what is going on in your application.  If you’d care to provide us with a code sample that demonstrates the behavior you’re describing, we’d be more than happy to look at it to see if we can understand why you’re seeing the behavior you’ve described.  

    In general, Windows tries to schedule each thread on the last processor on which it ran, but that logic can be defeated by actions taken by the thread."

    Hope this helps!

    -Steve

  7. Posted on: October 29, 2007 at 10:09PM  

    Try this:

    Press CTRL+ALT+DEL to display those screen with options like task manager, etc.

    Then place your mouse pointer over "Cancel" (while you're listening some music), click and press CTRL+ALT+DEL again, and click, and CTRL+ALT+DEL again, etc.

    A lot of sound glitches, no?

    Even if your player is with HIGH priority, I think is something with Vista itself and the new audio management.

    I hear a small glitch when I resume from blank screen (after 10 minutes idle).

  8. Posted on: October 29, 2007 at 10:15PM  

    I experience a bit of "glitching" on VISTA Media Center - just with the picture, not the sound.  I am using a AMD 4600+ with 4GB RAM, VISTA Home Premium 64 bit. My TV tuner is an ATI TV Wonder 650 PCI.  Everything works well, except I do notice a bit of stuttering  when I have a flash intensive website open at the same time.  Anyone else experience this sort of behaviour?

  9. Posted on: October 30, 2007 at 1:01AM  

    Hey Kittyburgers,

    I know I haven't had any experience yet with the 64bit version of Vista Home Premium, but I would say that its the CPU when im running WMP11 and heavy intensive games eather on the computer itself or even on the net my computer to seem sluggish. I know its not the exact same problem but I know what your going threw. I heard that 64 bit was a hassle anyways from the get go.

  10. Posted on: October 30, 2007 at 1:52AM  

    I agree that playing music without glitches is a difficult task, but I honestly believe that this has been solved many years ago. The last time I remember my MP3s glitching was back when I had a P75mhz (which should be of no surprise). The only other time I had my MP3s glitch was when I upgraded my PC to Vista. This same machine (exact same hardware) which had XP running on it, *never* had an MP3 glitch. On Vista, sound **constantly** glitched. Merely scrolling web pages caused sound issues.

    Obviously the problem is most likely poor driver support in combination with the re-arch of sound/video in Vista (and sprinkle in some DRM).

    Those are the true reasons why Vista has a poor multimedia experience (don't get me started on video).

    Because honestly my mobile phone can play MP3s, while I surf the web, on a call and text message; all without any glitches.

    Plus my PC with the exact same hardware running multiple OSes, only Vista seems to have issues with playback (even OSes running in Virtual PC do better).

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 &quot;glitching&quot; issues in Vista . I can&#39;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&#39;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