Tuesday, October 28, 2008 10:53 AM
Maurits
How long can the logoff sound be?
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
|
|
sample rate
|
mono
|
stereo
|
surround
|
5.1
|
7.1
|
|
8000
|
524.29
|
262.14
|
131.07
|
87.38
|
65.54
|
|
11025
|
380.44
|
190.22
|
95.11
|
63.41
|
47.55
|
|
16000
|
262.14
|
131.07
|
65.54
|
43.69
|
32.77
|
|
22050
|
190.22
|
95.11
|
47.55
|
31.70
|
23.78
|
|
32000
|
131.07
|
65.54
|
32.77
|
21.85
|
16.38
|
|
44100
|
95.11
|
47.55
|
23.78
|
15.85
|
11.89
|
|
48000
|
87.38
|
43.69
|
21.85
|
14.56
|
10.92
|
|
88200
|
47.55
|
23.78
|
11.89
|
7.93
|
5.94
|
|
96000
|
43.69
|
21.85
|
10.92
|
7.28
|
5.46
|
|
176400
|
23.78
|
11.89
|
5.94
|
3.96
|
2.97
|
|
192000
|
21.85
|
10.92
|
5.46
|
3.64
|
2.73
|
|
|
|
|
|
|
|
signed 16-bit int
|
|
sample rate
|
mono
|
stereo
|
surround
|
5.1
|
7.1
|
|
8000
|
262.14
|
131.07
|
65.54
|
43.69
|
32.77
|
|
11025
|
190.22
|
95.11
|
47.55
|
31.70
|
23.78
|
|
16000
|
131.07
|
65.54
|
32.77
|
21.85
|
16.38
|
|
22050
|
95.11
|
47.55
|
23.78
|
15.85
|
11.89
|
|
32000
|
65.54
|
32.77
|
16.38
|
10.92
|
8.19
|
|
44100
|
47.55
|
23.78
|
11.89
|
7.93
|
5.94
|
|
48000
|
43.69
|
21.85
|
10.92
|
7.28
|
5.46
|
|
88200
|
23.78
|
11.89
|
5.94
|
3.96
|
2.97
|
|
96000
|
21.85
|
10.92
|
5.46
|
3.64
|
2.73
|
|
176400
|
11.89
|
5.94
|
2.97
|
1.98
|
1.49
|
|
192000
|
10.92
|
5.46
|
2.73
|
1.82
|
1.37
|
|
|
|
|
|
|
|
24-bit container: signed
20-bit int or signed 24-bit int
|
|
sample rate
|
mono
|
stereo
|
surround
|
5.1
|
7.1
|
|
8000
|
174.76
|
87.38
|
43.69
|
29.13
|
21.85
|
|
11025
|
126.81
|
63.41
|
31.70
|
21.14
|
15.85
|
|
16000
|
87.38
|
43.69
|
21.85
|
14.56
|
10.92
|
|
22050
|
63.41
|
31.70
|
15.85
|
10.57
|
7.93
|
|
32000
|
43.69
|
21.85
|
10.92
|
7.28
|
5.46
|
|
44100
|
31.70
|
15.85
|
7.93
|
5.28
|
3.96
|
|
48000
|
29.13
|
14.56
|
7.28
|
4.85
|
3.64
|
|
88200
|
15.85
|
7.93
|
3.96
|
2.64
|
1.98
|
|
96000
|
14.56
|
7.28
|
3.64
|
2.43
|
1.82
|
|
176400
|
7.93
|
3.96
|
1.98
|
1.32
|
0.99
|
|
192000
|
7.28
|
3.64
|
1.82
|
1.21
|
0.91
|
|
|
|
|
|
|
|
32-bit container: signed
20-bit int, signed 24-bit int, or float32
|
|
sample rate
|
mono
|
stereo
|
surround
|
5.1
|
7.1
|
|
8000
|
131.07
|
65.54
|
32.77
|
21.85
|
16.38
|
|
11025
|
95.11
|
47.55
|
23.78
|
15.85
|
11.89
|
|
16000
|
65.54
|
32.77
|
16.38
|
10.92
|
8.19
|
|
22050
|
47.55
|
23.78
|
11.89
|
7.93
|
5.94
|
|
32000
|
32.77
|
16.38
|
8.19
|
5.46
|
4.10
|
|
44100
|
23.78
|
11.89
|
5.94
|
3.96
|
2.97
|
|
48000
|
21.85
|
10.92
|
5.46
|
3.64
|
2.73
|
|
88200
|
11.89
|
5.94
|
2.97
|
1.98
|
1.49
|
|
96000
|
10.92
|
5.46
|
2.73
|
1.82
|
1.37
|
|
176400
|
5.94
|
2.97
|
1.49
|
0.99
|
0.74
|
|
192000
|
5.46
|
2.73
|
1.37
|
0.91
|
0.68
|
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. :-)