<?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>Larry Osterman's WebLog : Audio</title><link>http://blogs.msdn.com/larryosterman/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>Elliot Omiya, Frank Yerrace and I make a video…</title><link>http://blogs.msdn.com/larryosterman/archive/2009/08/11/elliot-omiya-frank-yerrace-and-i-make-a-video.aspx</link><pubDate>Wed, 12 Aug 2009 00:39:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9865016</guid><dc:creator>LarryOsterman</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/larryosterman/comments/9865016.aspx</comments><wfw:commentRss>http://blogs.msdn.com/larryosterman/commentrss.aspx?PostID=9865016</wfw:commentRss><wfw:comment>http://blogs.msdn.com/larryosterman/rsscomments.aspx?PostID=9865016</wfw:comment><description>&lt;p&gt;Charles just let me know that he’s &lt;a href="http://channel9.msdn.com/shows/Going+Deep/Elliot-H-Omiya-Larry-Osterman-and-Frank-Yerrace-Inside-Windows-7-Audio-Stack/"&gt;posted a video&lt;/a&gt; that Elliot, Frank and I did talking about the audio features added to Win7 and some of the architectural decisions that went into it.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9865016" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/larryosterman/archive/tags/Audio/default.aspx">Audio</category><category domain="http://blogs.msdn.com/larryosterman/archive/tags/Windows+7/default.aspx">Windows 7</category></item><item><title>A quick run through the new Windows 7 multimedia audio SDK samples</title><link>http://blogs.msdn.com/larryosterman/archive/2009/08/07/a-quick-run-through-the-new-windows-7-multimedia-audio-sdk-samples.aspx</link><pubDate>Fri, 07 Aug 2009 22:17:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9860547</guid><dc:creator>LarryOsterman</dc:creator><slash:comments>12</slash:comments><comments>http://blogs.msdn.com/larryosterman/comments/9860547.aspx</comments><wfw:commentRss>http://blogs.msdn.com/larryosterman/commentrss.aspx?PostID=9860547</wfw:commentRss><wfw:comment>http://blogs.msdn.com/larryosterman/rsscomments.aspx?PostID=9860547</wfw:comment><description>&lt;p&gt;As I mentioned yesterday, the &lt;a href="http://blogs.msdn.com/larryosterman/archive/2009/08/06/the-windows-7-sdk-is-live.aspx"&gt;Windows SDK is now live&lt;/a&gt;.&amp;#160; For the Windows SDK, there are 9 new samples (and one changed samples).&amp;#160; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Two of the SDK samples demonstrate the WIndows 7 “Ducking” feature – they’re actually based on the code I wrote for my &lt;a href="http://channel9.msdn.com/pdc2008/PC13/"&gt;PDC talk last year&lt;/a&gt;, but tweaked to show some new scenarios and clean up the code (the original PDC code was &lt;em&gt;not&lt;/em&gt; ready for prime time, it was strictly demo-ware).&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;The DuckingMediaPlayer application shows both a &lt;em&gt;really &lt;/em&gt;simple DirectShow based media player but also shows how to integrate the players volume control with the Windows per-application volume mixer.&amp;#160; So if you’re wondering how to integrate the volume control for your application with the built-in per-application volume controls, this sample will show you how to do it.&lt;/li&gt;    &lt;li&gt;The DuckingCaptureSample application is a trivial application that uses the wave APIs to capture audio data (and throw it away).&amp;#160; This shows how to trigger the “ducking”&amp;#160; feature in WIndows 7.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The other 7 samples reproduce functionality in the old WinAudio SDK sample – instead of providing a single monolithic audio sample, we crafted&amp;#160; different samples each of which shows one aspect of audio rendering.&amp;#160; All of these samples are simple console applications which read their parameters from the command line.&amp;#160; They’re intentionally extremely simple to reduce the potential for confusion in the samples.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;The EndpointVolume sample shows how to use the IAudioEndpointVolume APIs.&amp;#160; It demonstrates using the VolumeStepUp, VolumeStepDown, SetMute and SetMasterVolumeLevelScalar APIs.&lt;/li&gt;    &lt;li&gt;The CaptureSharedEventDriven sample shows how to use WASAPI in “event driven” mode to capture data in shared mode from the microphone.&lt;/li&gt;    &lt;li&gt;The CaptureSharedTimerDriven sample shows how to use WASAPI in “timer driven” mode to capture data in shared mode from the microphone.&lt;/li&gt;    &lt;li&gt;The RenderSharedEventDriven sample shows how to use WASAPI in “event driven” mode to play a simple sine wave in shared mode from the speakers.&lt;/li&gt;    &lt;li&gt;The RenderSharedTimerDriven sample shows how to use WASAPI in “timer driven” mode to play a simple sine wave in shared mode from the speakers.&lt;/li&gt;    &lt;li&gt;The RenderExclusiveEventDriven sample shows how to use WASAPI in “event driven” mode to play a simple sine wave in exclusive mode from the speakers.&amp;#160; This also shows the “exclusive mode swizzle” that is required to align the buffer size with the hardware buffer size (which is required to work with many HDAudio solutions).&lt;/li&gt;    &lt;li&gt;The RenderExclusiveTimerDriven sample shows how to use WASAPI in “timer driven” mode to play a simple sine wave in exclusive mode from the speakers.&amp;#160; This also shows the “exclusive mode swizzle” that is required to align the buffer size with the hardware buffer size (which is required to work with many HDAudio solutions).&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The reason we don’t have capture exclusive samples is that we felt that users of the SDK could derive the exclusive capture samples from the render samples if it was important to them.&amp;#160; &lt;/p&gt;  &lt;p&gt;All the shared mode samples also show how to implement stream switching.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;One of the things I’m quite proud about the samples is their structure.&amp;#160; Each sample has the following basic file layout:&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre class="csharpcode"&gt; Directory of C:\Program Files\Microsoft SDKs\Windows\v7.0\Samples\multimedia\audio\RenderExclusiveEventDriven

08/07/2009  10:08 AM    &amp;lt;DIR&amp;gt;          .
08/07/2009  10:08 AM    &amp;lt;DIR&amp;gt;          ..
07/14/2009  06:54 PM             7,079 CmdLine.cpp
07/14/2009  06:54 PM               760 CmdLine.h
07/14/2009  06:54 PM             2,084 ReadMe.txt
07/14/2009  06:54 PM               533 stdafx.cpp
07/14/2009  06:54 PM               935 stdafx.h
07/14/2009  06:54 PM             1,067 targetver.h
07/14/2009  06:54 PM             1,925 ToneGen.h
07/14/2009  06:54 PM            18,376 WASAPIRenderer.cpp
07/14/2009  06:54 PM             2,560 WASAPIRenderer.h
07/14/2009  06:54 PM            14,754 WASAPIRenderExclusiveEventDriven.cpp
07/14/2009  06:54 PM             1,283 WASAPIRenderExclusiveEventDriven.sln
07/14/2009  06:54 PM             8,403 WASAPIRenderExclusiveEventDriven.vcproj
              12 File(s)         59,759 bytes
               2 Dir(s)  62,822,105,088 bytes free&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Each sample has the same set of common files:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;CmdLine.cpp/CmdLine.h: A very simple command line parsing function&lt;/li&gt;

  &lt;li&gt;stdafx.cpp/stdafx.h: Common header definitions&lt;/li&gt;

  &lt;li&gt;targetver.h: Defines the target platform for these samples (Windows Vista in this case).&lt;/li&gt;

  &lt;li&gt;ToneGen.h: A very simple sine wave generating function (not present for the capture samples).&lt;/li&gt;

  &lt;li&gt;WASAPIRenderer.cpp/WASAPIRenderer.h (WASAPICapture for capture samples): The code which does all the WASAPI rendering and/or capturing&lt;/li&gt;

  &lt;li&gt;&amp;lt;SampleName&amp;gt;: Scaffolding for the sample – this defines the command line parameters and instantiates the actual render/capture object and asks it to do the rendering/capturing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each of these samples is essentially identical, in fact they’re sufficiently similar that you can use your favorite file comparison tool to see what code has to change to go from one mode to another.&amp;#160; So to see what changes are required to go from exclusive timer driven to exclusive event driven, you can windiff the RenderExclusiveEventDriven\WASAPIRenderer.cpp and RenderExclusiveTimerDriven\WASAPIRenderer.cpp files and see what changes are required to implement the different model.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9860547" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/larryosterman/archive/tags/Audio/default.aspx">Audio</category><category domain="http://blogs.msdn.com/larryosterman/archive/tags/Windows+7/default.aspx">Windows 7</category></item><item><title>The Windows 7 SDK is live!</title><link>http://blogs.msdn.com/larryosterman/archive/2009/08/06/the-windows-7-sdk-is-live.aspx</link><pubDate>Fri, 07 Aug 2009 02:56:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9859706</guid><dc:creator>LarryOsterman</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/larryosterman/comments/9859706.aspx</comments><wfw:commentRss>http://blogs.msdn.com/larryosterman/commentrss.aspx?PostID=9859706</wfw:commentRss><wfw:comment>http://blogs.msdn.com/larryosterman/rsscomments.aspx?PostID=9859706</wfw:comment><description>&lt;p&gt;I just received email that the new Windows 7 SDK is now &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=71deb800-c591-4f97-a900-bea146e4fae1&amp;amp;displaylang=en"&gt;live&lt;/a&gt;!&amp;#160; Apparently it’s not on the &lt;a href="http://msdn.microsoft.com/en-us/windows/bb980924.aspx"&gt;Windows SDK download site&lt;/a&gt; yet, but if you click on the first link, you can download an ISO which contains the SDK.&amp;#160; &lt;/p&gt;  &lt;p&gt;For the Win7 SDK, I wrote about 8 new samples in the Multimedia\Audio category, they’re described &lt;a href="http://blogs.msdn.com/windowssdk/archive/2009/07/02/new-win32-samples-in-windows-sdk-for-windows-7-multimedia.aspx"&gt;here&lt;/a&gt; (check the Multimedia\Audio samples.&amp;#160; These samples replace the old WinAudio SDK sample – basically I took the old WinAudio sample and blew it up into 8 different samples which demonstrate different aspects of rendering audio using WASAPI.&lt;/p&gt;  &lt;p&gt;I’ll write some more about the samples tomorrow – there are some cool things in the way the samples are structured that I hope will help developers who want to understand the difference between the various WASAPI render and capture modes.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9859706" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/larryosterman/archive/tags/Audio/default.aspx">Audio</category><category domain="http://blogs.msdn.com/larryosterman/archive/tags/Windows+7/default.aspx">Windows 7</category></item><item><title>A few of my favorite Win7 Sound features – Stream Switching</title><link>http://blogs.msdn.com/larryosterman/archive/2009/08/05/a-few-of-my-favorite-win7-sound-features-stream-switching.aspx</link><pubDate>Thu, 06 Aug 2009 00:45:57 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9858436</guid><dc:creator>LarryOsterman</dc:creator><slash:comments>29</slash:comments><comments>http://blogs.msdn.com/larryosterman/comments/9858436.aspx</comments><wfw:commentRss>http://blogs.msdn.com/larryosterman/commentrss.aspx?PostID=9858436</wfw:commentRss><wfw:comment>http://blogs.msdn.com/larryosterman/rsscomments.aspx?PostID=9858436</wfw:comment><description>&lt;p&gt;Way back when I was in college, I learned Lisp using a derivative of Lisp called &lt;a href="http://en.wikipedia.org/wiki/Maclisp"&gt;MACLISP&lt;/a&gt; (named for MIT’s project MAC, not for anything that came from a fruity company in Cupertino).&amp;#160; One of the coolest features that MACLISP offered was the (DWIM) command – basically if you had a typo when entering an s-list into MACLISP, you could type (&lt;a href="http://www.catb.org/~esr/jargon/html/D/DWIM.html"&gt;DWIM&lt;/a&gt;) and the MACLISP interpreter would fix your code for you (and yeah, it usually got it somewhat wrong :)).&lt;/p&gt;  &lt;p&gt;Stream Switching is a DWIM feature in the audio stack.&amp;#160; If an application is rendering to a default audio device and the device is removed, the audio stream will automatically switch to the new device.&amp;#160; The same happens if the default device changes for other reasons (if the user changes the default device for example) or if the sample rate on the device changes (this can happen with certain types of audio hardware allow external controls to change the sample rate for the device).&lt;/p&gt;  &lt;p&gt;We were able to figure out how to implement the stream switching logic in a fashion that causes it to work without requiring changes from 3rd party applications, which is really cool because it allows us to enable new scenarios without breaking appcompat – as long as the application is rendering to a default endpoint, we’ll stream switch the application without the app being notified.&lt;/p&gt;  &lt;p&gt;If an application is rendering to a specific endpoint, we’re not going to stream switch when the endpoint is removed – we don’t know the reasons for the application choosing that particular endpoint so we don’t attempt to second guess the applications intent (maybe the user has asked that their music player only play through the headphones and not through the speakers because playing through the speakers would disturb the baby).&lt;/p&gt;  &lt;p&gt;We also don’t support stream switching if the application is using WASAPI (the low level audio rendering APIs) to render audio.&amp;#160; That’s for a number of reasons, but mostly it’s because the presumption is that any application that is using WASAPI is using a low level rendering API and thus doesn’t want this kind of behavior.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;The stream switching logic is really cool in action, especially if you’ve got a machine which supports dynamic jack detection – when you’re watching a DVD in windows media player and you plug in a pair of headphones, poof – the audio gets redirected to the headphones just like you’d expect it to.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9858436" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/larryosterman/archive/tags/Audio/default.aspx">Audio</category><category domain="http://blogs.msdn.com/larryosterman/archive/tags/Windows+7/default.aspx">Windows 7</category></item><item><title>A few of my favorite Win7 Sound features – Capture Monitor (aka Listen to…)</title><link>http://blogs.msdn.com/larryosterman/archive/2009/08/04/a-few-of-my-favorite-win7-sound-features-capture-monitor-aka-listen-to.aspx</link><pubDate>Tue, 04 Aug 2009 20:30:21 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9857282</guid><dc:creator>LarryOsterman</dc:creator><slash:comments>14</slash:comments><comments>http://blogs.msdn.com/larryosterman/comments/9857282.aspx</comments><wfw:commentRss>http://blogs.msdn.com/larryosterman/commentrss.aspx?PostID=9857282</wfw:commentRss><wfw:comment>http://blogs.msdn.com/larryosterman/rsscomments.aspx?PostID=9857282</wfw:comment><description>&lt;p&gt;The capture monitor is a feature that allows you to listen to a portable media player (or any other microphone input) through your PC speakers.&amp;#160; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;First a bit of history.&amp;#160; Way back in the dark ages (Windows XP timeframe), audio solution manufacturers used to include an analog circuitry that connected the line in to the speaker jack on the PC.&amp;#160; They routed this through an analog volume control and exposed this through the audio device topology.&amp;#160; People used this functionality to connect their portable media players to their PCs.&amp;#160; While this feature was popular with customers, the cost of providing the circuitry was too much for some IHVs and they started removing this functionality from their products starting some time before Vista shipped.&lt;/p&gt;  &lt;p&gt;Not surprisingly, customers complained about this and we decided to implement equivalent functionality in the audio subsystem in Windows.&amp;#160; Because we’re doing this in the audio subsystem instead of in hardware, it allows you to configure the capture to run between any two devices.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;To configure the capture monitor, you go to the properties page for the input device and select the “Listen” tab:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/larryosterman/WindowsLiveWriter/AfewofmyfavoriteWin7SoundfeaturesCapture_93BA/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="Listen to... control panel page" border="0" alt="Listen to... control panel page" src="http://blogs.msdn.com/blogfiles/larryosterman/WindowsLiveWriter/AfewofmyfavoriteWin7SoundfeaturesCapture_93BA/image_thumb.png" width="414" height="461" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Once you select the “Listen to this device” checkbox (and hit apply), the system will start capturing data from the input and rendering it to the output device.&amp;#160; I’ve been using it to listen to my media player for months :).&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;I’ve been really gratified to see that both &lt;a href="http://blogs.zdnet.com/Bott/?p=1195&amp;amp;page=2"&gt;Ed Bott&lt;/a&gt; and &lt;a href="http://lifehacker.com/5326409/play-your-ipod-through-your-windows-7-pcs-speakers"&gt;Lifehacker&lt;/a&gt; (who picked this up from Ed) have noticed this feature, it was a huge amount of fun to write.&amp;#160; It was also my first experience using TDD (or rather a variant of TDD – instead of writing the test first then the code, I wrote the code and the test for the code at the exact same time) - based on my experiences, I’m totally sold on it as a development paradigm.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9857282" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/larryosterman/archive/tags/Audio/default.aspx">Audio</category><category domain="http://blogs.msdn.com/larryosterman/archive/tags/Windows+7/default.aspx">Windows 7</category></item><item><title>A few of my favorite Win7 Sound features – UI refinements</title><link>http://blogs.msdn.com/larryosterman/archive/2009/08/03/a-few-of-my-favorite-win7-sound-features-ui-refinements.aspx</link><pubDate>Tue, 04 Aug 2009 02:08:22 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9856614</guid><dc:creator>LarryOsterman</dc:creator><slash:comments>64</slash:comments><comments>http://blogs.msdn.com/larryosterman/comments/9856614.aspx</comments><wfw:commentRss>http://blogs.msdn.com/larryosterman/commentrss.aspx?PostID=9856614</wfw:commentRss><wfw:comment>http://blogs.msdn.com/larryosterman/rsscomments.aspx?PostID=9856614</wfw:comment><description>&lt;p&gt;Well, we shipped Windows 7, and now I’d like to talk about a few of my favorite features that were added by the Sound team.&amp;#160; Most of them fit in the “make it just work the way it’s supposed to”, but a few are just cool.&lt;/p&gt;  &lt;p&gt;I also want to call out some stuff that people probably are going to miss in the various Windows 7 reviews.&lt;/p&gt;  &lt;p&gt;One of the areas I want to call out is the volume UI.&amp;#160; There’s actually been a ton of work done on the volume UI in Windows 7, although most of it exists under the covers.&amp;#160; For instance, the simple volume control (the one you get to with a single click from the volume notification area) uses what we call “flat buttons”.&lt;/p&gt;  &lt;p align="center"&gt;   &lt;table border="1" cellspacing="0" cellpadding="2" width="441"&gt;&lt;tbody&gt;       &lt;tr&gt;         &lt;td valign="top" width="218"&gt;           &lt;p align="center"&gt;Windows 7 Simple Volume UI:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="221"&gt;           &lt;p align="center"&gt;Windows Vista Simple Volume UI:&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr&gt;         &lt;td valign="top" width="218"&gt;&lt;a href="http://blogs.msdn.com/blogfiles/larryosterman/WindowsLiveWriter/AfewofmyfavoriteWin7SoundfeaturesUIrefin_E2E9/image_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Win7 Simple Volume" border="0" alt="Win7 Simple Volume" src="http://blogs.msdn.com/blogfiles/larryosterman/WindowsLiveWriter/AfewofmyfavoriteWin7SoundfeaturesUIrefin_E2E9/image_thumb.png" width="84" height="305" /&gt;&lt;/a&gt;&lt;/td&gt;          &lt;td valign="top" width="221"&gt;&lt;a href="http://blogs.msdn.com/blogfiles/larryosterman/WindowsLiveWriter/AfewofmyfavoriteWin7SoundfeaturesUIrefin_E2E9/sndvolvista_2.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Vista Simple Volume " border="0" alt="Vista Simple Volume " src="http://blogs.msdn.com/blogfiles/larryosterman/WindowsLiveWriter/AfewofmyfavoriteWin7SoundfeaturesUIrefin_E2E9/sndvolvista_thumb.jpg" width="88" height="269" /&gt;&lt;/a&gt;&lt;/td&gt;       &lt;/tr&gt;     &lt;/tbody&gt;&lt;/table&gt; &lt;/p&gt;  &lt;p&gt;Both the mute control and the device button are “flat buttons” – when you mouse over the buttons, the button surfaces:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/larryosterman/WindowsLiveWriter/AfewofmyfavoriteWin7SoundfeaturesUIrefin_E2E9/image_8.png"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="simple volume with &amp;quot;flat button&amp;quot; enabled" border="0" alt="simple volume with &amp;quot;flat button&amp;quot; enabled" src="http://blogs.msdn.com/blogfiles/larryosterman/WindowsLiveWriter/AfewofmyfavoriteWin7SoundfeaturesUIrefin_E2E9/image_thumb_3.png" width="84" height="305" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;By using the “flat buttons”, the UI continues to have the old functionality, but it visually appears cleaner.&amp;#160; There have been a number of other changes to the simple volume UI.&amp;#160; First off, we will now show more than one slider if you have more than one audio solution on your machine and you’re using both of them at the same time.&amp;#160; This behavior is controlled by the new volume control options dialog:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/larryosterman/WindowsLiveWriter/AfewofmyfavoriteWin7SoundfeaturesUIrefin_E2E9/image_6.png"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/larryosterman/WindowsLiveWriter/AfewofmyfavoriteWin7SoundfeaturesUIrefin_E2E9/image_thumb_2.png" width="415" height="415" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;As I mentioned above, the device icon is also a “flat button” – this enables one click access to the hardware properties for you audio solution.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;The volume mixer has also changed slightly.&amp;#160; You’ll notice the flat buttons for the device and mute immediately.&amp;#160; We also added a flat button for the System Sounds which launches the system sounds applet.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/larryosterman/WindowsLiveWriter/AfewofmyfavoriteWin7SoundfeaturesUIrefin_E2E9/image_4.png"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/larryosterman/WindowsLiveWriter/AfewofmyfavoriteWin7SoundfeaturesUIrefin_E2E9/image_thumb_1.png" width="489" height="349" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Another subtle change to the volume mixer is that there are now meters for individual applications as well as for the master volume:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/larryosterman/WindowsLiveWriter/AfewofmyfavoriteWin7SoundfeaturesUIrefin_E2E9/image_10.png"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/larryosterman/WindowsLiveWriter/AfewofmyfavoriteWin7SoundfeaturesUIrefin_E2E9/image_thumb_4.png" width="489" height="349" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;And finally, the volume mixer no longer flickers when resizing (yay!).&amp;#160; Fixing the flicker was a problem that took a ton of effort (and I needed to ask the User team for help figuring out the problem) – the solution turned out to be simple but it took some serious digging to figure it out.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9856614" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/larryosterman/archive/tags/Audio/default.aspx">Audio</category><category domain="http://blogs.msdn.com/larryosterman/archive/tags/Windows+7/default.aspx">Windows 7</category></item><item><title>Windows 7 fixes the PlaySound(XXX, SND_MEMORY|SND_ASYNC) anti-pattern</title><link>http://blogs.msdn.com/larryosterman/archive/2009/06/24/windows-7-fixes-the-playsound-xxx-snd-memory-snd-async-anti-pattern.aspx</link><pubDate>Thu, 25 Jun 2009 00:54:11 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9802264</guid><dc:creator>LarryOsterman</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/larryosterman/comments/9802264.aspx</comments><wfw:commentRss>http://blogs.msdn.com/larryosterman/commentrss.aspx?PostID=9802264</wfw:commentRss><wfw:comment>http://blogs.msdn.com/larryosterman/rsscomments.aspx?PostID=9802264</wfw:comment><description>&lt;p&gt;A number of times in the past, I’ve mentioned that the &lt;a href="http://blogs.msdn.com/larryosterman/archive/2009/02/19/playsound-xxx-snd-memory-snd-async-is-almost-always-a-bad-idea.aspx"&gt;PlaySound(xxx, xxx, SND_MEMORY|SND_ASYNC)&lt;/a&gt; pattern is almost always a bad idea.&amp;#160; After the last wave of crash dumps were received for this problem, our team decided to do something about it.&amp;#160; Starting with Windows 7, if you call PlaySound with SND_MEMORY|SND_ASYNC, instead of relying on the memory passed in by the application, we allocate our own buffer for the sound file on the heap and copy the file into that buffer.&amp;#160; We’ll only do it for WAV files that are smaller than 2M in size, and if the allocation of the buffer fails, we fall back on the original code path, but it should dramatically reduce the number of apps that crash while using this pattern.&lt;/p&gt;  &lt;p&gt;It’s a little thing, but it should make life much easier for those applications.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9802264" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/larryosterman/archive/tags/Audio/default.aspx">Audio</category></item><item><title>PlaySound(xxx, SND_MEMORY | SND_ASYNC) is almost always a bad idea.</title><link>http://blogs.msdn.com/larryosterman/archive/2009/02/19/playsound-xxx-snd-memory-snd-async-is-almost-always-a-bad-idea.aspx</link><pubDate>Fri, 20 Feb 2009 01:31:57 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9435071</guid><dc:creator>LarryOsterman</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/larryosterman/comments/9435071.aspx</comments><wfw:commentRss>http://blogs.msdn.com/larryosterman/commentrss.aspx?PostID=9435071</wfw:commentRss><wfw:comment>http://blogs.msdn.com/larryosterman/rsscomments.aspx?PostID=9435071</wfw:comment><description>&lt;p&gt;Whenever you submit a crash report to &lt;a href="http://oca.microsoft.com/en/windiag.asp"&gt;OCA&lt;/a&gt;, a bug gets filed in the relevant product database and gets automatically assigned to the developer responsible for the code.&amp;#160; I had a crashing bug in the PlaySound API assigned to me.&amp;#160; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;In this case, the call was crashing deep inside of the waveOutOpen API and it was crashing because the input WAVEFORMATEX structure was bogus.&amp;#160; The strange thing is that the PlaySound API does some fairly thorough validation of the input WAVEFORMATEX read from the .WAV file and that validation had to have passed to get to the call to waveOutOpen.&lt;/p&gt;  &lt;p&gt;I looked a bit deeper and came to the realization that every single one of the crashes (in maybe a dozen different applications) had specified SND_MEMORY | SND_ASYNC in their call to PlaySound.&lt;/p&gt;  &lt;p&gt;I’ve talked about that particular combination &lt;a href="http://blogs.msdn.com/larryosterman/archive/2007/01/05/software-contracts-part-2-there-are-two-sides-to-every-contract.aspx"&gt;before&lt;/a&gt; in my blog, but I wanted to call it out in a top level post in the hopes that people will stop making this common mistake.&lt;/p&gt;  &lt;p&gt;When you call PlaySound with the SND_MEMORY flag, it tells the PlaySound API that instead of reading the audio data from a file, you’re passing in a pointer to memory which holds the wave contents for you.&amp;#160; That’s not controversial, and can be quite handy if (for instance) you want to build a .WAV file in memory instead of calling the wave APIs directly.&lt;/p&gt;  &lt;p&gt;When you call PlaySound with the SND_ASYNC flag, that flag tells PlaySound that instead of blocking until the sound has finished playing, the API should return immediately instead of blocking while the sound is played.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Neither of these flags is controversial and neither of them is particularly dangerous &lt;em&gt;until&lt;/em&gt; you combine the two together.&lt;/p&gt;  &lt;p&gt;The problem is that there’s really no way of knowing when the sound has finished playing and thus when the application frees the memory, it’s entirely possible that the PlaySound API is still using it.&amp;#160; That means that if you ever call PlaySound with both of these flags, you stand a very high chance of crashing due to the combination of these behaviors.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;The unfortunate thing is that this behavior has existed since the SND_MEMORY flag was added back in Windows 3.1.&amp;#160; The only safe way of dealing with this that works on all current Windows operating systems is to call PlaySound(NULL, 0, 0) before freeing the memory – the call to PlaySound(NULL, 0, 0) will block until the currently playing sound has completed playing (or abort the playsound if it hasn’t started yet).&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9435071" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/larryosterman/archive/tags/Things+you+shouldn_2700_t+do_2E00_/default.aspx">Things you shouldn't do.</category><category domain="http://blogs.msdn.com/larryosterman/archive/tags/Audio/default.aspx">Audio</category></item><item><title>When you do UX work, sometimes you have to worry about the strangest things…</title><link>http://blogs.msdn.com/larryosterman/archive/2009/01/13/when-you-do-ux-work-sometimes-you-have-to-worry-about-the-strangest-things.aspx</link><pubDate>Tue, 13 Jan 2009 20:13:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9316088</guid><dc:creator>LarryOsterman</dc:creator><slash:comments>31</slash:comments><comments>http://blogs.msdn.com/larryosterman/comments/9316088.aspx</comments><wfw:commentRss>http://blogs.msdn.com/larryosterman/commentrss.aspx?PostID=9316088</wfw:commentRss><wfw:comment>http://blogs.msdn.com/larryosterman/rsscomments.aspx?PostID=9316088</wfw:comment><description>&lt;p&gt;I recently got a bug reported to me about the visuals in the sound control panel applet not being aligned properly (this is from the UI for a new Windows 7 feature):&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/larryosterman/WindowsLiveWriter/WhenyoudoUXworksometimesyouhavetoworryab_816E/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/larryosterman/WindowsLiveWriter/WhenyoudoUXworksometimesyouhavetoworryab_816E/image_thumb.png" width="415" height="237" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The problem as reported was that the microphone was aligned incorrectly w.r.t. the down arrow. – the microphone was too far to the right.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;But if you look carefully, you’ll see that that isn’t the case – drawing a box around the controls makes it clearer:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/larryosterman/WindowsLiveWriter/WhenyoudoUXworksometimesyouhavetoworryab_816E/image_4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/larryosterman/WindowsLiveWriter/WhenyoudoUXworksometimesyouhavetoworryab_816E/image_thumb_1.png" width="416" height="238" /&gt;&lt;/a&gt;Nitpickers Corner: For those of you that love to count pixels, it’s entirely possible that the arrow might be off by a couple of pixels but fixing it wouldn’t fix the problem, because then the arrow would be off-center with respect to the speakers.&amp;#160; The real problem is that the microphone icon is visually weighted to the right – the actual icon resource was lined up with the arrow, but because the visual weight was to the right, it displayed poorly.&amp;#160; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;It turns out that there’s really no good way of fixing this – if we were to adjust the location of the icons, it wouldn’t help, because a different device would have a different visual center (as the speaker icon does)…&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Instead, we looked at the visuals and realized that there was an alternative solution: Adjust the layout for the dialog and the problem more-or-less goes away:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/larryosterman/WindowsLiveWriter/WhenyoudoUXworksometimesyouhavetoworryab_816E/newmonitor.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="newmonitor" border="0" alt="newmonitor" src="http://blogs.msdn.com/blogfiles/larryosterman/WindowsLiveWriter/WhenyoudoUXworksometimesyouhavetoworryab_816E/newmonitor_thumb.png" width="416" height="215" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The problem still exists at some level because the arrow is centered with the icons but some icons (like the stalk microphone above) are bottom heavy.&amp;#160; But for whatever reason, the visuals aren’t as disconcerting when laid out horizontally.&lt;/p&gt;  &lt;p&gt;As I said in the title – sometimes you need to worry about the strangest things.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9316088" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/larryosterman/archive/tags/Fascinating+geek+stuff/default.aspx">Fascinating geek stuff</category><category domain="http://blogs.msdn.com/larryosterman/archive/tags/Audio/default.aspx">Audio</category><category domain="http://blogs.msdn.com/larryosterman/archive/tags/Windows+7/default.aspx">Windows 7</category></item><item><title>Why do people think that a server SKU works well as a general purpose operating system?</title><link>http://blogs.msdn.com/larryosterman/archive/2009/01/08/why-do-people-think-that-a-server-sku-works-well-as-a-general-purpose-operating-system.aspx</link><pubDate>Thu, 08 Jan 2009 21:17:04 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9299345</guid><dc:creator>LarryOsterman</dc:creator><slash:comments>70</slash:comments><comments>http://blogs.msdn.com/larryosterman/comments/9299345.aspx</comments><wfw:commentRss>http://blogs.msdn.com/larryosterman/commentrss.aspx?PostID=9299345</wfw:commentRss><wfw:comment>http://blogs.msdn.com/larryosterman/rsscomments.aspx?PostID=9299345</wfw:comment><description>&lt;p&gt;Sometimes the expectations of our customers mystify me.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;One of the senior developers at Microsoft recently complained that the audio quality on his machine (running Windows Server 2008) was poor.&lt;/p&gt;  &lt;p&gt;To me, it’s not surprising.&amp;#160; Server SKUs are tuned for high performance in &lt;em&gt;server&lt;/em&gt; scenarios, they’re not configured for desktop scenarios.&amp;#160; That’s the entire POINT of having a server SKU – one of the major differences between server SKUs and client SKUs is that the client SKUs are tuned to balance the OS in favor of foreground responsiveness and the server SKUs are tuned in favor of background responsiveness (after all, its a server, there’s usually nobody sitting at the console, so there’s no point in optimizing for the console).&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;In this particular case, the documentation for the &lt;a href="http://msdn.microsoft.com/en-us/library/ms684247.aspx"&gt;MMCSS service&lt;/a&gt; describes a large part of the root cause for the problem:&amp;#160; The MMCSS service (which is the service that provides glitch resilient services for Windows multimedia applications) is essentially disabled on server SKUs.&amp;#160; It’s just one of probably hundreds of other settings that are tweaked in favor of server responsiveness on server SKUs.&amp;#160; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Apparently we’ve got a bunch of support requests coming in from customers who are running server SKUs on their desktop and are upset that audio quality is poor.&amp;#160; And this mystifies me.&amp;#160; It’s a server operating system – if you want client operating system performance, use a client operating system.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;PS: To change the MMCSS tuning options, you should follow the suggestions from the MSDN article I linked to above:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;The MMCSS settings are stored in the following registry key: &lt;/p&gt;    &lt;p&gt;&lt;strong&gt;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile&lt;/strong&gt;&lt;/p&gt;    &lt;p&gt;This key contains a REG_DWORD value named &lt;strong&gt;SystemResponsiveness&lt;/strong&gt; that determines the percentage of CPU resources that should be guaranteed to low-priority tasks. For example, if this value is 20, then 20% of CPU resources are reserved for low-priority tasks. Note that values that are not evenly divisible by 10 are rounded up to the nearest multiple of 10. A value of 0 is also treated as 10.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;For Vista, this value is set to 20, for Server 2008 the value is set to 100 (which disables MMCSS).&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9299345" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/larryosterman/archive/tags/Audio/default.aspx">Audio</category></item><item><title>Why specify SND_NODEFAULT when calling PlaySound?</title><link>http://blogs.msdn.com/larryosterman/archive/2008/09/25/why-specify-snd-nodefault-when-calling-playsound.aspx</link><pubDate>Fri, 26 Sep 2008 00:46:34 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8965597</guid><dc:creator>LarryOsterman</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/larryosterman/comments/8965597.aspx</comments><wfw:commentRss>http://blogs.msdn.com/larryosterman/commentrss.aspx?PostID=8965597</wfw:commentRss><wfw:comment>http://blogs.msdn.com/larryosterman/rsscomments.aspx?PostID=8965597</wfw:comment><description>&lt;p&gt;Because the alternative is often much worse.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Several months ago, I got a bug report that if you launched mmsys.cpl then set the “Select” sound to a value, then cleared the sound, the reporters application would ding whenever you moved around their tree control.&lt;/p&gt;  &lt;p&gt;I dug into the problem a bit and discovered that the problem was actually in the Windows common controls.&amp;#160; Under some circumstances the common controls would call PlaySound specifying a sound alias and the SND_ASYNC and SND_ALIAS flags only.&amp;#160; &lt;/p&gt;  &lt;p&gt;The problem with this is that if you specify SND_ALIAS without also specifying SND_NODEFAULT, the PlaySound API decides that you &lt;em&gt;really&lt;/em&gt; want the sound to be played and it will play the default “ding” sound instead.&amp;#160; &lt;/p&gt;  &lt;p&gt;From the PlaySound API’s point of view this makes sense.&amp;#160; After all, you asked the API to play a sound, it doesn’t know that you meant “only play this sound when the sound file represented by the alias exists”.&amp;#160; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;In fact, that’s the entire reason for the SND_NODEFAULT flag – it lets the PlaySound API that you only want to play a sound when the sound has been defined.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8965597" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/larryosterman/archive/tags/Nifty+Win32+tricks_2E00_/default.aspx">Nifty Win32 tricks.</category><category domain="http://blogs.msdn.com/larryosterman/archive/tags/Audio/default.aspx">Audio</category></item><item><title>They just announced my PDC talk, so I guess I can mention at least the title of the talk.</title><link>http://blogs.msdn.com/larryosterman/archive/2008/09/24/they-just-announced-my-pdc-talk-so-i-guess-i-can-mention-at-least-the-title-of-the-talk.aspx</link><pubDate>Wed, 24 Sep 2008 21:21:59 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8963944</guid><dc:creator>LarryOsterman</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/larryosterman/comments/8963944.aspx</comments><wfw:commentRss>http://blogs.msdn.com/larryosterman/commentrss.aspx?PostID=8963944</wfw:commentRss><wfw:comment>http://blogs.msdn.com/larryosterman/rsscomments.aspx?PostID=8963944</wfw:comment><description>&lt;p&gt;The PDC folks just announced a host of &lt;a href="http://blogs.msdn.com/pdc/archive/2008/09/24/unveiling-windows-7-to-the-world.aspx"&gt;Windows 7 related PDC talks&lt;/a&gt;, one of which is mine.&lt;/p&gt;  &lt;p&gt;The title of the talk is “Windows 7: Building Great Communications Applications”.&amp;#160; You can find it under the Windows 7 track on &lt;a href="https://sessions.microsoftpdc.com/public/sessions.aspx"&gt;the Microsoft PDC site&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;The primary target for my talk is developers who are building an application that in any way communicates between users (voice mail, instant messaging, voice over ip, etc).&amp;#160; In addition, if you’re a games developer or a media player developer, you should also attend, there’s stuff in the talk for you too.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;There are also some other cool talks included in the list that I’m absolutely planning on attending.&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;See you in LA!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8963944" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/larryosterman/archive/tags/Audio/default.aspx">Audio</category></item><item><title>Why call PlaySound(NULL, NULL, SND_NODEFAULT)?</title><link>http://blogs.msdn.com/larryosterman/archive/2008/09/15/why-call-playsound-null-null-snd-nodefault.aspx</link><pubDate>Tue, 16 Sep 2008 03:18:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8953279</guid><dc:creator>LarryOsterman</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/larryosterman/comments/8953279.aspx</comments><wfw:commentRss>http://blogs.msdn.com/larryosterman/commentrss.aspx?PostID=8953279</wfw:commentRss><wfw:comment>http://blogs.msdn.com/larryosterman/rsscomments.aspx?PostID=8953279</wfw:comment><description>&lt;p&gt;Someone just wandered over to my office and he had noticed the following pattern in his code:&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre class="csharpcode"&gt;PlaySound(NULL, NULL, SND_NODEFAULT);
PlaySound(&lt;span class="str"&gt;&amp;quot;.Default&amp;quot;&lt;/span&gt;, NULL, SND_SYSTEM | SND_ASYNC | SND_NODEFAULT);&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;He was wondering why on earth the code would do that call to &lt;a href="http://msdn.microsoft.com/en-us/library/ms712879.aspx"&gt;PlaySound&lt;/a&gt;(NULL).&amp;#160; &lt;/p&gt;

&lt;p&gt;As I explained it to him, the reason is because you almost always want to cancel the current sound playing before you queue up the next sound.&lt;/p&gt;

&lt;p&gt;The problem is that the current implementation[1] of PlaySound(…, SND_ASYNC) simply queues the request to a worker thread which blocks waiting on the currently playing sound to complete.&amp;#160; So if you have a situation where you call PlaySound(…, SND_ASYNC) many times in succession, you’ll find that all the calls to PlaySound pile up behind each other, which means that you might end up playing sounds long after the action associated with the sound has completed.&lt;/p&gt;

&lt;p&gt;Of course you might want this behavior – it’s certainly possible to string lots of system sounds together to produce any number of interesting effects.&lt;/p&gt;

&lt;p&gt;But most of the time you just want to stop the current sound before you start playing the next.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;[1] There are obviously no guarantees that the implementation of PlaySound won’t change – I’m just describing what the current code does.&amp;#160; Even if the implementation is changed, it won’t change the underlying behavior.&lt;/p&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8953279" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/larryosterman/archive/tags/Nifty+Win32+tricks_2E00_/default.aspx">Nifty Win32 tricks.</category><category domain="http://blogs.msdn.com/larryosterman/archive/tags/Audio/default.aspx">Audio</category></item><item><title>Why doesn’t Windows support amplification of audio samples?</title><link>http://blogs.msdn.com/larryosterman/archive/2008/08/11/why-doesn-t-windows-support-amplification-of-audio-samples.aspx</link><pubDate>Mon, 11 Aug 2008 19:36:21 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8848412</guid><dc:creator>LarryOsterman</dc:creator><slash:comments>15</slash:comments><comments>http://blogs.msdn.com/larryosterman/comments/8848412.aspx</comments><wfw:commentRss>http://blogs.msdn.com/larryosterman/commentrss.aspx?PostID=8848412</wfw:commentRss><wfw:comment>http://blogs.msdn.com/larryosterman/rsscomments.aspx?PostID=8848412</wfw:comment><description>&lt;p&gt;Nils Arthur &lt;a href="http://blogs.msdn.com/larryosterman/archive/2008/08/01/what-s-wrong-with-this-code-part-22-drawing-text.aspx#8805639"&gt;asked&lt;/a&gt; in another post: &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;While we are talking volume controls. Could you explain why it's only possible to lower the volume in Windows (i.e. setting a volume between 0% and 100%) and not raise it (i.e setting it higher than 100%)?&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Before I get into the the answer, let me define some terms:&amp;#160; Attenuation means reducing the amplitude of a signal from a baseline - so if the signal is a full range sine wave going from 1.0 to -1.0, if you attenuate it to 50%, you get a sine wave from 0.5 to -0.5.&amp;#160; I wrote about it (with pictures :)) in &lt;a href="http://blogs.msdn.com/larryosterman/archive/2007/04/03/volume-in-windows-vista-part-1-what-is-volume.aspx"&gt;this post&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;The answer to Nils' question is both simple and complicated. &lt;/p&gt;  &lt;p&gt;The simple part of the answer: Because most PC audio hardware only supports attenuation and not amplification.&lt;/p&gt;  &lt;p&gt;Now for the complicated parts of the answer: We only support what the hardware allows for master volume.&amp;#160; And most hardware only supports attenuation.&amp;#160; There are a lot of reasons for that, but the primary one is that it's dramatically cheaper (and uses less power) to attenuate signals than it is to amplify them. &lt;/p&gt;  &lt;p&gt;The other issue w.r.t. amplification/attenuation is signal quality. As I mentioned in the post on volume above, you can attenuate a sample in the digital domain without loss of fidelity.&amp;#160; However when you attempt to amplify a signal in the digital domain, it clips.&amp;#160;&amp;#160; That means that amplification MUST be done in the analog domain.&amp;#160; Again, this goes to hardware costs - because amplification needs to be done in the analog domain, it means that the audio hardware needs to have an amplifier that can be digitally controlled, which is (again) more expensive.&amp;#160; The audio hardware doesn't even have to support hardware volume - if Windows doesn't find a hardware volume control, it simply inserts a master volume into the audio pipeline. &lt;/p&gt;  &lt;p&gt;Some audio hardware DOES support amplification, but the audio volume controls map the volume control from low to high into a range from 0..100 because it's dramatically simpler to represent that to the user. &lt;/p&gt;  &lt;p&gt;That means that if an audio solution presents a hardware volume from -96.0dB to +3dB (there are a number of them that do that), we'll map that 99dB range into a 0.0 to 1.0 range that maps nicely into a slider.&amp;#160; We've thought about differentiating between attenuation and amplification in the volume UI, but the reality is that the net effect is the same whether we represent amplification or not.&lt;/p&gt;  &lt;p&gt;You can see if your audio hardware supports amplification by going to the multimedia control panel.&amp;#160; Select the audio endpoint you want to check, go to the &amp;quot;Properties&amp;quot; dialog.&amp;#160; On that dialog, check the &amp;quot;Levels&amp;quot; tab, the hardware master volume control is present there.&amp;#160; You can right click on the text box and change the units from linear to dB, you can then move the slider around to see the dB range.&amp;#160; Or you could write some code and call the &lt;a href="http://msdn.microsoft.com/en-us/library/aa964576(VS.85).aspx"&gt;IAudioEndpointVolume::GetVolumeRange&lt;/a&gt; API, which will return the information directly.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8848412" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/larryosterman/archive/tags/Audio/default.aspx">Audio</category></item><item><title>Whatever happened to Wave Out Mix?</title><link>http://blogs.msdn.com/larryosterman/archive/2008/07/11/whatever-happened-to-wave-out-mix.aspx</link><pubDate>Sat, 12 Jul 2008 00:54:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8722085</guid><dc:creator>LarryOsterman</dc:creator><slash:comments>18</slash:comments><comments>http://blogs.msdn.com/larryosterman/comments/8722085.aspx</comments><wfw:commentRss>http://blogs.msdn.com/larryosterman/commentrss.aspx?PostID=8722085</wfw:commentRss><wfw:comment>http://blogs.msdn.com/larryosterman/rsscomments.aspx?PostID=8722085</wfw:comment><description>&lt;p&gt;The Intertubes are all &lt;a href="http://mobile.slashdot.org/article.pl?sid=08/07/11/0128203"&gt;atwitter&lt;/a&gt; with reports that&amp;#160; &lt;a href="http://www.maximumpc.com/article/news/dell_colludes_with_riaa_disables_stereo_mix_without_forewarning"&gt;Dell and other OEMs&lt;/a&gt;&amp;#160;&lt;a href="http://www.ripten.com/2008/07/07/bend-over-dude-youre-getting-a-dell/"&gt;colluded with the RIAA&lt;/a&gt; to &lt;a href="http://www.eggheadcafe.com/software/aspnet/32286847/vista-audio-solution--wh.aspx"&gt;disable the Wave Out Mix&lt;/a&gt;&amp;#160;&lt;a href="http://www.viprasys.com/vb/f44/i-found-solution-enable-stereo-mix-dell-pc-sigmatel-sound-card-22176/"&gt;option&lt;/a&gt; on new laptops.&lt;/p&gt;  &lt;p&gt;Wow, what a tempest in a teapot.&amp;#160; I just LOVE watching conspiracy theories as the echo chamber does it’s magic.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;And of course it’s almost certainly hogwash (I don’t know for sure, but I &lt;em&gt;do&lt;/em&gt; know that some of the rumors are totally stupid).&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;First off, what &lt;em&gt;is&lt;/em&gt; Wave Out Mix?&amp;#160; It’s an option that some audio manufacturers added to their audio hardware (Creative calls it “What U Hear”).&amp;#160; Typically the Wave Out Mix is implemented by connecting the analog output from the DAC (Digital-to-Audio Converter) to a specific input on the ADC (Analog-to-Digital Converter) which is labeled as “Wave Out Mix”.&lt;/p&gt;  &lt;p&gt;If you record on the Wave Out Mix input, you will capture the samples that are being played via Wave Out.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;In Windows Vista, by default we only enable microphone, line in and digital inputs to the audio hardware (the theory being that users typically only want to be able to listen to those inputs).&amp;#160; If the audio solution offers other inputs, they’re still there but we bury them somewhat.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;You can find those additional inputs in mmsys if you start the sound control panel and go to the “Recording” tab.&amp;#160; If you right click and select “Show Disabled Devices” you can enable those alternate inputs.&lt;/p&gt;  &lt;p&gt;In addition, these days many OEMs don’t bother adding the Wave Out Mix support.&amp;#160; It costs slightly more to order chips with Wave Out Mix support than it does to order chips without the functionality, and OEMs are incredibly cost conscious.&amp;#160; The other reason is that for those OEMs that implemented the Wave Out Mix with an analog tap, you can achieve almost the same results with a &lt;a href="http://www.amazon.com/Cables-Go-21062-3-5mm-Stereo/dp/B00007FGUE/ref=pd_bbs_sr_1?ie=UTF8&amp;amp;s=electronics&amp;amp;qid=1215793952&amp;amp;sr=8-1"&gt;$2.50 analog cable&lt;/a&gt; run between the output and the line in input of the machine.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Part of the reason that I know that this is just a conspiracy theory running rampant is that Windows Vista built the support for the Wave Out Mix &lt;a href="http://msdn.microsoft.com/en-us/library/ms678736(VS.85).aspx"&gt;input directly into the operating system&lt;/a&gt;.&amp;#160; If you pass the AUDCLNT_STREAMFLAGS_LOOPBACK flag to the IAudioClient::Initialize method, then the audio system will initialize the engine in loopback mode.&amp;#160; You can start capturing data off that IAudioClient object and you’ll get the post-mix output for the endpoint.&amp;#160; &lt;/p&gt;  &lt;p&gt;The loopback support was designed primarily for use by AEC functionality (which needs to be able to know what samples are being played), but it also allows you to perform essentially the same functionality as the Wave Out Mix hardware used to do.&lt;/p&gt;  &lt;p&gt;If you want to play with the loopback functionality, the WinAudio SDK sample application allows you to capture using the loopback functionality.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8722085" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/larryosterman/archive/tags/Audio/default.aspx">Audio</category></item></channel></rss>