View RSS Feed

The Ill-Tempered Audiophool

iTunes, Audio MIDI Setup, and all that

Rate this Entry
One of the first things I learned when I first visited this site about a year and a half ago was the following:

iTunes (on OS 10.6.X at the time) will only play a track bit-perfectly if Audio MIDI Setup's sample frequency matches that of the track in iTunes. Otherwise it (or core audio?) up/down samples. I was told that in order to play a 96kHz track without resampling directly after playing a 44.1 kHz track, it was not enough simply to reset Audio MIDI Setup, but one had to first reset Audio MIDI Setup to 96kHz, then quit iTunes, then restart iTunes, and then play the 96kHz track.

Most of my quest with third-party software has been to make that transition more seamless. The differences in sound quality, to my ear, through my equipment (which upsamples everything), is not particularly striking.

Anyway, today Paul mentioned in another thread that more current versions of iTunes no longer necessitate the quit/restart cycle. If there was a way to automatically read the native sampling frequency of the track about to be played, match it to that of Audio MIDI, and if necessary pause the track and change it, then resume playing, you could get bit-perfect playback with iTunes with no further heroics.

I have no reason not to believe this, but I am suspicious, because it sounds almost too good to be true. Moreover, Bob Stern and I cobbled together a shell-script and iTunes plug-in to do this. I've now got versions for 10.6 and 10.7.

If someone could verify that iTunes indeed now behaves as Paul says, I would be happy to make these freely available to the community. Please let me know...

Personal Blogs


  1. The Computer Audiophile's Avatar
    I can check this out tomorrow using my Alpha DAC and HDCD indicator. If the rate isn't correct the HDCD light will not illuminate.
  2. wgscott's Avatar
    Paul did what sounds to me like a fairly definitive test, so I am going to go ahead and package this up for anyone who wants it...

    If anyone hears anything to the contrary, please let me know.


  3. Paul R's Avatar
    I fed it into the Proton and the sample rate LEDs changed, which is a pretty good indicator. I meant to send you a note this morning. :)

    One thing, it works fine on a Macbook running Lion (32bit OS, 64bit iTunes) but did not work on the Mini, running 64bit OS/ 64 bit iTunes. It is probably user error, as I was pretty tired when I tried it last night, and it is also why I didn't send back another note.

    Chris - if you could double check it on your gear, that would be great.

  4. wgscott's Avatar
    It worked on my 2009 mini, running 64bit OS/ 64 bit iTunes. I only tried it with the built-in speaker.

    The one current major flaw is that the user has to have Audio MIDI setup pre-focused on the right output device.
  5. wgscott's Avatar
    Also, for GUI scripting to work, you need to enable assistive devices in the Universal Access pane of System Preferences.

    Normally an applescript would warn you about this, but I am using it embedded in a shell script, so the error, and instructions on what to do about it, isn't reported to the user.
  6. bleedink's Avatar
    Sorry to hijack this thread, but I got lost reading this. Is iTunes in fact changing the sampling rate automatically or not? One person says yes, then the next person offers a script to do it...which is it?!@?@? Sorry, just not very clear reading this what the results are....
  7. Paul R's Avatar
    Naw. iTunes will not, by itself, automatically change the sample rate.

    But, we are thinking that you can go into the Audio/Midi setup and change the sample rate, and it will change without exiting and restarting iTunes.

    This is significant because Bill's script will automatically set the sample rate in Audio/Midi for each track.

    For all intents and purposes, with Bill's script installed, that means automatic sample rate switching in iTunes.

    What we have to verify is that the sample rate actually changes without the need to exit and restart iTunes. You might test it on your system, if you have a way to see the sample rate your DAC is seeing. (LEDs, Display, etc.)

  8. Paul R's Avatar
    I am pretty sure that will be the culprit. Can't check it till I get home though, I forgot to setup remote access to that Mac from the internet. :)

  9. wgscott's Avatar
    ... thing.

    For those who want to test on 10.7, do this:

    1. Open your terminal.

    2. cd ~/Desktop

    3. Issue the commands:

    curl -O

    mv nyquist_switching_iTunes_plugin_10.7_only.tgz /.

    cd /

    sudo tar xvfz nyquist_switching_iTunes_plugin_10.7_only.tgz

    4. Open iTunes, go to the Script icon in the menu bar, and select "ToggleiTunesNyquist". This allows you to turn it on or off, or uninstall the plug-in. If you select "Yes", it will prompt you to turn on assistive devices if you haven't done so (this will only happen once) and then it will prompt you to go to Audio MIDI Setup and select the appropriate output device.

    If it is ok, it should all just work.

    Assuming this proves to be useful, I will make a more user-friendly installer, each for 10.6 and 10.7.
  10. bleedink's Avatar
    Thanks Paul you cleared that up for me. I'd forgotten about all that mess you have to deal with when using iTunes. So just to clarify, this script will work better now as iTunes no longer needs to shut itself down first correct? Thanks for the tip! I may have to use iTunes just to see how it is these days.
  11. Paul R's Avatar
    So we hope! :)
  12. JR_Audio's Avatar
    Just yesterday, I have tested and measured some play back programs on Mac OSX 10.6.8 and can tell for 100 %, that ITunes: 10.5 (141) still does not change sample rates automatically.

  13. Paul R's Avatar

    Please play a track, and while the track is playing, open up Audio/Midi and change the sample rate. See if it changes on your DAC, without having to exit and restart iTunes. Also, please try it with no track playing. :)


  14. wgscott's Avatar

    The question is if you manually change the sample frequency in the Audio MIDI Setup window to match that of a non-redbook track in iTunes, and then without restarting iTunes, start to play the track, does iTunes do the right thing, or is it down-sampled and then up-sampled, or does it then output bit-perfectly?

    If the latter, then we have an Applescript/plug-in solution.
  15. JR_Audio's Avatar
    so I can't test it now, but for me the app must change the sample rate automatically without user interfering, so changing that in MIDI setup is no solution for me. Also iTunes does not have exclusive access to the device (Hog Mod), and no integer Playback under Snow Leopard, but I must say, that iTunes 10.5 does sound better than the earlier versions, it seams to have a similar play from RAM feature, because you can see on the activity monitor, that the cpu drops after every track starts to down to 1 %, but still no comparison to AudirvanaPlus, Decibel oder BitPerfect.

  16. Audio_ELF's Avatar
    @Jurgen I think you're missing the point...

    In the past if the sample rate in Audio Midi is set when you start iTunes (call it sample rate A) and you then change the sample rate (to rate B) in Audio Midi while iTunes is started: iTunes outputs via resamples (if needed) the music to rate A then Core Audio resamples it to rate B...

    It's now said the IF Audio Midi is changed iTunes realises this change has been made and will output or resample at rate B avoiding the potential double resampling...

    Second to this Scott has created a script which changes the sample rate automatically via Audio Midi to match the sample rate of the file being played... This is only of significance if iTunes behaviour is now correct (Apple have acknowledged this was a bug previously though they said it was low priority to fix).

  17. The Computer Audiophile's Avatar
    Hi Guys - This is actually classic iTunes behavior. I just checked with my Alpha DAC and confirmed nothing has changed. iTunes must still be closed and reopened after an Audio Midi change.

    Here's what's happening to Paul's playback.

    Audio Midi set to 44.1 -> Open iTunes -> Play 44.1 track = Bit perfect

    Change Audio Midi to 96k -> leave iTunes open -> Play 96k track = Mess

    Mess = 96k track -> itunes downsamples to 44.1k -> Audio Midi upsamples the 44.1k to 96k -> output to DAC.

    Paul - When your proton lights up the sample rate indicator it's receiving that information from Audio Midi regardless of what iTunes is set at.
  18. Paul R's Avatar
    Thanks Chris - can't say I am not disappointed, but it is always better to have the facts.

    Darn it all!

    It sure fooled me, though I admit, I didn't listen to it so much as test to see if the output sample rate was changing on the fly.

  19. JR_Audio's Avatar
    I was aware, what the point was, but for me this would have been no option either, because of the sound quality. I am back at home now and can confirm Chris finding, that nothing has changed.

  20. JR_Audio's Avatar
    When I have MIDI setup at 44K when opening iTunes and played a 44K File, than everything is Bit True und fine. See the below graph, showing a 1 kHz – 3 dBFS, 24 Bit Signal, digital analyzed.

    Now when I play a 48K file, without changing anything, I lost Bit True and the Mac Audio System converts the 48K signal in a 44K sample rate frame. The next measurement shows the quality of the SRC converter.

    When I now stop playback and changing the sample rate in MIDI setup to 48K with leaving Itunes open and playback again the 48K signal, it looks like that I have two SRC going on. Now the output sample rate is 48K, as set in the MIDI setup, but the 48K signal looks screw up. Looks like that iTunes, that I started when MIDI setup was at 44K, converts the 48K signal into 44K and after that the Mac Audio System converts this 44K signal a second time to 48K output. See the measurement.

  21. wgscott's Avatar
    That is definitive.

    I appreciate very much your taking the time to do this and post the data.

    Bummer; it would have been great, because there are instances when it is simply easier just to set and forget iTunes.

    AudirvanaPlus and BitPerfect are my current favored solutions (I've not tried the high-priced options).

  22. JR_Audio's Avatar
    With AudirvanaPlus, you are on the save side of good sound.

    Do you want to see the online SRC that is in use with AudirvanaPlus?

    Here we are. Settings are iZotope 64 Bit SRC set to best quality.

    I haven’t seen any better and I have tested a lot.

  23. wgscott's Avatar
    That looks really good. I know it sounds good, but it is nice to see why it does.

    It is interesting that the 48-44-44 iTunes resampling essentially introduces what looks to my (untrained) eye, simple harmonic distortion. Maybe that is how they "get away" with doing it the way they do.
  24. JR_Audio's Avatar
    I was aware, that iTunes does sample rate convert everything that doesn't match the sample rate that was set, when starting iTunes, but the above measured (and auditioned) results also surprised me, that the sound was better, with 48 K files, played back at 44 K (sample rate, when starting iTunes), compared to the sound, when set the sample rate of the Audio / MIDI setup was set afterwards to 48 K (still playing back the 48 K source file) with leaving iTunes open. The output sample rate will then be 48 K, but the file seems to be converted internally two times.

  25. HiFiGuy528's Avatar
    Is it better to leave AudiMidi to 24/96 and let iTunes play whatever file it has?
  26. HiFiGuy528's Avatar
    Not sure why my question got moved up to the top.

    Is it better to leave AudiMidi to 24/96 and let iTunes play whatever file it has?
  27. lanaya_piper's Avatar
    Can this be integrated to any existing home theater system? I'm really curious how this works.
  28. René Bertin's Avatar
    Bill and others: I'd be very interested in playing around with the plugin (I'm on 10.6.8 so the 10.7 code above won't work for me). What you are trying to do is not impossible: there's a commercial product that does just this (Amarra HiFi). I'm also researching the possibility to do the sample rate setting directly via CoreAudio, this is supposed to be possible.