Matthew van Eerde's web log
I am a Software Development Engineer in Test working for the Windows Sound team. You can contact me via email: mateer at microsoft dot com
Friend key: 28904932216450_59cd9d55374be03d8167d37c8ff4196b
Windows has a customizable soundtrack - when different things happen, sounds play. You can live with the default sounds, turn all the sounds off, or substitute your own sounds. All configurable via the Sound control panel:
You can assign short or long, pleasant or annoying sounds to any event in the list. For example, you could rip a CD to .wav format and assign it to the "Maximize" event.
There are two events that are a little finicky about how long the sound is, though: the "Exit Windows" and "Windows Logoff" events. If you assign a sound that is too long to either of these events, it won't play. It plays when you click the "Test" button, but when you actually log off or shut down, the sound doesn't play.
How long is too long?
Before the answer, a quick review of .wav files.
You can have any number of frames per second. CDs use a sample rate of
44100 frames per second; DVDs use 48000 frames per second. This is
usually one of (11025, 22050, 44100, 88200, 176400; 48000, 96000,
19200; 8000, 16000, 32000).
You can have any number of samples in a frame: mono (1 channel), stereo (two channels), surround (four channels), 5.1 (six channels), 7.1 (eight channels), or a different number.
Each sample is a number. This can be a floating-point number (32 bits), an unsigned integer (8 bits), or a signed integer (16 bits, 20 bits, 24 bits, 32 bits.) The 20 bit and 24 bit integers can be either in 24-bit containers or in 32-bit containers.
The fatness of the samples, and how many there are per second, determines how many bytes a second of .wav data will contain. The formula is:
bytes/second = (samples/frame, AKA channels) * (frames/second, AKA sample rate) * (bits/sample) / (bits/byte, always 8)
For performance reasons, Windows Vista limits the size of shutdown/logoff sounds to 4 MB.
So how long is 4MB? Here's the answer in tabular form for most common formats. Lengths are in seconds.
unsigned 8-bit int
signed 16-bit int
24-bit container: signed
20-bit int or signed 24-bit int
32-bit container: signed
20-bit int, signed 24-bit int, or float32
The most common audio format by far is 44.1 kHz / stereo / 16-bit; if your .wav file is of this format, you get just under 23 seconds before you hit the 4 MB limit.
If you want to go over this limit, or if you want a multichannel logoff sound, you can get away with downsampling. If you shoehorn in a longer sound, though, you may run into this:
If you just wait, the sound will play to the end and logoff will continue.
If you click "Cancel", explorer.exe will exit anyway and you'll be logged in with no shell.
A trick to get the shell back: Ctrl-Shift-Esc to bring up Task Manager, and File | New Task (Run...) | explorer.exe to reinvoke the shell. This also allows you to determine which of the notification area icons are well-behaved. :-)