Controlling iTunes
Script of the Day: Needle Drop
Needle Drop plays each track in the selected iTunes playlist for a set time interval optionally starting at a set number of seconds into each track, beginning with the selected track. Handy for 'scoping playlists.
With the settings above, each track in the selected playlist will play for 30 seconds starting at the track's 00:30 second mark; there will be a 00:05 second delay before the subsequent track plays. The latter two settings are optional.
More info and download is here.
Previous "Scripts of the Day". Subscribe to my RSS feed or follow @dougscripts on Twitter to get daily "Script of the Day" notifications.
UPDATED: A Space Between v1.2
The few-seconds gap between tracks on recorded media is an artificial time. Devised to be just long enough to visually and sonically demarcate the tracks on a space-limited side of LP vinyl, the gap carried over to tapes, CDs and digital. It is unlikely that musicians playing a gig would pause such a short period of time before launching unto their next number...for every single number. Even so, we're accustomed to the two-second rule when listening to recorded media. (And cross-fades? Utterly unnatural.)
A Space Between will play the tracks in the selected playlist and wait a user-entered number of seconds between tracks.
I've found that six to eight seconds of silence between tracks can be quite refreshing, especially between longer contiguous album tracks. But it adds something to the atmosphere of a mixed-track playlist, too.
How un-streamy.
This latest version of A Space Between is a maintenance update with a few minor performance tweaks.
Free stuff, dev ID-signed, more information and download is here.
Play Selected Track and Cue Next
A Correspondent inquired about a script that would play a selected track in iTunes through to the end and then stop and then select the next track but not play it. In such a way, a playlist containing sequential musical cues required for a theatrical performance could be fired one track at a time, via the script, without a lot of stopping and mouse-clicking and swearing backstage ("Up yer scrim!", "Purple behind!").
This is such a script:
-- Play Selected Track and Cue Next
tell application "iTunes"
-- get the single selected track and play it
set theSelection to selection
if length of theSelection is 1 then
set theTrack to item 1 of theSelection
try
play theTrack with once
on error
## beep
return
end try
-- the selected track is playing, now do some other stuff...
-- get the playlist
set thePlaylist to (get view of front window)
-- stash current fixed indexing value
set curfi to fixed indexing
-- we want free indexing not fixed indexing
set fixed indexing to false
-- compute next track's index
set idx to (get index of theTrack)
if (idx = (count of tracks of thePlaylist)) then
set idx to 1
else
set idx to (idx + 1)
end if
-- select the next track in the playlist
reveal track idx of thePlaylist
-- restore fixed indexing to whatever it was before
set fixed indexing to curfi
end if
end tell
What you'd want to do is save this with Script Editor, named whatever you like, with a File Format of "Script" and put it in your [Home]/Library/iTunes/Scripts/ folder so it appears in iTunes' Script menu.
Prepare a playlist and select its first track. When it's time to actually play the track, don't use any iTunes play controls; instead, fire the script. The script will play the selected track, figure out which track is next in sequence, select it, and then quit. iTunes will stop when the current track has finished by virtue of that with once parameter on the play command. When it's time to play the next track, which is now the selected track, fire the script to play it and select the next track. And so on.
While assigning this script a keyboard shortcut will be convenient if you can keep a hand near the keyboard, something that could fire this via a physical remote control would be super boss. Under such circumstances, you may prefer—or it may be necessary—to save the script with a File Format of "Application".
UPDATED: I Hate That iTunes Done Chime! v3.0
Ripping CDs and converting audio files with iTunes isn't something a lot of people do anymore. Ahh, to be free of the slow, ear-stabbing torture of the done-chime that sounds after every import or conversion.
Boodely-oop!
Sure, you could lower the volume on your machine everytime that boodely-oop! drives another tri-tone nail into your brain. Or you could replace the done-chime with some other sound or silence! with I Hate That iTunes Done Chime!
This applet will allow you to replace iTunes' Tri-Tone done chime ("The Hellmouth's Doorbell") with a System sound, a user-chosen AIFF file, or no sound (actually, a sound file provided that is just one second of silence).
This script hadn't been updated since 2009, during which time the additional security and permission considerations of the OS prevented it from working. The script now asks for permisson before it moves any files around.
Dev ID signed and free to use, more information and download is here.
UPDATED: Quick Convert v4.1
Quick Convert v4.1 will convert all or just the selected tracks of the selected Playlist using your choice of available iTunes encoders, restoring your Preferences-set encoder afterwards. Works with importing selected CD tracks, too.
Additionally, you can:
- Choose to delete and/or Trash the original tracks and/or files
- Copy all converted/imported tracks to a new playlist
- Optionally save AAC encoded tracks as M4B "bookmarkable" and re-add the converted files to the Audiobooks (Books) library
This latest version restores the Edit menu, which I removed during some kind of fit of minimalism. Unfortunately, you kind of need that guy if you want cut, copy and paste shortcuts to work in the app. There are also some minor maintenance fixes.
Quick Convert is free, but payment in appreciation requested. More info and download is here.
UPDATED: Needle Drop v5.0
Needle Drop v5.0 will play each track in the selected iTunes playlist for a set time interval optionally starting at a set number of seconds into each track, beginning with the selected track. Handy for 'scoping playlists.
The latest version adds support for OS X 10.10 Yosemite and iTunes 12 and has other minor tweaks.
More information and download is here.
Toggle Stereo/Mono Audio Output
Correspondent Simon Crosbie has set up an amp and pair of speakers in his workshop which is connected to an Airport Express. Unfortunately, the speakers are some distance apart, so that he may be near one speaker or another at any time, and will only hear that channel's output. Simon wanted to know if there's a way to toggle between stereo and mono output so he can hear more than just half of a stereo recording.
Yes, there is a way. Go to System Preferences > Accessibility. Choose "Audio" in the left-hand list and in the panel that appears click the checkbox next to "Play stereo audio as mono".
Goodnight everybody!
Wait a minute. I almost forgot I wrote this script to do it:
tell application "System Preferences"
reveal anchor "Hearing" of pane id "com.apple.preference.universalaccess"
end tell
tell application "System Events"
tell application process "System Preferences"
set frontmost to true
tell window "Accessibility"
##--> pre 10.9 set monoStereoCheckbox to checkbox 2 of group 1
set monoStereoCheckbox to checkbox "Play stereo audio as mono"
if (get value of monoStereoCheckbox) as boolean is true then
set ddMessage to "Switch to STEREO output?"
else
set ddMessage to "Switch to MONO output?"
end if
if button returned of (display dialog ddMessage buttons {"No", "Yes"} default button 2) is "Yes" then
tell monoStereoCheckbox to click
end if
end tell
end tell
end tell
if application "System Preferences" is running then
tell application "System Preferences" to quit
end if
[UPDATE November 13, 2013: The original script has been updated for Mavericks. Note the commented line for pre-10.9 systems and the line that follows it. Set the monoStereoCheckbox variable using one or the other depending on the OS.]
[UPDATE October 17, 2014: Another change for compatibility with Yosemite. The line "set frontmost to true" is inserted right after the first tell application process "System Preferences" line near the beginning.]
I would save this script in the system wide Scripts menu (install it in ~/Library/Scripts/). Because the script uses (gulp) GUI scripting you must make sure that "Enable access for assitive devices" is checked in the Accessibility System Preferences panel.
Smarties among you can figure out how to switch mono/stereo when using AppleScript to change AirPlay speakers.
And bear in mind that while the script works with the current OS (and probably an OS that may be released this Fall), Apple may change the layout of the System Preferences panels in a future update, in which case the GUI scripting will have to be updated.
[UPDATE December 28, 2018: Mojave made some changes and the updated version of the script can be seen here.
UPDATED: Play Random Album v3.1
Play Random Album scans your library, creates a playlist of a complete single album choosen at random and begins playback of the playlist created. Works great when assigned a keyboard shortcut.
This version works around a problem with iTunes 11 whereby after starting to play the first track of the new playlist no additional tracks appear in the MiniPlayer/Up Next and only the first track ever plays. The script now waits until the playlist is completely assembled before starting to play it.
UPDATED: Change Hidden iTunes Preferences v3.0
Thanks to a couple of recent posts at Mac OS X Hints and Cult of Mac, Change Hidden iTunes Preferences saw a lot of downloads in the past week or two. Unfortunately, I hadn't had time until today to give it an update. An older preference, "Show buttons horizontally", is no longer applicable and a new preference, "Disable 'elastic' scrolling behavior", applicable in Lion, needed to be added. These changes are in the latest version of Change Hidden iTunes Preferences.
Additionally, this version is written as a Cocoa-AppleScript applet and can only be run on OS X 10.6 or better.
Custom Playlist Column Views, Sorta
Here's something I'm often asked which Correspondent Rob Falk put succinctly: "Is there a way to clone a playlist view...other than the Library [using Assimilate View Options]? I frequently need to create a playlist that has a specific set of columns, that are not the same as the library, and was looking for a way to automate that."
There sorta kinda is.
My first thought was to use AppleScript to just duplicate an existing playlist that already had the requisite view settings. (The duplicate command is typically used to copy a track from one playlist to another.) Unfortunately, when iTunes' AppleScript duplicate command is used to copy a playlist itbafflinglycreates a new untitled and empty playlist using the properties and views of the Music library playlist. Same as just creating a new playlist. That doesn't seem right, does it? You'd thinkwell, I thought anywaythat using duplicate to copy a playlist would behave the same as the playlist contextual menu command "Duplicate" (control-click or right-click on the name of the playlist):
So, my next thought was...just use "Duplicate". The playlist will be perfectly duplicated, column views and all, and selected in the Source list. Now you'll have a new playlist named the same as the original with a "1" at the end and which is populated with the original's tracks (if it had any). You could create a bunch of playlists with columns set the various ways you like and then "Duplicate" them when you required one. Just rename the new duplicated playlist and delete any tracks. And that part can be automated.
The workflow, then, is to "Duplicate" a playlist manually with the contextual menu command and then run this script right afterwards: