Category Archives: Technology

iTunes 10.2.1 fails to decode MP3 files properly

It is generally assumed that all major MP3 playback software produces the same output. The reason for this thinking is that the MPEG standard defines a decoder in a strict way, allowing only small deviations due to rounding.

A few years ago, I was disabused of that idea when I did an informal test to compare several well-known music players (iTunes 7, Winamp, Foobar2000, Windows Media Player). The test revealed iTunes 7 to be the outlier producing different output from the rest of the pack.

Today, I will present the results of a more rigorous test using the latest version of iTunes (10.2.1).

Test setup

  • Windows 7 Professional SP1 (32-bit) with all the latest updates
  • Auzentech X-Meridian 7.1 sound card
  • Cool Edit Pro 2.0 audio editing software

Tested players

  • Windows Media Player 12.0.7601.17514
  • Winamp 5.56
  • Foobar2000 1.1.5
  • iTunes 10.2.1

MethodolOgy

I played two 10-second MP3 clips in each player, recording the output digitally with Cool Edit Pro 2.0 using the S/PDIF loopback mechanism provided by the sound card driver.

All postprocessing options (crossfade, sound check, etc.) were turned off. Both application and system volume were at 100%.

I used the following MP3 files:

  1. a 10-second clip from Wszystko Ch. by Elektryczne Gitary encoded with LAME 3.97 at 256 kbps ABR with high encoding quality (download file)
  2. a 10-second clip from Time by Pink Floyd encoded with LAME 3.98 at 256 kbps ABR with high encoding quality (download file)

After recording in Cool Edit Pro (as a 16-bit, 44.1 kHz file which matched the source material), I saved each stream as a text file, which looked like this:

-354	-172
1	203
-447	-443
-2490	-3088
-3504	-3676
-3233	-2944
-3206	-3867
-2829	-4348
-2391	-4461
-2196	-4165...

I also opened each of the two MP3 files directly in Cool Edit Pro 2.0 and then saved it as a text file. This file was used as a reference: the output of each player was compared against it. Cool Edit Pro 2.0 uses a Fraunhofer MP3 decoder (Fraunhofer IIS is the institute where MP3 was developed).

I opened the text files in Notepad++ and synchronized them by discarding the initial silence in each file. The goal was to make sure that the first sample in each file corresponded to the start of the clip to enable direct sample-by-sample comparison.

After synchronization, each text file was opened in Cool Edit Pro 2.0 again. Each waveform was subtracted from the reference waveform to reveal the differences.

Results

Each waveform below shows the difference between the reference output stream (Cool Edit Pro 2.0 with Fraunhofer decoder) and the output stream produced by an MP3 player.

Wszystko Ch. – Windows Media Player 12

wszystko-wmp

Wszystko Ch. – Winamp 5.56

wszystko-winamp

Wszystko Ch. – Foobar2000 1.1.5

wszystko-foobar

Wszystko Ch. – iTunes 10.2.1

wszystko-itunes10

As you can see, Windows Media Player, Winamp and Foobar2000 all produced output that matched the reference stream very closely. A review of the text files showed that all three players produced virtually identical bitstreams: the differences between individual samples and the reference stream did not exceed 1, or in rare cases, 2. These differences were not large enough to register on the waveform view, even with magnification.

iTunes 10.2.1, however, added significant distortion that can be seen in the waveform above. In some cases, the samples deviated from the reference values by as much as 5 percent (e.g. 1811 instead of 1719). You can also download the above waveform as a WAV file to hear the “enhancement” added by iTunes. It basically sounds like a very high-pitched sound (> 15000 Hz) of an uneven volume. The ability to hear it will depend on your age: younger listeners will find it more prominent. (Of course, during normal music listening this sound would be very hard to hear.)

The output generated by iTunes 10.2.1 did not depend on the output setting in QuickTime (which iTunes uses to play audio). DirectSound, WaveOut and Windows Audio Sessions all produced the same output.

Time – Windows Media Player 12

time-wmp

TimeWinamp 5.56

time-winamp

Time Foobar2000 1.1.5

time-foobar

TimeiTunes 10.2.1

time-itunes10

Again, Windows Media Player, Winamp and Foobar2000 match the reference stream, while iTunes engages in creative decoding. In this sample, the distortion is smaller: personally, I cannot hear anything when I play the above waveform.

Conclusions

Cool Edit Pro 2.0, Windows Media Player 12, Winamp 5.56 and Foobar2000 1.1.5 all decoded the MP3 clips in virtually the same way. iTunes 10.2.1, on the other hand, produced a distorted output stream. While the distortion is probably inaudible in normal listening situations, it seems to mean that the latest version of iTunes fails to conform to the MP3 standard and is probably best avoided by users who care about audio fidelity.

Notes

In further tests using the same samples, I found that iTunes 9.2.1 matched the reference stream as well as WMP, Winamp and Foobar2000 – it would therefore seem that it decodes MP3 files properly. I also evaluated MediaMonkey 3 and detected very significant distortion (much larger than iTunes 10.2.1), even after disabling as many postprocessing options as I could find (volume leveling, clipping protection, crossfade, smooth stop/seek/pause, remove silence – did I miss anything?).

Check out the thread at Hydrogenaudio for an interesting discussion and independent measurements which confirm my findings.

Windows 7: The almost-there operating system

One thing that struck me soon after I upgraded my main computer from Windows XP to Windows 7 is how many things it gets almost right. The OS is full of well-engineered features that seem awesome, yet – upon closer inspection – turn out to have some hidden flaw that renders them useless or at least very frustrating.

Math Input Panel

I’ll start with the Math Input Panel. This is a feature so awesome that you want to show it to your friends. You scribble a mathematical expression with your mouse, touch screen or graphics tablet, and it is magically converted into proper typographical form.

Screenshot of the Math Input Panel

But then you want to insert your formula into a document. You open the built-in (and greatly improved) Write editor of Windows 7. You click “Insert”. Nothing happens. You open Paint (also improved in Windows 7) and try again. Nothing. OpenOffice Writer? Nothing. Word 2003? Nada. Does this thing even work?

Then you read the small print. The Math Input Panel only works with applications that support MathML. As of this writing, the only popular application with MathML support would be Word 2007. There are no other output options. The Math Input Panel cannot generate code in LaTeX, which is the de facto standard in the mathematical community and has been adopted by projects such as Wikipedia, WordPress and jsMath. It cannot generate OLE objects for older versions of Word. It does not even let you paste the damn equation as an image. How can something so ingenious be so useless?

Windows Firewall

On its face, the Windows Firewall has everything you need to say goodbye to third-party firewalls like Comodo. It’s lean, well-integrated with the OS, and the new “Windows Firewall with Advanced Security” console lets you specify detailed rules for inbound and outbound connections to/from specific programs and ports:

Screenshot of the Windows Firewall control panel

Perfect, isn’t it? Unfortunately, it has two fatal shortcomings:

  • Any application can add its own exceptions to it by means of a simple API call. Why? The official rationale is that it is not the firewall’s job to block malicious applications from accessing the network – once you have executed malicious code on your computer, it can pretty much do whatever it wants, including sending data via a trusted process in a way that is invisible to the firewall. There is some truth to this, but a less permissive firewall would still make things that much harder for wrongdoers. More importantly, however, this reasoning misses the use case where you want to prevent legitimate applications from “phoning home”. If I block Adobe Photoshop from using my Internet connection, it probably won’t go so far as to hijack another process, but it will make use of an official Windows API to add an outbound rule for itself.
  • There is no way to get pop-up notifications about outbound connections. In a typical software firewall, when a new application attempts to establish an outbound connection, you get a pop-up window which enables you to allow or block the connection, and add a permanent rule for this application. The Windows Firewall does not have this functionality. The only thing you can enable is a notification about blocked incoming connections, which gives you a chance to unblock an application. What about outbound connections? The best you can do is block all unknown applications, but then you will never know that an application wanted to access the Net. It will just silently fail.

Sticky Notes

Screenshot showing two sticky notes on the desktopThe Sticky Notes feature looks really useful at first. For someone who stares at his screen for most of the day, the Windows desktop seems to be a logical place for “notes to self”. The UI is pretty straightforward and has some nice touches, such as the fact that every note has a little plus button that lets you quickly add another note.

Unfortunately, for some unknown reason Sticky Notes is not a gadget, like the weather thingy you can see on the screenshot above. It’s a separate application. One that cannot be minimized to the system tray. And I don’t know about you, but I don’t like tiny utilities like this taking up space on my taskbar. I need the space so I can comfortably switch between my productivity applications.

Windows Backup

The final “almost perfect” Windows 7 feature I’m going to talk about is Windows Backup. Now this is a seriously exciting utility that promises to replace third-party backup applications like Acronis True Image. On the face of it, it has everything you need. Scheduled and on-demand backups? Check. System drive snapshots? Check. Backups of selected folders? Check. Incremental backups? Check. Restore from bootable CD/DVD? Check. Time needed to back up 500 GB of data to an external USB hard drive? 35 hours. That’s right. Thirty-five freaking hours. (If you suspect there is something wrong with my setup, read these other reports.) Try it once and you’ll never try it again.

It’s as if Microsoft developed a perfectly good backup application and then decided to cripple it on purpose, just to let ISVs make a buck. I don’t want to give my money to Acronis again, especially after reading their official response to a compression bug in TrueImage Home 11 (“just turn off compression”), but it seems I’m going to have to.

Why you should use English versions of your OS and other software

Even though I’m writing this blog in English, I know I have a considerable number of readers in non-English-speaking countries, such as my native Poland. This post is for them. If you are American, British, Australian, New Zealand(ish?)Kiwi — sorry, there’s nothing for you here. See you next week.

Now for the rest of you. As you can probably figure out from the title, I’m going to try to convince you to use English versions of your software. Now, I am the webmaster of a site which tells you how to learn English, so you might expect I would tell you how daily exposure to English menu items, system messages, help files, and all the other textual UI elements will program your brain with correct English. (Which, by the way, would all be true.)

But today I’m not going to write about the importance of getting English input every chance you get. Instead, I will give you a very practical reason to install English versions of your operating system and other software rather than versions localized in your native language.

Suppose you have just updated the drivers for your nVidia card. Unfortunately, something has gone wrong and every time you reboot your machine you see the following error message:

Sterownik ekranu przestał działać, ale odzyskał sprawność.

(The error message is in Polish because, in this example, we will assume you are Polish and use the Polish version of Windows.) “Motyla noga”, you curse to yourself while opening your Web browser. If there’s one thing you’ve learned online, it’s that the Internet has the answer to your computer question. Other people must have had the same problem and there must be a forum post somewhere which has the solution.

But what are you going to type into Google? What keywords would be likely to occur in this forum post you want to find? In all likelihood, the poster would have quoted the error message itself.

Except they would have quoted it in English, not Polish. Let’s face it — it is much more probable that the solution to your problem is posted on one of the many English-language tech forums than on one of the few Polish-language ones. A Google Groups search on “nVidia” turns up 17,000,000 group threads in English and only 211,000 in Polish (1/80 of the English figure).

So now you’re stuck with your Polish error message, trying to figure out the exact words the English version might have used. “The screen driver has failed?” “Malfunctioned?” “Stopped working?”

Of course, I have an English-language version of Windows, so if I am having computer issues, I can simply read the English error message off the screen (in our example it’s “The display driver has stopped responding and has successfully recovered”), type that magic phrase into Google together with the name of the malfunctioning device or application and boom! — within minutes I’m reading about the secret registry setting that makes it all okay.

Now that I think about it, having an English-language version of Windows probably accounts for something like 30% of my troubleshooting ability. Moreover, using English-language software is useful not only when troubleshooting — I find it equally helpful when I just want to learn how to do something in Windows, Office, Photoshop or even a Web app like GMail. I can just search on the names I see instead of wondering what is the English name for warstwy dopasowania (adjustment layers). And I can apply the solution more easily because I don’t have to translate all the names back into Polish.

It would perhaps behoove me to give you “the other side” of the argument, but the matter seems pretty clear-cut to me: If you want to get help with your software (and who doesn’t?), it helps to use the same version that most of the potential helpers use. And with this, I leave you.

What you should know about Volume Shadow Copy/System Restore in Windows 7 & Vista (FAQ)

What is volume shadow copy?

Volume Shadow Copy is a service that creates and maintains snapshots (“shadow copies”) of disk volumes in Windows 7 and Vista. It is the back-end of the System Restore feature, which enables you to restore your system files to a previous state in case of a system failure (e.g. after a failed driver or software installation).

Does volume shadow copy protect only my system files?

No. Volume Shadow Copy maintains snapshots of entire volumes. By default, it is turned on for your system volume (C:) and protects all the data on that volume, including all the system files, program files, user settings, documents, etc.

How is this different from what’s in Windows XP?

In Windows XP, System Restore does not use the Volume Shadow Copy service. Instead, it uses a much simpler mechanism: the moment a program attempts to overwrite a system file, Windows XP makes a copy of it and saves it in a separate folder. In Windows XP, System Restore does not affect your documents – it only protects files with certain extensions (such as DLL or EXE), the registry, and a few other things (details). It specifically excludes all files in the user profile and the My Documents folder (regardless of file extension).

When are the shadow copies created?

Volume shadow copies (restore points) are created before the installation of device drivers, system components (e.g. DirectX), Windows updates, and some applications.

In addition, Windows automatically creates restore points at hard-to-predict intervals. The first thing to understand here is that the System Restore task on Vista and 7 will only execute if your computer is idle for at least 10 minutes and is running on AC power. Since the definition of “idle” is “0% CPU usage and 0% disk input for 90% of the last 15 minutes, plus no keyboard/mouse activity” (source), it could take days for your machine to be idle, especially if you have a lot of programs running in the background.

As you see, the frequency with which automatic restore points are created is hard to estimate, but if you use your machine every day on AC power and nothing prevents it from entering an idle state, you can expect automatic restore points to be created every 1-2 days on Windows Vista and every 7-8 days on Windows 7. Of course, the actual frequency will be higher if you count in the restore points created manually by you and those created before software installations.

Here’s a more precise description: By default, the System Restore task is scheduled to run every time you start your computer and every day at midnight, as long as your computer is idle and on AC power. The task will wait for the right conditions for up to 23 hours. These rules are specified in Scheduled Tasks and can be changed by the user. If the task is executed successfully, Windows will create a restore point, but only if enough time has passed since the last restore point (automatic or not) was created. On Windows Vista the minimum interval is 24 hours; on Windows 7 it is 7 days. As far as I know, this interval cannot be changed.

What cool things can I do with Volume Shadow Copy?

  • If your system malfunctions after installing a new video card driver or firewall software, you can launch System Restore and roll back to a working system state from before the installation. If you can’t get your system to boot, you can also do this from the Windows Setup DVD. This process is reversible, i.e. your current state will be automatically saved as a restore point, to which you can later go back. (Note: System Restore will not roll back your documents and settings, just the system files.)
  • previous_versionsIf you accidentally delete 10 pages of your dissertation, you can right-click the document, choose Restore previous versions, and access a previous version of it. You can open it (in read-only mode) or copy it to a new location.
  • If you accidentally delete a file or folder, you can right-click the containing folder, choose Restore previous versions, and open the folder as it appeared at the time a shadow copy was made (see screenshot below). All the files and folders that you deleted will be there!

previous_folder

Note: While the Volume Shadow Copy service and System Restore are included in all versions of Windows Vista, the Previous versions user interface is only available in Vista Business, Enterprise and Ultimate. On other Vista versions, the previous versions of your files are still there; you just cannot access them easily. The Previous versions UI is available in all versions of Windows 7.

Is Volume Shadow Copy a replacement for versioning?

No. A versioning system lets you access all versions of a document; every time you save a document, a new version is created. Volume Shadow Copy only allows you to go back to the moment when a restore point was made, which could be several days ago. So if you do screw up your dissertation, you might have to roll back to a very old version.

Is Volume Shadow Copy a replacement for backups?

No, for the following reasons:

  • Shadow copies are not true snapshots. When you create a restore point, you’re not making a new copy of the drive in question — you’re just telling Windows: start tracking the changes to this drive; if something changes, back up the original version so I can go back to it. Unchanged data will not be backed up. If the data on your drive gets changed (corrupted) for some low-level reason like a hardware error, VSC will not know that these changes happened and will not back up your data. (see below for a more detailed description of how VSC works)
  • The shadow copies are stored on the same volume as the original data, so when that volume dies, you lose everything.
  • With the default settings, there is no guarantee that shadow copies will be created regularly. In particular, Windows 7 will only create an automatic restore point if the most recent restore point is more than 7 days old. On Windows Vista, the minimum interval is 24 hours, but remember that the System Restore task will only run if your computer is on AC power and idle for at least 10 minutes, so it could take days before the conditions are right, especially if you run a lot of background processes or do not use your computer frequently.
  • There is no guarantee that a suitable shadow copy will be there when you need it. Windows deletes old shadow copies without a warning as soon as it runs out of shadow storage. With a lot of disk activity, it may even run out of space for a single shadow copy. In that case, you will wind up with no shadow copies at all; and again, there will be no message to warn you about it.

How much disk space do Volume Shadow Copies take up?

By default, the maximum amount of storage available for shadow copies is 5% (on Windows 7) or 15% (on Vista), though only some of this space may be actually allocated at a given moment.

You can change the maximum amount of space available for shadow copies in Control Panel | System | System protection | Configure.

How efficient is Volume Shadow Copy?

It’s quite efficient. The 5% of disk space that it gets by default is usually enough to store several snapshots of the disk in question. How is this possible?

The first thing to understand is that volume shadow copies are not true snapshots. When a restore point is created, Volume Shadow Copy does not create a full image of the volume. If it did, it would be impossible to store several shadow copies of a volume using only 5% of that volume’s capacity.

Here’s what really happens when a restore point is created: VSC starts tracking the changes made to all the blocks on the volume. Whenever anyone writes data to a block, VSC makes a copy of that block and saves it on a hidden volume. So blocks are “backed up” only when they are about to get overwritten. The benefit of this approach is that no backup space is wasted on blocks that haven’t changed at all since the last restore point was created.

Notice that VSC operates on the block level, that is below the file system level. It sees the disk as a long series of blocks. (Still, it has some awareness of files, as you can tell it to exclude certain files and folders.)

The second important fact is that shadow copies are incremental. Suppose it’s Wednesday and your system has two shadow copies, created on Monday and Tuesday. Now, when you overwrite a block, a backup copy of the block is saved in the Tuesday shadow copy, but not in the Monday shadow copy. The Monday copy only contains the differences between Monday and Tuesday. More recent changes are only tracked in the Tuesday copy.

In other words, if we were to roll back an entire volume to Monday, we would take the volume as it is now, “undo” the changes made since Tuesday (using the blocks saved in the Tuesday shadow copy), and finally “undo” the changes made between Monday and Tuesday. So the oldest shadow copy is dependent on all the more recent shadow copies.

When I delete a 700 MB file, does VSC add 700 MB of data to the shadow copy?

No. When you delete a file, all that Windows does is remove the corresponding entry (file name, path, properties) from the Master File Table. The blocks (units of disk space) that contained the file’s contents are marked as unused, but they are not actually deleted. So all the data that was in the file is still there in the same blocks, until the blocks get overwritten (e.g. when you copy another file to the same volume).

Therefore, if you delete a 700 MB movie file, Volume Shadow Copy does not have to back up 700 MB of data. Because it operates on the block level, it does not have to back up anything, as the blocks occupied by the file are unchanged! The only thing it has to back up is the blocks occupied by the Master File Table, which has changed.

If you then start copying other files to the same disk, some of the blocks formerly occupied by the 700 MB file will get overwritten. VSC will make backups of these blocks as they get overwritten.

What are the security implications of Volume Shadow Copy?

Suppose you decide to protect one of your documents from prying eyes. First, you create an encrypted copy using an encryption application. Then, you “wipe” (or “secure-delete”) the original document, which consists of overwriting it several times and deleting it. (This is necessary, because if you just deleted the document without overwriting it, all the data that was in the file would physically remain on the disk until it got overwritten by other data. See question above for an explanation of how file deletion works.)

Ordinarily, this would render the original, unencrypted document irretrievable. However, if the original file was stored on a volume protected by the Volume Shadow Copy service and it was there when a restore point was created, the original file will be retrievable using Previous versions. All you need to do is right-click the containing folder, click Restore previous versions, open a snapshot, and, lo and behold, you’ll see the original file that you tried so hard to delete!

The reason wiping the file doesn’t help, of course, is that before the file’s blocks get overwritten, VSC will save them to the shadow copy. It doesn’t matter how many times you overwrite the file, the shadow copy will still be there, safely stored on a hidden volume.

Is there a way to securely delete a file on a volume protected by VSC?

No. Shadow copies are read-only, so there is no way to delete a file from all the shadow copies.

A partial solution is to delete all the shadow copies (by choosing Control Panel | System | System protection | Configure | Delete) before you wipe the file. This prevents VSC from making a copy of the file right before you overwrite it. However, it is quite possible that one of the shadow copies you just deleted already contained a copy of the file (for example, because it had recently been modified). Since deleting the shadow copies does not wipe the disk space that was occupied by them, the contents of the shadowed file will still be there on the disk.

So, if you really wanted to be secure, you would also have to wipe the blocks that used to contain the shadow copies. This would be very hard to do, as there is no direct access to that area of the disk.

Some other solutions to consider:

  • You could make sure you never save any sensitive data on a volume that’s protected by VSC. Of course, you would need a separate VSC-free volume for such data.
  • system_protectionYou could disable VSC altogether. (After disabling VSC, you may want to wipe the free space on your drive to overwrite the blocks previously occupied by VSC, which could contain shadow copies of your sensitive data.) However, if you disable VSC, you also lose System Restore functionality.  Curiously, Windows offers no option to enable VSC only for system files. If you want to protect your system, you also have to enable Previous versions (see screenshot to the right).
  • The most secure approach is to use an encrypted system volume. That way, no matter what temporary files, shadow copies, etc. Windows creates, it will all be encrypted.

Notice that VSC only VSC only lets you recover files that existed when a restore point was created. So if the sequence of events is as follows:

create file → create restore point → make encrypted copy → overwrite original file

the original file will be recoverable. But if the sequence is:

create restore point → create file → make encrypted copy → overwrite original file

you are safe. If you make sure to encrypt and wipe files as soon as you create them, so that no restore point gets created after they are saved on disk in unencrypted form, there will be no way to recover them with VSC. However, it is not easy to control when Windows creates a restore point; for example, it can do it at any time, just because your computer happens to be idle.

Can I prevent VSC from keeping snapshots of certain files and folders?

Yes, but you have to edit the registry to do that. Here are detailed instructions from MSDN.

What happens when VSC runs out of space?

Most of the time, most of the data on your disk stays unchanged. However, suppose you uninstall a 5 GB game and then install another 5 GB game in its place. This means that 5 GB worth of blocks got overwritten and had to be backed up by VSC.

In such “high-churn” scenarios, VSC can run out of space pretty quickly. What happens then? VSC deletes as many previous shadow copies as necessary, starting from the oldest, until it has enough space for the latest copy. In the rare event that there isn’t enough space even for the one most recent copy, all the shadow copies will be deleted. There are no partial copies.

Thanks to Adi Oltean, who was one of the engineers of Volume Shadow Copy at Microsoft, for answering my questions on the subject.