<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>The Audio Fool : Audio</title><link>http://blogs.msdn.com/audiofool/archive/tags/Audio/default.aspx</link><description>Tags: Audio</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>You can't hear DC</title><link>http://blogs.msdn.com/audiofool/archive/2007/06/21/you-can-t-hear-dc.aspx</link><pubDate>Thu, 21 Jun 2007 20:00:58 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3445707</guid><dc:creator>RyanBemrose</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/audiofool/comments/3445707.aspx</comments><wfw:commentRss>http://blogs.msdn.com/audiofool/commentrss.aspx?PostID=3445707</wfw:commentRss><description>&lt;p&gt;Recently one of my team members found a bug in some old code while doing a code review.&amp;nbsp; Our application was generating a sine wave to be rendered by the audio hardware.&amp;nbsp; The sample format isn't important except to note that it is an unsigned value between 0 and MAX = 2*FS_AMP.&amp;nbsp; The bug is in the following code.&lt;/p&gt; &lt;table cellspacing="0" cellpadding="2" width="574" border="0" unselectable="on"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign="top" width="572"&gt; &lt;p&gt;void GenerateSineWave(float buffer[], float frequency, float amplitude) {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // frequency in Hz, amplitude in range(0.0, 1.0)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; float w = 2 * PI * frequency / SAMPLE_RATE;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for&amp;nbsp;(int t = 0; t &amp;lt; NUMBER_OF_SAMPLES; t++)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; float sample = sin(w * t) * FS_AMP //&amp;nbsp;full scale sine wave&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sample += FS_AMP; // Move into positive range&amp;nbsp;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sample *= amplitude;&amp;nbsp; // Scale to&amp;nbsp;requested amplitude&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; buffer[t] = sample;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;}&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;So do you see the bug?&amp;nbsp; After this code, we have a sine wave that oscillates between 0 and 2*amplitude*FS_AMP.&amp;nbsp; For amplitude = 1.0, this is exactly what we want, but for any smaller amplitude, the wave is low-justified in the sample range.&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/9329c0513632_786A/smsin_bottom_2.png" atomicselection="true"&gt;&lt;img height="115" alt="smsin_bottom" src="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/9329c0513632_786A/smsin_bottom_thumb_2.png" width="579"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;What we really wanted here is a signal that is center-justified in the range, such as below.&amp;nbsp; We were sending the wrong samples!&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/9329c0513632_786A/smsin_ctr_1.png" atomicselection="true"&gt;&lt;img height="115" alt="smsin_ctr" src="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/9329c0513632_786A/smsin_ctr_thumb_1.png" width="579"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;The fix is fairly simple.&amp;nbsp; We want to scale (*= amplitude) before we translate (+= FS_AMP).&amp;nbsp; Then we get a sine wave that oscillates between (FS_AMP *(1-amplitude)) and (FS_AMP * (1+amplitude)).&lt;/p&gt; &lt;p&gt;After fixing a bug in old code, the next question we have to ask ourselves is why we missed it.&amp;nbsp; How come this bug wasn't found in&amp;nbsp;a test pass when it was written, or any time in between?&amp;nbsp; The answer is almost as subtle as the code that caused the problem.&amp;nbsp; From an audio perspective, the bug had no impact at all.&lt;/p&gt; &lt;p&gt;The buffer generated by this buggy code was sent directly to the DAC on the hardware.&amp;nbsp; The signal does not clip, and it's not distorted.&amp;nbsp; All of the sine components are the same.&amp;nbsp; If you got an FFT on each of the two sine waves above, they would differ only in the very first bin, the one corresponding to the DC component of the signal.&lt;/p&gt; &lt;p&gt;But you can't hear DC.&lt;/p&gt; &lt;p&gt;DC is essentially the baseline for a signal.&amp;nbsp; The value from which the signal wave deviates in time.&amp;nbsp; The measured level of silence.&amp;nbsp; For a speaker, the DC level is the distance of the cone when unplugged.&amp;nbsp; For the atmosphere, DC is about 14psi (or 1.0 atm) at sea level.&lt;/p&gt; &lt;p&gt;For a digital signal stored as numbers, DC can be any arbitrary value.&amp;nbsp; In a computer which have a fixed minimum and maximum, we usually choose&amp;nbsp;halfway between min and max because it offers the most dynamic range.&amp;nbsp;&amp;nbsp;This also explains why most audio formats use signed numbers for samples rather than unsigned.&amp;nbsp;&amp;nbsp;The center of the allowed range for a signed number is zero, and&amp;nbsp;zero is a very easy number to work with.&amp;nbsp; In the code&amp;nbsp;snippet above, the bug would not manifest if we were using signed numbers, because the translation step for signed numbers is a no-op.&lt;/p&gt; &lt;p&gt;One other way of looking at DC is as a wave with frequency zero, and an infinite wavelength.&amp;nbsp; Since zero is below the lowest frequency a human can hear (about 20Hz), you can't hear it.&amp;nbsp;&amp;nbsp;Q.E.D.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Epilogue&lt;/strong&gt;:&amp;nbsp;This bug &lt;em&gt;does&lt;/em&gt; show up as a frequency component any time we dynamically alter the amplitude while streaming,&amp;nbsp;so we fixed&amp;nbsp;it.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3445707" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/audiofool/archive/tags/Audio/default.aspx">Audio</category><category domain="http://blogs.msdn.com/audiofool/archive/tags/Programming/default.aspx">Programming</category></item><item><title>More posts eventually!</title><link>http://blogs.msdn.com/audiofool/archive/2007/03/05/more-posts-soon.aspx</link><pubDate>Tue, 06 Mar 2007 05:09:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1813863</guid><dc:creator>RyanBemrose</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/audiofool/comments/1813863.aspx</comments><wfw:commentRss>http://blogs.msdn.com/audiofool/commentrss.aspx?PostID=1813863</wfw:commentRss><description>&lt;p&gt;It's that time of year, it seems.&amp;nbsp; I was down with the flu last week, and I'm 
trying desperately to catch up this week.&amp;nbsp; I promise I'll get more posts up 
soon.&amp;nbsp; I'm doing some WASAPI playback library stuff right now and I'm just dying 
to do a couple of articles about the new Vista audio APIs.&amp;nbsp; I'm also trying to 
figure out a way to work in some more usability stuff.&lt;/p&gt;&lt;p&gt;Meanwhile, to keep you occupied, here's a pretty cool demo of Vista's speech recognition engine.&amp;nbsp; The guy in the video is trying to program perl - a task for which Vista SR is clearly not designed.&amp;nbsp; He is apparently trying to make Vista look bad, but to me he really only manages to make himself look silly.&amp;nbsp; From the video one can immediately conclude two things:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Vista Speech Recognition is really quite good for documents and conversation.&lt;/li&gt;&lt;li&gt;For programming, stick to the keyboard.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;(Warning: NSFW.&amp;nbsp; Contains F-bombs and other colorful verbal frustruation as the protagonist tries to make the parsing engine emit perl-shaped line noise.&amp;nbsp; If you're at work, time to put on the headphones.)&lt;br&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.youtube.com/watch?v=MzJ0CytAsec" mce_href="http://www.youtube.com/watch?v=MzJ0CytAsec"&gt;http://www.youtube.com/watch?v=MzJ0CytAsec&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1813863" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/audiofool/archive/tags/Audio/default.aspx">Audio</category><category domain="http://blogs.msdn.com/audiofool/archive/tags/Windows/default.aspx">Windows</category><category domain="http://blogs.msdn.com/audiofool/archive/tags/Humans/default.aspx">Humans</category><category domain="http://blogs.msdn.com/audiofool/archive/tags/Usability/default.aspx">Usability</category></item><item><title>Digital Audio: Aliasing</title><link>http://blogs.msdn.com/audiofool/archive/2007/02/15/digital-audio-aliasing.aspx</link><pubDate>Fri, 16 Feb 2007 07:26:15 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1686952</guid><dc:creator>RyanBemrose</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/audiofool/comments/1686952.aspx</comments><wfw:commentRss>http://blogs.msdn.com/audiofool/commentrss.aspx?PostID=1686952</wfw:commentRss><description>&lt;p&gt;Sampling a continuous waveform into discrete digital samples results in lost information.&amp;nbsp; Discrete samples can only tell what the wave is doing at periodic instants in time, and not what's happening between them.&amp;nbsp; The continuous sampled wave could be doing anything between samples.&amp;nbsp; We simply don't know.&amp;nbsp; &lt;/p&gt; &lt;p&gt;The problem here is that when we want to get back the data that we threw away and turn samples back into a continuous wave, we must interpolate between samples&amp;nbsp;to find the lost information.&amp;nbsp; Unfortunately, there are an infinite number of signals that could have produced the samples that we want.&amp;nbsp; Fortunately, if we accept a small restriction on our continuous waveform, we can get back to one unique signal.&amp;nbsp; &lt;/p&gt; &lt;p&gt;I think an example is in order.&amp;nbsp; Consider the&amp;nbsp;7kHz sine wave&amp;nbsp;below, shown over a 1ms interval.&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/DigitalAudioAliasing_10B47/sin_7cycles%5B23%5D.png" atomicselection="true"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="141" src="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/DigitalAudioAliasing_10B47/sin_7cycles_thumb%5B23%5D.png" width="500" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;If we sample this sine wave with a sampling rate of 10kHz, we get 11 samples in this interval (counting the endpoints), as shown below.&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/DigitalAudioAliasing_10B47/sin_7cyc_samp%5B3%5D.png" atomicselection="true"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="141" src="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/DigitalAudioAliasing_10B47/sin_7cyc_samp_thumb%5B3%5D.png" width="500" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;But when we play back these samples, you won't get 7kHz out of the speaker.&amp;nbsp; What you hear is the 3kHz wave described by the red curve below.&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/DigitalAudioAliasing_10B47/sin_7_3cyc_samp%5B1%5D.png" atomicselection="true"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="141" src="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/DigitalAudioAliasing_10B47/sin_7_3cyc_samp_thumb%5B1%5D.png" width="500" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;So what happened?&amp;nbsp; Notice that both curves produce exactly the same samples, when sampled at 10kHz.&amp;nbsp;&amp;nbsp;At&amp;nbsp;this sample rate, there is no way to tell the difference between&amp;nbsp;3kHz, 7kHz, or&amp;nbsp;even the 13kHz wave below.&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/DigitalAudioAliasing_10B47/sin_7_3_13cyc_samp%5B1%5D.png" atomicselection="true"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="141" src="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/DigitalAudioAliasing_10B47/sin_7_3_13cyc_samp_thumb%5B1%5D.png" width="500" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;This effect is known as &lt;em&gt;aliasing&lt;/em&gt;, and these frequencies are &lt;em&gt;aliases&lt;/em&gt; of each other.&amp;nbsp; In fact, for any frequency &lt;em&gt;f&lt;/em&gt; and sample rate S, all frequencies of the form (N*S ± &lt;em&gt;f&lt;/em&gt;) for some integer N&amp;nbsp;are aliases.&lt;/p&gt; &lt;p&gt;There is hope, though.&amp;nbsp;&amp;nbsp;For given &lt;em&gt;f&lt;/em&gt; and&amp;nbsp;S,&amp;nbsp;there is one unique frequency of the type (N*S ± &lt;em&gt;f&lt;/em&gt;) that is between 0 and S/2.&amp;nbsp;&amp;nbsp;Looking at the samples in the example above, the 3kHz wave is between zero and half the sampling rate.&amp;nbsp; No other frequency between&amp;nbsp;0 and 5kHz can be produced from&amp;nbsp;those samples, and the wave is unique.&amp;nbsp; The frequency S/2, called the &lt;em&gt;Nyquist frequency&lt;/em&gt;, is the upper limit of alias-free signal frequency.&lt;/p&gt; &lt;p&gt;All of the information lost from sampling a continuous waveform has a frequency higher than S/2.&amp;nbsp; Therefore, the process of sampling is lossless, as long as all of the frequencies&amp;nbsp;you're interested in&amp;nbsp;are below half the sample rate.&lt;/p&gt; &lt;p&gt;But wait, you may ask.&amp;nbsp; What if you're interested in preserving higher frequencies?&amp;nbsp; Just increase the sample rate to more than twice the highest frequency you're interested in.&amp;nbsp; The human ear can hear frequencies of up to about 20kHz, and it's no coincidence that CD Audio samples at 44.1kHz, providing bit-perfect representation of any frequency humans can hear.&lt;/p&gt; &lt;p&gt;There is one more problem when sampling.&amp;nbsp;&amp;nbsp;Sampling just your frequencies of interest isn't always enough.&amp;nbsp; High frequencies don't just go away when you sample.&amp;nbsp;&amp;nbsp;This &lt;em&gt;out-of-band noise&lt;/em&gt; (Noise because it's not part of the signal we want to preserve) in your continuous signal will still be sampled, only now it will alias down below S/2 and contaminate the digital signal you want to keep.&lt;/p&gt; &lt;p&gt;For this reason, any time you sample a continuous signal, you &lt;strong&gt;must&lt;/strong&gt; first &lt;em&gt;band-limit&lt;/em&gt; the signal with a low-pass filter to block (&lt;em&gt;attenuate&lt;/em&gt;) all frequencies above the Nyquist frequency, so that there is no out-of-band noise at the sampling stage.&amp;nbsp; More on what that means in another post.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1686952" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/audiofool/archive/tags/Audio/default.aspx">Audio</category></item><item><title>Clipping in popular music</title><link>http://blogs.msdn.com/audiofool/archive/2007/02/07/clipping-in-popular-music.aspx</link><pubDate>Thu, 08 Feb 2007 01:44:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1622288</guid><dc:creator>RyanBemrose</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/audiofool/comments/1622288.aspx</comments><wfw:commentRss>http://blogs.msdn.com/audiofool/commentrss.aspx?PostID=1622288</wfw:commentRss><description>&lt;p&gt;Aside from the distortion artifacts, one of the biggest problems that&amp;nbsp;results from&amp;nbsp;&lt;a href="http://blogs.msdn.com/audiofool/archive/2007/01/09/audio-fidelity-clipping.aspx" mce_href="http://blogs.msdn.com/audiofool/archive/2007/01/09/audio-fidelity-clipping.aspx"&gt;clipping&lt;/a&gt; is a loss of dynamic range.&amp;nbsp; Remember that the dynamic range of a signal&amp;nbsp;is effectively the &lt;a href="http://blogs.msdn.com/audiofool/archive/2006/12/06/the-difference-between-measuring-dr-and-thd-n.aspx" mce_href="http://blogs.msdn.com/audiofool/archive/2006/12/06/the-difference-between-measuring-dr-and-thd-n.aspx"&gt;difference between the maximum output level and the noise floor&lt;/a&gt;.&amp;nbsp; When you clip a waveform, you lower the maximum sample value, which lowers the output level and reduces dynamic range.&lt;/p&gt; &lt;p&gt;This can happen especially when you amplify a signal.&amp;nbsp; Amplification increases all parts of a signal, including its noise floor and its maximum value.&amp;nbsp; Normally,&amp;nbsp;these two values increase by the same&amp;nbsp;amount, so the&amp;nbsp;ratio between them stays the same and&amp;nbsp;dynamic range is unaffected.&amp;nbsp; Unfortunately, a signal that is amplified too much has to clip at the top end, and that's when&amp;nbsp;DR suffers.&lt;/p&gt; &lt;p&gt;So the moral here is don't overamplify your music, right?&amp;nbsp; That seems easy enough.&amp;nbsp; The problem is that popular recording studios don't listen.&amp;nbsp; Recall that, superficially, &lt;a href="http://blogs.msdn.com/audiofool/archive/2007/02/07/louder-sounds-better.aspx" mce_href="http://blogs.msdn.com/audiofool/archive/2007/02/07/louder-sounds-better.aspx"&gt;louder music sounds better&lt;/a&gt;.&amp;nbsp; Better sounding music sells more discs, and so it pays for the studios to master their music as close to the clipping level as possible.&amp;nbsp; "But wait," the studio says,&amp;nbsp;"most people are tone-deaf anyway.&amp;nbsp; We can get it just a little louder than our competition if we clip&amp;nbsp;a little bit off of the peaks."&amp;nbsp; The competition responds in kind, clipping just a little more, and the result (as Larry &lt;a href="http://blogs.msdn.com/audiofool/archive/2007/01/09/audio-fidelity-clipping.aspx#1452180" mce_href="http://blogs.msdn.com/audiofool/archive/2007/01/09/audio-fidelity-clipping.aspx#1452180"&gt;scooped me&lt;/a&gt; on) is why popular music has terrible dynamic range.&lt;/p&gt; &lt;p&gt;The following articles tell the sad story far better than I can.&amp;nbsp; I encourage you to give them a read.&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.mindspring.com/%7Emrichter/dynamics/dynamics.htm" mce_href="http://www.mindspring.com/~mrichter/dynamics/dynamics.htm"&gt;http://www.mindspring.com/~mrichter/dynamics/dynamics.htm&lt;/a&gt;&amp;nbsp;(&lt;a href="http://www.cdmasteringservices.com/dynamicdeath.htm" mce_href="http://www.cdmasteringservices.com/dynamicdeath.htm"&gt;mirror&lt;/a&gt;)&lt;br&gt;&lt;a href="http://en.wikipedia.org/wiki/Loudness_war" mce_href="http://en.wikipedia.org/wiki/Loudness_war"&gt;http://en.wikipedia.org/wiki/Loudness_war&lt;/a&gt;&lt;br&gt;&lt;a href="http://www.prorec.com/prorec/articles.nsf/articles/8A133F52D0FD71AB86256C2E005DAF1C" mce_href="http://www.prorec.com/prorec/articles.nsf/articles/8A133F52D0FD71AB86256C2E005DAF1C"&gt;http://www.prorec.com/prorec/articles.nsf/articles/8A133F52D0FD71AB86256C2E005DAF1C&lt;/a&gt;&lt;br&gt;&lt;a href="http://www.austin360.com/music/content/music/stories/xl/2006/09/28cover.html" mce_href="http://www.austin360.com/music/content/music/stories/xl/2006/09/28cover.html"&gt;http://www.austin360.com/music/content/music/stories/xl/2006/09/28cover.html&lt;/a&gt;&lt;/p&gt; &lt;p&gt;And one of my favorite illustrations: &lt;a href="http://recforums.prosoundweb.com/index.php/mv/msg/4286/0/0/0/" mce_href="http://recforums.prosoundweb.com/index.php/mv/msg/4286/0/0/0/"&gt;http://recforums.prosoundweb.com/index.php/mv/msg/4286/0/0/0/&lt;/a&gt;&lt;/p&gt; &lt;p&gt;And now you know why serious audio aficionados stick to the classics.&amp;nbsp; :)&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1622288" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/audiofool/archive/tags/Audio/default.aspx">Audio</category></item><item><title>Louder Sounds Better</title><link>http://blogs.msdn.com/audiofool/archive/2007/02/07/louder-sounds-better.aspx</link><pubDate>Thu, 08 Feb 2007 01:12:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1587696</guid><dc:creator>RyanBemrose</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/audiofool/comments/1587696.aspx</comments><wfw:commentRss>http://blogs.msdn.com/audiofool/commentrss.aspx?PostID=1587696</wfw:commentRss><description>&lt;p&gt;Below is an example of the &lt;a href="http://en.wikipedia.org/wiki/Fletcher-Munson_curves" mce_href="http://en.wikipedia.org/wiki/Fletcher-Munson_curves"&gt;Fletcher-Munson Equal Loudness Curve&lt;/a&gt;.&amp;nbsp; It is one of the most recognized graphics in audio engineering.&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/LouderSoundsBetter_12855/FletcherMunson_EqualLoudness2.jpg" mce_href="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/LouderSoundsBetter_12855/FletcherMunson_EqualLoudness2.jpg" atomicselection="true"&gt;&lt;img src="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/LouderSoundsBetter_12855/FletcherMunson_EqualLoudness_thumb.jpg" style="border-width: 0px;" mce_src="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/LouderSoundsBetter_12855/FletcherMunson_EqualLoudness_thumb.jpg" border="0" height="365" width="470"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;The horizontal axis is frequency of tones, and the vertical axis is actual sound pressure in dBSPL.&amp;nbsp;&amp;nbsp;Each point on a curve has about the same subjective "loudness" to the human ear.&amp;nbsp; The low parts of the curves are the frequencies where the ear is more sensitive.&amp;nbsp; Conversely, the high parts are where the ear is less sensitive and it takes more pressure to get the same 'loudness'.&amp;nbsp; The dotted line at the bottom represents the threshold of hearing.&amp;nbsp; Any frequency below that line can't be heard at all by the average human.&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/LouderSoundsBetter_12855/fm_25_signal3%5B9%5D.png" mce_href="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/LouderSoundsBetter_12855/fm_25_signal3%5B9%5D.png" atomicselection="true"&gt;&lt;img src="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/LouderSoundsBetter_12855/fm_25_signal3_thumb%5B5%5D.png" mce_src="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/LouderSoundsBetter_12855/fm_25_signal3_thumb%5B5%5D.png" align="right" height="233" width="300"&gt;&lt;/a&gt;Consider an arbitrary waveform coming out of a speaker.&amp;nbsp; &amp;nbsp; That waveform has the frequency response shown in red on the diagram to the right.&amp;nbsp; The blue line is the same waveform amplified by 20dB, and the orange line is amplified by 80dB.&amp;nbsp; Notice that the louder signal aligns better with the flatter Fletcher-Munson curves at the top.&amp;nbsp; There is less variation in sound at different frequencies, and the result is that the louder signal has a richer, fuller sound.&lt;/p&gt; &lt;p&gt;The opposite is also true.&amp;nbsp;&amp;nbsp;For quieter sounds,&amp;nbsp;certain frequencies to which the ear is less-sensitive can seem to drop out of the signal, especially at very high and very low frequencies.&amp;nbsp;&amp;nbsp;The orange line&amp;nbsp;has a very powerful bass, with low frequencies staying close to the same&amp;nbsp;loudness as&amp;nbsp;the middle.&amp;nbsp; The blue line's&amp;nbsp;bass is much less 'loud' than the middle frequencies.&amp;nbsp; Many frequencies on the red line have completely dropped out, below the threshold of hearing.&amp;nbsp;&lt;/p&gt; &lt;p&gt;The&amp;nbsp;Fletcher-Munson curves illustrate&amp;nbsp;an audio engineering example of why, to the human ear, louder sounds better.&amp;nbsp; The higher the signal amplitude, the more frequencies are present,&amp;nbsp;making the signal richer and fuller.&amp;nbsp;&amp;nbsp;You can also read &lt;a href="http://mixonline.com/mag/audio_why_louder_sounds/" mce_href="http://mixonline.com/mag/audio_why_louder_sounds/"&gt;this article&lt;/a&gt;, which discusses it from an audio production and musician's point of view.&lt;/p&gt; &lt;p&gt;A&amp;nbsp;practical&amp;nbsp;result of this is that when a person tries to compare two sounds, the louder one will often subjectively sound better regardless of their relative signal quality.&amp;nbsp; Any time you want to compare sounds by ear objectively, you have to make sure they're the same level.&lt;/p&gt; &lt;p&gt;One final note:&amp;nbsp; I hope this post does a little bit to explain why people are drawn to loud concerts, or to turning headphones up to extremely high levels, but there's a very dangerous flip-side.&amp;nbsp; The orange line in my figure above peaks out at about 125dBSPL.&amp;nbsp; A concert at that level may indeed sound good, but it is also&amp;nbsp;at or above&amp;nbsp;the threshold of pain, depending on the listener, and any prolonged exposure will likely cause permanent hearing damage.&amp;nbsp; There are any number of guidelines about maximum safe listening levels, and I recommend you heed them.&amp;nbsp; That set of headphones may sound mighty fine cranked up to 90dBSPL, but they are also doing irreparable damage to one of your most important and finely tuned sensory organs.&amp;nbsp; Perhaps someday I'll do a post on exactly what happens when you destroy your auditory receptors.&amp;nbsp; Trust me, it isn't fun.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1587696" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/audiofool/archive/tags/Audio/default.aspx">Audio</category></item><item><title>Audio Fidelity: Clipping</title><link>http://blogs.msdn.com/audiofool/archive/2007/01/09/audio-fidelity-clipping.aspx</link><pubDate>Wed, 10 Jan 2007 01:30:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1440488</guid><dc:creator>RyanBemrose</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/audiofool/comments/1440488.aspx</comments><wfw:commentRss>http://blogs.msdn.com/audiofool/commentrss.aspx?PostID=1440488</wfw:commentRss><description>&lt;p&gt;In theory, an audio signal can take on any amplitude.&amp;nbsp; There is no mathematical upper limit for how far from zero a sample can go, or how high the magnitude of a continuous wave can go.&amp;nbsp; In practice, however, a digital signal's amplitude is limited by its number of bits, and even electrical components can only handle so much voltage without being damaged.&amp;nbsp; Every real-world device has some practical maximum value that the signal can attain.&amp;nbsp; Try to go past this maximum, and your signal will suffer.&amp;nbsp; &lt;i&gt;Clipping&lt;/i&gt; occurs when an audio device tries to output a signal whose amplitude is greater than its maximum value, and instead outputs the maximum value.&amp;nbsp; Clipped waves have a characteristic "leveled off" top (or bottom) that looks as if the wave were just chopped off.&lt;/p&gt; &lt;p&gt;The best way to describe&amp;nbsp;the problem with clipping might be by example.&amp;nbsp; Here is a generic sine wave (click for larger image):&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/AudioFidelityClipping_11897/sine%5B1%5D.png" mce_href="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/AudioFidelityClipping_11897/sine%5B1%5D.png" atomicselection="true"&gt;&lt;img src="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/AudioFidelityClipping_11897/sine.png" style="border: 0px none ;" mce_src="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/AudioFidelityClipping_11897/sine.png" border="0" height="82" width="240"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;And here is the logarithmic frequency spectrum of that sine wave.&amp;nbsp; The gray line represents a typical noise floor.&amp;nbsp;&amp;nbsp;Anything above the line is above the noise floor, and anything below the line generally won't be heard.&amp;nbsp; As expected with a clear sine wave, we see a single spike at our fundamental frequency, and no other audible tones.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;a href="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/AudioFidelityClipping_11897/sinefft%5B1%5D.png" mce_href="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/AudioFidelityClipping_11897/sinefft%5B1%5D.png" atomicselection="true"&gt;&lt;img src="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/AudioFidelityClipping_11897/sinefft.png" style="border: 0px none ;" mce_src="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/AudioFidelityClipping_11897/sinefft.png" border="0" height="86" width="240"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Now, here is the same sine wave doubled in amplitude and then clipped (admittedly, an extreme case, but not as uncommon as you'd think):&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/AudioFidelityClipping_11897/clip%5B3%5D.png" mce_href="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/AudioFidelityClipping_11897/clip%5B3%5D.png" atomicselection="true"&gt;&lt;img src="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/AudioFidelityClipping_11897/clip%5B2%5D.png" style="border: 0px none ;" mce_src="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/AudioFidelityClipping_11897/clip%5B2%5D.png" border="0" height="82" width="240"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;And the FFT of our clipped wave.&amp;nbsp; Notice the clearly audible &lt;a href="http://blogs.msdn.com/audiofool/archive/2006/08/07/691803.aspx" mce_href="http://blogs.msdn.com/audiofool/archive/2006/08/07/691803.aspx"&gt;harmonics&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/AudioFidelityClipping_11897/clipfft%5B1%5D.png" mce_href="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/AudioFidelityClipping_11897/clipfft%5B1%5D.png" atomicselection="true"&gt;&lt;img src="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/AudioFidelityClipping_11897/clipfft.png" style="border: 0px none ;" mce_src="http://blogs.msdn.com/blogfiles/audiofool/WindowsLiveWriter/AudioFidelityClipping_11897/clipfft.png" border="0" height="86" width="240"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;This is obviously a suboptimal listening experience - For every sound, you hear every odd harmonic.&amp;nbsp; But it could be much worse.&amp;nbsp; There is no good solution to limiting a signal level, and clipping is&amp;nbsp;just one of several things that a filter can do when it tries to produce&amp;nbsp;a signal that is too hot.&amp;nbsp;&amp;nbsp;A much worse outcome (common in&amp;nbsp;poorly designed older digital filters which store samples as CPU integers) will overflow and "wrap"&amp;nbsp;instead of clipping.&amp;nbsp; The sample jumps from INT_MAX to INT_MIN (or vice versa), and the speakers represent this as&amp;nbsp;a full-scale impulse, resulting in a "pop" that can damage your hardware (and your ears!).&lt;/p&gt; &lt;p&gt;One alternative to clipping, known as &lt;i&gt;soft clipping&lt;/i&gt;, involves using a complicated function to "compress" the wave as it gets near the maximum value.&amp;nbsp; Compressing the wave this way still introduces distortion, but it doesn't have the hard "edge" that clipping does.&lt;/p&gt; &lt;p&gt;Clipping and soft clipping introduce errors into a signal.&amp;nbsp; For this reason, you want to do it as little as possible during intermediate steps.&amp;nbsp; With the new audio engine in Windows Vista, all internal signals are stored as floating point numbers.&amp;nbsp; Valid output samples are between -1.0 and 1.0, but&amp;nbsp;intermediate steps between digital filters can&amp;nbsp;be outside that range, and the data type handles it just fine.&amp;nbsp; At the last possible step, the audio engine performs another kind of limiting (which I'll let JJ describe), converting to integer (if necessary) and sending to the audio codec.&amp;nbsp; This is an improvement over all integer digital processing, which has to apply limiting at each stage.&amp;nbsp; &lt;/p&gt;&lt;p&gt;&lt;a href="http://blogs.msdn.com/audiofool/pages/audio-topic-index.aspx" mce_href="http://blogs.msdn.com/audiofool/pages/audio-topic-index.aspx"&gt;Fidelity series index&lt;/a&gt;&lt;br&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1440488" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/audiofool/archive/tags/Audio/default.aspx">Audio</category></item><item><title>The difference between measuring DR and THD+N</title><link>http://blogs.msdn.com/audiofool/archive/2006/12/06/the-difference-between-measuring-dr-and-thd-n.aspx</link><pubDate>Thu, 07 Dec 2006 01:49:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1216884</guid><dc:creator>RyanBemrose</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/audiofool/comments/1216884.aspx</comments><wfw:commentRss>http://blogs.msdn.com/audiofool/commentrss.aspx?PostID=1216884</wfw:commentRss><description>&lt;p&gt;I've talked here before about how&amp;nbsp;noise and distortion are very similar concepts with very different causes.&amp;nbsp; Noise is unwanted artifacts independent of the signal&amp;nbsp;often caused by physical processes outside&amp;nbsp;of a&amp;nbsp;device.&amp;nbsp; Distortion is unwanted artifacts directly correlated with the signal usually caused by&amp;nbsp;components inside of the device.&amp;nbsp; When taking measurements of these artifacts, what we aim to measure is likewise quite different.&amp;nbsp; But the methods are surprisingly similar.&lt;/p&gt; &lt;p&gt;A dynamic range (&lt;b&gt;DR&lt;/b&gt;) measurement for a device is simply the difference in dB between&amp;nbsp;the device's output level and its noise floor.&amp;nbsp; To get output level, play a digital full-scale wave, and measure the amplitude.&amp;nbsp; To get a noise floor reading, play silence and measure the amplitude.&amp;nbsp; It turns out that for PC devices, there's a hitch, though.&amp;nbsp; Many audio codecs have muting circuits that shorts the output to a very low level when they detect that they are only outputting silence.&amp;nbsp; This is very clever, but it means we&amp;nbsp;aren't really getting a true noise floor measurement.&amp;nbsp; As a result, when taking a DR measurement on a PC,&amp;nbsp;we play a very low-level sine wave&amp;nbsp;while taking the measurement.&amp;nbsp; About 60dB below full scale (-60dBFS) should do it.&amp;nbsp;&amp;nbsp;We just need something to stimulate the codec and disengage the mute circuits.&lt;/p&gt; &lt;p&gt;But, you may be&amp;nbsp;thinking, doesn't this mean&amp;nbsp;we can't take a noise floor measurement below our signal?&amp;nbsp; We should never be able to&amp;nbsp; take a DR measurement of more than 60dB this way.&amp;nbsp; You're right, of course, which is why we need to also put the output through a &lt;i&gt;band reject filter &lt;/i&gt;which removes all signal components of one particular frequency - in this case, the frequency at which we're playing our sine wave.&amp;nbsp; What this filter allows us to do is to measure the amplitude of every frequency in the signal &lt;i&gt;except&lt;/i&gt; for the frequency we're playing.&amp;nbsp; That amplitude is, you guessed it, the noise floor.&lt;/p&gt; &lt;p&gt;Measuring distortion is a completely different can of worms.&amp;nbsp; To get a distortion reading,&amp;nbsp;we want to play a very loud signal (usually a sine wave, but could be multitone - more on that soon) at or near full scale, in order to provoke distortion artifacts.&amp;nbsp; Originally, almost all of the distortion in audio devices was &lt;i&gt;harmonic&lt;/i&gt;, meaning that if we play a sine wave has frequency F, the frequencies of distortion are 2F, 3F, 4F, and so on.&amp;nbsp; To take a distortion reading,&amp;nbsp;we measure the power of each harmonic, and sum them all up to get&amp;nbsp;a reading.&amp;nbsp; Our final measurement is the dB difference between this and our output level.&amp;nbsp; This measurement is known as the &lt;i&gt;Total Harmonic Distortion&lt;b&gt; &lt;/b&gt;&lt;/i&gt;(THD).&lt;/p&gt; &lt;p&gt;Modern electronic audio, however, can also have distortion artifacts in between the harmonics.&amp;nbsp; The summation method for THD won't measure these &lt;i&gt;nonlinear distortion&lt;/i&gt; artifacts, which usually sound worse than the harmonics.&amp;nbsp; What we really want to measure is the sum of every tone, harmonic or not, except the fundamental.&amp;nbsp; To do this, we turn back to our band reject filter to remove the fundamental signal and capture the amplitude of everything else.&amp;nbsp; Any distortion in the signal will be at a frequency other than the notched out frequency, and will be captured.&amp;nbsp; Strictly speaking, once we do this, we're also capturing the noise floor in addition to the distortion.&amp;nbsp; This is usually not a problem since in most real devices, full-scale distortion swamps the noise floor by an order of magnitude.&amp;nbsp; Still, to be pedantic, what we're measuring here is &lt;i&gt;Total Harmonic Distortion plus Noise&lt;/i&gt;, or &lt;b&gt;THD+N&lt;/b&gt;.&lt;/p&gt; &lt;p&gt;So our&amp;nbsp;measurement process looks like this:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Play full-scale tone with no filter  &lt;/li&gt;&lt;li&gt;Take amplitude measurement.&amp;nbsp; This is our output level measurement.  &lt;/li&gt;&lt;li&gt;Play test tone with bandreject filter tuned to test frequency.  &lt;/li&gt;&lt;li&gt;Take amplitude measurement.&amp;nbsp; This is our floor measurement.  &lt;/li&gt;&lt;li&gt;Take the dB difference between the measurements in steps 2 and 4.&amp;nbsp; This is our final value.&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;The only difference between DR and THD+N is the test tone used in step 3.&amp;nbsp; For DR,&amp;nbsp;we want only to stimulate the circuits, so we use a very quiet tone.&amp;nbsp; For THD+N,&amp;nbsp;we want to provoke distortion, so&amp;nbsp;we use a very loud tone.&amp;nbsp; I find it interesting that we can get measurements for these two different effects using the same process.&amp;nbsp; It sure saves on the test coding time, anyway.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1216884" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/audiofool/archive/tags/Audio/default.aspx">Audio</category></item><item><title>Audio Fidelity: Output Level</title><link>http://blogs.msdn.com/audiofool/archive/2006/12/04/audio-fidelity-output-level.aspx</link><pubDate>Tue, 05 Dec 2006 09:10:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1208937</guid><dc:creator>RyanBemrose</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/audiofool/comments/1208937.aspx</comments><wfw:commentRss>http://blogs.msdn.com/audiofool/commentrss.aspx?PostID=1208937</wfw:commentRss><description>&lt;p&gt;Output&amp;nbsp;level&amp;nbsp;is one of the simplest fidelity metrics to understand, but don't take that to mean it's not important.&amp;nbsp; There are several occasions where you want to know the maximum, loudest value that a signal can get.&amp;nbsp; On the digital side, that's pretty easy.&amp;nbsp; A &lt;i&gt;full-scale&lt;/i&gt; digital signal is a waveform (usually a sine wave) which oscillates back and forth between the maximum and minimum digital values.&amp;nbsp; An 8-bit full-scale signal, then, has samples that traverse the whole range between 0 and 256, and has a digital amplitude of 128.&lt;/p&gt; &lt;p&gt;However, on the analog side of things, it's not that easy.&amp;nbsp; The voltage at the speaker can go from the noise floor all the way up to the point where the speaker blows out.&amp;nbsp; But that's not really useful for measurements.&amp;nbsp;&amp;nbsp;More useful is knowing exactly which analog level corresponds to digital full-scale.&amp;nbsp; &lt;i&gt;Full-Scale Output Level&lt;/i&gt; (or just Output Level for short) on a PC is the amplitude of the analog signal that comes out of the jack/speakers when a digital full-scale waveform is applied to the codec.&amp;nbsp; &lt;/p&gt; &lt;p&gt;The main use of a device's output level is as a reference level.&amp;nbsp; Remember that when measuring a value in dB, you need to &lt;a href="http://blogs.msdn.com/audiofool/archive/2006/08/22/713498.aspx" mce_href="http://blogs.msdn.com/audiofool/archive/2006/08/22/713498.aspx"&gt;compare it against a reference&lt;/a&gt;.&amp;nbsp; For most analog measurements, the output level is a natural choice.&amp;nbsp; Dynamic Range and Distortion, for example, are measured in dB below output level.&lt;/p&gt; &lt;p&gt;You also need to know the output level of a device whenever you connect to other components.&amp;nbsp; Mismatching the output level of one device with the input tolerance of another can lead to audio too soft to hear, or even worse: blown components.&amp;nbsp; This is why many applications specify output level as a fidelity metric.&amp;nbsp; Most consumer electronics operate at 2Vrms (&lt;i&gt;Volts &lt;a href="http://en.wikipedia.org/wiki/Root_mean_square" mce_href="http://en.wikipedia.org/wiki/Root_mean_square"&gt;root mean square&lt;/a&gt;&lt;/i&gt;).&amp;nbsp; Some professional gear goes all the way up to 10V.&amp;nbsp; PCs in the past have never had an output level specification, and range all over the scale, from 100mV to 2V.&amp;nbsp; As expected, this plays&amp;nbsp;havoc with speaker gain&amp;nbsp;and other devices trying to interoperate.&amp;nbsp; This changed with Vista.&amp;nbsp; To get a Vista logo, an audio device needs to output a minimum of 1.0V.&amp;nbsp; (Vista doesn't specify a maximum, but in practice, computer power supplies limit the level to below about 2V,&amp;nbsp;which is only 6dB over the minimum)&lt;/p&gt; &lt;p&gt;Because of output level uncertainties, plugging a component into your PC is currently a trial-by-error experience.&amp;nbsp; You start with the component gain all the way down, and turn it&amp;nbsp;up slowly until it's comfortable.&amp;nbsp; Fine when the gain is an analog knob, but in the age of all-digital controls, it can be frustruating.&amp;nbsp; Hopefully with better standards in the future, this won't be such an unpredictable experience.&lt;/p&gt;&lt;p&gt;&lt;a href="http://blogs.msdn.com/audiofool/pages/audio-topic-index.aspx" mce_href="http://blogs.msdn.com/audiofool/pages/audio-topic-index.aspx"&gt;Fidelity series index&lt;/a&gt; &lt;br&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1208937" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/audiofool/archive/tags/Audio/default.aspx">Audio</category></item><item><title>Always dither before you quantize</title><link>http://blogs.msdn.com/audiofool/archive/2006/10/18/always-dither-before-you-quantize.aspx</link><pubDate>Wed, 18 Oct 2006 23:07:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:839871</guid><dc:creator>RyanBemrose</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/audiofool/comments/839871.aspx</comments><wfw:commentRss>http://blogs.msdn.com/audiofool/commentrss.aspx?PostID=839871</wfw:commentRss><description>&lt;p&gt;Quantization adds noise.&amp;nbsp; Taking a nice continuous signal and expressing it as distinct integers will introduce a round-off error, which means you've added random fluctuations to the signal, which&amp;nbsp;is&amp;nbsp;the definiton of noise.&amp;nbsp;&amp;nbsp;Remember that&amp;nbsp;&lt;a href="http://blogs.msdn.com/audiofool/archive/2006/06/27/648229.aspx" mce_href="http://blogs.msdn.com/audiofool/archive/2006/06/27/648229.aspx"&gt;noise is inevitable&lt;/a&gt;, so&amp;nbsp;we just have to manage it (such as using enough bits per sample).&amp;nbsp; The problem is that round-off errors aren't random&amp;nbsp;- just ask any banker.&amp;nbsp; Whether you round up or down can be strongly correlated with the signal - down at the peak of the continuous&amp;nbsp;wave and up at the trough, for example.&amp;nbsp; We have a word for signal-correlated noise, and that's &lt;a href="http://blogs.msdn.com/audiofool/archive/2006/08/07/691803.aspx" mce_href="http://blogs.msdn.com/audiofool/archive/2006/08/07/691803.aspx"&gt;distortion&lt;/a&gt;.&amp;nbsp; Distortion is much more difficult for the ear to separate from signal, which makes it much worse, from an audio perspective.&amp;nbsp; Fortunately, there's a solution.&amp;nbsp; Ironically, it's to add more noise.&lt;/p&gt; &lt;p&gt;&lt;i&gt;Dithering&lt;/i&gt; is the technique of adding white noise to a continuous signal before quantizing it.&amp;nbsp; This noise effectively&amp;nbsp;cancels the distortion introduced by rounding because the noise is no longer correlated to the signal.&amp;nbsp; The noise floor of the quantized signal is higher (reducing dynamic range), but it is white noise which is much easier on the ear than the distortion it's covering up.&lt;/p&gt; &lt;p&gt;One common type of dithering is &lt;i&gt;Triangular Probability Dithering&lt;b&gt; &lt;/b&gt;&lt;/i&gt;(TPD).&amp;nbsp; With TPD, you&amp;nbsp;generate&amp;nbsp;two random numbers x and y in the range [0,&amp;nbsp;1] (uniform&amp;nbsp;distribution) for each sample.&amp;nbsp; Add (x-y)/2 to the sample, and then round to the nearest integer.&amp;nbsp; This is gives the quantized signal a white noise floor 3dB over the undithered sample, but clears any distortion artifacts due to rounding.&lt;/p&gt; &lt;p&gt;Quantization noise is usually not considered a big problem in signals, because the solution is as simple as adding more bits to your samples.&amp;nbsp; Remember that quantization noise is determined by the theoretical maximum dynamic range for your sample size.&amp;nbsp; The quantization noise floor for 16-bit samples will be 96dB below the full-scale level.&amp;nbsp; If you use TPD, your noise floor goes to 93dB&amp;nbsp;below full scale.&amp;nbsp; This is only a problem, though, if your input continuous signal has more than 93dB of dynamic range, and if it does, you just add enough bits to push the quantization noise below the noise of your original samples.&amp;nbsp; &lt;/p&gt; &lt;p&gt;The add-more-bits approach does not, however, remove the need to dither.&amp;nbsp; &lt;i&gt;Spectral&amp;nbsp;&lt;/i&gt;(pure sine wave)&amp;nbsp;components in the distortion caused by round-off can be quite noticable even when the overall quantization noise is below the signal's floor.&amp;nbsp; Dithering smooths this distortion into white noise, spreading it across all bands, and ensuring no component is too high.&lt;/p&gt; &lt;p&gt;If you ever have to convert from&amp;nbsp;continuous real number samples to integers, keep in mind this simple rule of thumb.&amp;nbsp; Always dither before you quantize.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=839871" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/audiofool/archive/tags/Audio/default.aspx">Audio</category></item><item><title>Audio Fidelity: Frequency Response</title><link>http://blogs.msdn.com/audiofool/archive/2006/09/20/audio-fidelity-frequency-response.aspx</link><pubDate>Wed, 20 Sep 2006 16:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:762876</guid><dc:creator>RyanBemrose</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/audiofool/comments/762876.aspx</comments><wfw:commentRss>http://blogs.msdn.com/audiofool/commentrss.aspx?PostID=762876</wfw:commentRss><description>
&lt;p&gt;Not all frequencies are created equal.&amp;nbsp; And they're also not generally treated equally by a digital filter.&amp;nbsp; How inequally they're treated is one of the defining characteristics of a filter.&amp;nbsp; Audio engineers have a metric for describing this behavior.&amp;nbsp; The &lt;i&gt;frequency response&lt;/i&gt; of a filter or system&amp;nbsp;tells us the relative output signal given a known input signal at&amp;nbsp;a given&amp;nbsp;frequency.&amp;nbsp; Frequency response is different than our other metrics, in that a measurement is not simply a number.&amp;nbsp; It's a function of frequency, and the whole metric makes a curve and not just a number.&lt;/p&gt;
 
&lt;p&gt;The term "frequency response"&amp;nbsp;is not actually&amp;nbsp;very well defined.&amp;nbsp; In&amp;nbsp;technical terms, frequency response is&amp;nbsp;a complex-valued function&amp;nbsp;which&amp;nbsp;is made of two measurements: phase shift, and&amp;nbsp;magnitude.&amp;nbsp; You might also hear the terms &lt;i&gt;phase response&lt;/i&gt; and &lt;i&gt;magnitude response&lt;/i&gt;, corresponding to the two parts separately.&amp;nbsp;&amp;nbsp;The human ear, however, cares far more about magnitude than it does about&amp;nbsp;phase.&amp;nbsp; Since most people are only concerned with the real-valued magnitude of the graph, the terms "frequency response" and "magnitude response" are often used interchangably.&amp;nbsp; I will use the more precise term wherever applicable.&lt;/p&gt;
 
&lt;p&gt;In an ideal&amp;nbsp;audio system, the&amp;nbsp;magnitude response is a constant unity value over&amp;nbsp;all audible frequencies.&amp;nbsp; This means signal amplitude is independent of frequency, and all tones have the same output level as their input level.&amp;nbsp; This is important when playing back sounds, so that you don't change the characteristic of the sound.&amp;nbsp; Of course, the real world doesn't have ideal audio systems, so designers just do their best.&lt;/p&gt;
 
&lt;p&gt;So what happens when somebody messes up their frequency response?&amp;nbsp; The most common problems are dropping high or low-end sounds, and overemphasizing certain bands, and none of them sound good.&amp;nbsp; Dropping out low sounds results in a signal with all middle and high frequencies, making sounds tinny, hollow, and jarring.&amp;nbsp; Dropping high sounds destroys the harmonics that give a sound its unique timbre.&amp;nbsp; Without the high frequencies, sounds are flat,&amp;nbsp;lack characteristic, and are hard to tell apart.&amp;nbsp; Overemphasizing bands results in jarring volume differences between otherwise complementary&amp;nbsp;tones and&amp;nbsp;destroys chords as one note overpowers the others.&amp;nbsp; If a person's speech is played with overemphasized bands, meaning is also lost because the voice inflection becomes all wrong.&lt;/p&gt;
 
&lt;p&gt;But don't take my word for it.&amp;nbsp; You can try it yourself with home stereo equipment that has a graphic equalizer.&amp;nbsp; A graphic equalizer is nothing more than an audio filter with a variable magnitude response.&amp;nbsp; Moving the sliders up and down changes the shape of the magnitude response curve, and you can hear these effects for yourself.&amp;nbsp; In fact, graphic equalizers were originally created as a way to correct ("equalize") audio equipment with bad magnitude response.&lt;/p&gt;
 
&lt;p&gt;&lt;a href="http://blogs.msdn.com/audiofool/pages/audio-topic-index.aspx" mce_href="http://blogs.msdn.com/audiofool/pages/audio-topic-index.aspx"&gt;Fidelity series index&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=762876" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/audiofool/archive/tags/Audio/default.aspx">Audio</category></item><item><title>Audio Fidelity: Crosstalk</title><link>http://blogs.msdn.com/audiofool/archive/2006/09/01/audio-fidelity-crosstalk.aspx</link><pubDate>Fri, 01 Sep 2006 17:18:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:735316</guid><dc:creator>RyanBemrose</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/audiofool/comments/735316.aspx</comments><wfw:commentRss>http://blogs.msdn.com/audiofool/commentrss.aspx?PostID=735316</wfw:commentRss><description>&lt;p&gt;For years, recorded audio was just a signal, captured by a microphone, stored as an audio signal, and then played back by a speaker.&amp;nbsp; The microphone acted as a "proxy" eardrum to hear the sounds when&amp;nbsp;and where the real listener's ear couldn't be.&amp;nbsp; But somebody made an important realization.&amp;nbsp; Most people have more than one ear.&amp;nbsp; So, to proxy accurately, you need two microphones, two stored audio signals, and two speakers, all synchronized in time.&amp;nbsp; The synchronized audio&amp;nbsp;signal involved in one of these mic-storage-speaker combinations is called a &lt;i&gt;channel&lt;/i&gt;.&amp;nbsp; A set of synchronized channels is called a &lt;i&gt;stream&lt;/i&gt;.&amp;nbsp; Thus was born the idea of &lt;i&gt;multichannel&lt;/i&gt; audio.&lt;/p&gt; &lt;p&gt;Nowadays, almost everything you'll find supports multiple channels, even if it's only two.&amp;nbsp; Two-channel audio is known as &lt;i&gt;stereo&lt;/i&gt;, and for stereo equipment, the channels are usually labeled 'left' and 'right.&amp;nbsp; Though two-channel is still the norm, three, five, seven, and eight channels are becoming increasingly common for playback.&amp;nbsp; Several companies are even developing array microphones to capture several channels simultaneously.&lt;/p&gt; &lt;p&gt;The problem with multichannel audio is crosstalk.&amp;nbsp; Although the two (or more) channels in a stream are semantically and temporally coupled, you still want the signals to be independent.&amp;nbsp; &lt;i&gt;Crosstalk&lt;/i&gt; artifacts occur when the data from one channel leaks into another channel in the same stream.&amp;nbsp;&amp;nbsp;Since channels generally follow the same electrical path (audio chip to rear-panel jack, in a computer), the wires are usually next to eachother.&amp;nbsp; Sound pulses in one channel can cause a corresponding pulse in the other wire through induction.&amp;nbsp; A lot of devices also use the same ground wire for more than one channel.&amp;nbsp; Either of these designs will cause crosstalk.&lt;/p&gt; &lt;p&gt;To the untrained ear, crosstalk can be difficult to detect, since&amp;nbsp;the brain is already used to processing the same data in both ears any time you hear a sound.&amp;nbsp; What crosstalk will do is garble and confuse the spatial (location) information in a stream so you can't tell where the sound is coming from.&amp;nbsp; Crosstalk in surround systems causes an echo effect that can ruin music and make speech unintelligible.&amp;nbsp; It&amp;nbsp;can also add unexpected peaks in your signal, which lead to distortion.&amp;nbsp; Finally, if you think about it, crosstalk can defeat the purpose of having multichannel audio in the first place - playing audio with extreme crosstalk is effectively the same as simply splitting the same monophonic signal into several speakers.&lt;/p&gt; &lt;p&gt;Next time you're listening to your expensive mp3 player with its $2 earbuds, try a little experiment.&amp;nbsp; Dial the balance knob all the way to the right, then stick in just&amp;nbsp;the left earbud.&amp;nbsp; If you hear music, you might want to consider some better headphones.&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/audiofool/pages/audio-topic-index.aspx" mce_href="http://blogs.msdn.com/audiofool/pages/audio-topic-index.aspx"&gt;Fidelity series index&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=735316" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/audiofool/archive/tags/Audio/default.aspx">Audio</category></item><item><title>32 bit audio redux</title><link>http://blogs.msdn.com/audiofool/archive/2006/08/23/715608.aspx</link><pubDate>Thu, 24 Aug 2006 02:44:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:715608</guid><dc:creator>RyanBemrose</dc:creator><slash:comments>9</slash:comments><comments>http://blogs.msdn.com/audiofool/comments/715608.aspx</comments><wfw:commentRss>http://blogs.msdn.com/audiofool/commentrss.aspx?PostID=715608</wfw:commentRss><description>&lt;p&gt;In my &lt;a href="http://blogs.msdn.com/audiofool/archive/2006/08/22/713498.aspx"&gt;previous post&lt;/a&gt;, I don't think I explained very well why a 32-bit signal wouldn't work on the low-end.&amp;nbsp; The point, I think, was well-taken on the high-end.&amp;nbsp; You don't want a 192 dBSPL audio signal applied to your body (or your planet, for that matter).&amp;nbsp; However, Tricky asks&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;&lt;em&gt;Why have the 6.02 dB increment per bit? Why not reduce this amount, or make it variable? &lt;br&gt;&lt;br&gt;I'm asking instead of going the standard way it's done 6.02dB per bit .. why not implement so that 32 bits per signal sample doesnt have to mean that you need to go up to 192dB. &lt;br&gt;&lt;br&gt;That is, sample only the range of human hearing. low end is 1 dB ? and then the upper end .. 120 dB? &lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;First of all, dB is a logarithmic scale.&amp;nbsp; Numbers on a dB scale represent the ratio between two values, not the difference.&lt;/p&gt; &lt;p&gt;dB = 20 * log10(n1/n2).&lt;/p&gt; &lt;p&gt;Each bit doubles the linear precision of the value.&amp;nbsp; 20 * log10(2n / n) = 20 * log10(2) = 20 * 0.301 = 6.02.&amp;nbsp; The 6.02 dB per bit number is a mathematical conversion factor.&amp;nbsp; It is the same as asking to make 3600sec/hr a variable number.&lt;/p&gt; &lt;p&gt;What I think he is actually suggesting is to take the pressure level of 120dB (about 20 Pa) and divide it into 4 billion slices, each one about 0.005 µPa.&amp;nbsp; The reason I chose 20 µPa (0 dBSPL) as a base is actually an important one.&amp;nbsp; That is about the sound pressure level (broadband) exerted by garden-variety air molecules bouncing off of your speaker in&amp;nbsp;Earth's atmosphere.&amp;nbsp; It also, coincidentally, is just about the smallest pressure change that a human ear is capable of perceiving.&lt;/p&gt; &lt;p&gt;Re-using our metaphor&amp;nbsp;from the previous post, suppose the ultimate amp/speaker is actually capable of displacing exactly enough air to create a sound pressure wave of 0.005 µPa.&amp;nbsp; At the same time a stray air molecule could hit the speaker adding a random pressure oscillation to your signal at 100 times that level.&amp;nbsp; Even if your pickup device is sensitive enough to discern 0.005 µPa (obviously not talking about the human ear here), there will still be no way to separate the meaningful signal from&amp;nbsp;atmospheric noise.&amp;nbsp; An audio signal more precise than atmospheric noise is meaningless, because the signal is lost in the random variations.&amp;nbsp; That is why 0 dBSPL is a good base for your step size.&lt;/p&gt; &lt;p&gt;Given that you never want a sound louder than 120 dBSPL (20 Pa), and that it's meaningless to get any finer resolution than 0 dBSPL (20 µPa), we can calculate how many steps we actually need for any audio signal we care to hear.&amp;nbsp; 20 Pa / 20 µPa = 1000000 steps.&amp;nbsp; Taking the log2 of that, we end up with 19.93 bits (I don't know how to take a fractional bit, so let's round up to 20).&amp;nbsp; Therefore, you will never need more than 20 bits per sample to describe any audio to which you care to listen.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=715608" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/audiofool/archive/tags/Audio/default.aspx">Audio</category></item><item><title>A Lesson in Dynamic Range (or Why 32 Bits per Sample Should Never Catch On)</title><link>http://blogs.msdn.com/audiofool/archive/2006/08/22/713498.aspx</link><pubDate>Wed, 23 Aug 2006 05:19:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:713498</guid><dc:creator>RyanBemrose</dc:creator><slash:comments>11</slash:comments><comments>http://blogs.msdn.com/audiofool/comments/713498.aspx</comments><wfw:commentRss>http://blogs.msdn.com/audiofool/commentrss.aspx?PostID=713498</wfw:commentRss><description>&lt;p&gt;&lt;/p&gt; &lt;p&gt;Anywhere you go, you will be able to find&amp;nbsp;people who will insist that more is better. Bigger cars, larger portions, and more bits in your audio samples. But we thinking people know that there is such as too much of a good thing, don't we? I refer, of course, to having too many audio sample bits.&amp;nbsp;  &lt;p&gt;The amount of bits in a number determines the allowable range of that number.&amp;nbsp;&amp;nbsp;Each bit you add doubles the maximum&amp;nbsp;number.&amp;nbsp; Each bit also doubles the ratio between the maximum value and the granularity.&amp;nbsp; This ratio, remember, is the &lt;em&gt;dynamic range&lt;/em&gt; of the signal, and is measured in dB.&amp;nbsp; Since each bit is a doubling, and&amp;nbsp;each doubling adds 6.02dB (we'll just call it 6 - it makes the math easier), then the dynamic range of a digital signal is equal to numberOfBitsPerSample * 6dB.&amp;nbsp; For 8bit audio, that's 48dB.&amp;nbsp; Sixteen-bit samples have 96dB, which is nearly our range of normal hearing. &lt;p&gt;Okay, so we can find a dB value.&amp;nbsp; But how does this apply to the real world?&amp;nbsp; A raw dB value is nothing more than a ratio between two numbers, and isn't generally all that useful.&amp;nbsp; In order to make it a meaningful measurement, we have to specify a well-known value against which we're comparing the measurement.&amp;nbsp; This value is called the &lt;em&gt;reference level&lt;/em&gt;.&amp;nbsp; We then speak of a measurement in dBxyz, where xyz specifies the reference.&amp;nbsp; For example, you might see a voltage measured in dBV, which is the ratio to 1.0 Volts RMS.&amp;nbsp; In the digital world, you often see dBFS, or decibels relative to digital Full Scale.&amp;nbsp; In an &lt;a href="http://blogs.msdn.com/audiofool/archive/2006/07/02/654567.aspx"&gt;earlier post&lt;/a&gt;, I used the term "dBSPL" without defining it (and got called out for it - Thanks, Steve).&amp;nbsp; Well, As TommyK helpfully points out, dBSPL is air pressure relative to 0.00002 Pascals - the threshhold of hearing.&amp;nbsp; This makes dBSPL a very useful measurement for sounds in air. &lt;p&gt;So let's consider an audiophile's dream -&amp;nbsp;a 32-bit-per-sample signal.&amp;nbsp; Now consider an ultimate amplifier and speaker&amp;nbsp;that can take advantage of all 32-bits in air.&amp;nbsp; First of all You want to set the lowest bit at 0dBSPL.&amp;nbsp; Anything lower would not only be below the threshhold of hearing even at 3kHz (the most sensitive point), but would also be drowned out by the noise of random air molecules bouncing off of your speaker.&amp;nbsp; So if the low-end is at 0dBSPL, what's the high-end of 32 bits?&amp;nbsp; From our equation above, 32 bits per sample provides a 192dB dynamic range.&amp;nbsp; Overkill?&amp;nbsp; The threshhold of pain is about 120dBSPL, and it's generally accepted that being exposed to over 140dBSPL will result in permanent hearing damage. &lt;p&gt;Put another way,&amp;nbsp;0.00002 Pa + 192dB&amp;nbsp;works out to be about 85kPa.&amp;nbsp; One atmosphere of pressure is 101.325kPa.&amp;nbsp; When&amp;nbsp;our ultimate amp/speaker plays Mozart at full-scale,&amp;nbsp;it create a sound pressure wave capable of moving&amp;nbsp;nearly the whole&amp;nbsp;atmosphere several thousand times per second.&amp;nbsp; Standing in that mosh pit is a good way to come down with an instantly lethal case of the bends.&amp;nbsp; The&amp;nbsp;word 'explode' also comes to mind. &lt;p&gt;On the plus side, I guess you won't really have to worry about hearing damage afterward.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=713498" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/audiofool/archive/tags/Audio/default.aspx">Audio</category></item><item><title>Quantization, Sample Rate, and Bits Per Sample</title><link>http://blogs.msdn.com/audiofool/archive/2006/08/16/703382.aspx</link><pubDate>Thu, 17 Aug 2006 09:28:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:703382</guid><dc:creator>RyanBemrose</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/audiofool/comments/703382.aspx</comments><wfw:commentRss>http://blogs.msdn.com/audiofool/commentrss.aspx?PostID=703382</wfw:commentRss><description>&lt;p&gt;Forgive my digression, but I need to lay some digital signal processing (&lt;i&gt;DSP&lt;/i&gt;) groundwork for what I want to talk about next.&amp;nbsp; If you're already a DSP guru, then you may want to skip this one.&amp;nbsp; (If you're a DSP guru, what're you reading a blog called "Audio Fool" for anyway?)&lt;/p&gt; &lt;p&gt;As you know, a physical audio signal is just a sound pressure&amp;nbsp;wave that increases and decreases pressure with time.&amp;nbsp; Any time you measure, there is a level, and that level can move up and down an arbitrarily small&amp;nbsp;amount.&amp;nbsp; This signal is continuous, or &lt;em&gt;analog &lt;/em&gt;in both time and in level (in as much as quantum physics lets anything be continuous).&amp;nbsp; &lt;/p&gt; &lt;p&gt;The analog nature of sound causes a problem when you want to put the signal into a computer.&amp;nbsp; Computers only understand numbers.&amp;nbsp; So to get a signal into&amp;nbsp;a computer, you have to represent it as a series of numbers.&amp;nbsp; The way to do this is to measure the level of the signal several times per second and keep only the levels at that time.&amp;nbsp; Once you're done, you end up with a list of snapshots that represents the original signal.&amp;nbsp; This process is called &lt;em&gt;quantization&lt;/em&gt;.&amp;nbsp; Each of the numbers that you store is a &lt;em&gt;sample&lt;/em&gt;, and the number of times per second that you collect a sample is called the &lt;em&gt;sample rate&lt;/em&gt;.&lt;/p&gt; &lt;p&gt;There's another problem with digitizing audio.&amp;nbsp; The continuous analog wave can have any real value, with any number of digits of precision.&amp;nbsp; The precision of a number in a computer is limited by the amount of memory you use, so you have to round off the sample value when you read it.&amp;nbsp; The precision of a digital sample is usually expressed as number of &lt;em&gt;bits per sample&lt;/em&gt;.&amp;nbsp; One bit is simply "on" or "off".&amp;nbsp; Each extra bit doubles the number of levels you can have.&amp;nbsp; Common bits-per-sample values for digital audio are 8 (256 values) and 16 (65536 values), especially handy because they're exactly one and two bytes respectively.&amp;nbsp; More bits per sample gets you better precision, which leads to a more accurate representation of the source signal, which leads to better audio.&amp;nbsp; But how many is enough?&amp;nbsp; Is more always better?&amp;nbsp; That's the topic for the next post.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=703382" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/audiofool/archive/tags/Audio/default.aspx">Audio</category></item><item><title>Audio Fidelity: Distortion</title><link>http://blogs.msdn.com/audiofool/archive/2006/08/07/audio-fidelity-distortion.aspx</link><pubDate>Tue, 08 Aug 2006 07:40:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:691803</guid><dc:creator>RyanBemrose</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/audiofool/comments/691803.aspx</comments><wfw:commentRss>http://blogs.msdn.com/audiofool/commentrss.aspx?PostID=691803</wfw:commentRss><description>&lt;p&gt;Distortion in audio is very closely related to noise.&amp;nbsp;Both &amp;nbsp;"distortion" and "noise" are used to describe unwanted components of an audio stream, so what's the difference?&amp;nbsp;&amp;nbsp;I already defined noise when I talked about &lt;a href="http://blogs.msdn.com/audiofool/archive/2006/06/27/648229.aspx" mce_href="http://blogs.msdn.com/audiofool/archive/2006/06/27/648229.aspx"&gt;dynamic range&lt;/a&gt;.&amp;nbsp;&amp;nbsp;But what is distortion?&amp;nbsp; The simplest answer is that distortion is &lt;i&gt;signal-correlated artifacts&lt;/i&gt;.&amp;nbsp; An artifact, as you remember,&amp;nbsp;is anything unwanted in an audio&amp;nbsp;signal.&amp;nbsp;&amp;nbsp;To be signal-correlated means that the volume of the artifact increases and decreases with the volume of&amp;nbsp;the signal.&amp;nbsp; To check, look at all of the artifacts in your signal.&amp;nbsp; Now, increase your signal volume.&amp;nbsp; Any artifact that increased is distortion.&amp;nbsp; Anything that stayed constant is noise.&amp;nbsp;&lt;/p&gt; &lt;p&gt;The most common form of distortion occurs when you have a signal (the &lt;i&gt;fundamental&lt;/i&gt;)&amp;nbsp;playing at frequency &lt;i&gt;f&lt;/i&gt;, and you hear answering artifacts at frequencies 2&lt;i&gt;f&lt;/i&gt;, 3&lt;i&gt;f&lt;/i&gt;, 4&lt;i&gt;f&lt;/i&gt;, and so on.&amp;nbsp; This type of distortion is called &lt;i&gt;harmonic distortion&lt;/i&gt;, and the artifact at frequency N*&lt;i&gt;f&lt;/i&gt; is called the &lt;i&gt;Nth harmonic&lt;/i&gt;.&amp;nbsp;&amp;nbsp; The distortion coming from a&amp;nbsp;purely linear&amp;nbsp;filter (In audio engineering terms, a &lt;i&gt;filter&lt;/i&gt; is any device or process that&amp;nbsp;takes a signal and outputs another signal, usually altered in some way) is harmonic.&amp;nbsp; Harmonics also have some very interesting mathematical properties that I may describe in a future post.&amp;nbsp;&lt;/p&gt; &lt;p&gt;Not all harmonic distortion is bad.&amp;nbsp; It is harmonic distortion that gives a voice or instrument its &lt;i&gt;timbre&lt;/i&gt;, which is nothing more than&amp;nbsp;a characteristic signature of harmonics that is recognized by the ear to be different sounds.&amp;nbsp; Different patterns of harmonic distortion are why a bass guitar, a cello, and a man's voice all sound different, even though they can all produce the same note.&lt;/p&gt; &lt;p&gt;Of course distortion is still undesirable in recording and playback equipment such as a computer, for the simple reason that the it changes a signal from what was intended.&amp;nbsp;&amp;nbsp;Non-harmonic distortion produces dischord.&amp;nbsp; Harmonic distortion&amp;nbsp;gives a signal a subtle and artificial timbre shift.&amp;nbsp;&amp;nbsp;&amp;nbsp; A distorted voice may sound slightly garbled, or have a ringing to it.&amp;nbsp; Distorted music might have notes that are just a bit off, or instruments that jangle.&amp;nbsp; Finally, listening to&amp;nbsp;a distorted signal causes &lt;i&gt;&lt;a href="http://www.google.com/search?q=define:Listening+Fatigue" mce_href="http://www.google.com/search?q=define:Listening+Fatigue"&gt;listening fatigue&lt;/a&gt;&lt;/i&gt;, headaches, and&amp;nbsp;tension that results in the urge to shut off that blasted noise.&amp;nbsp; Your ear knows, even if your brain doesn't.&lt;/p&gt; &lt;p&gt;As an example, radio stations often broadcast distorted signals, as a result of overamplifying the antenna's output power.&amp;nbsp; If you've ever been in the car and decided to shut off music that you like because you're just "tired of listening to it", then now you know why.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/audiofool/pages/audio-topic-index.aspx" mce_href="http://blogs.msdn.com/audiofool/pages/audio-topic-index.aspx"&gt;Fidelity series index&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=691803" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/audiofool/archive/tags/Audio/default.aspx">Audio</category></item></channel></rss>