iTunes stop time

Mikuro

Crotchety UI Nitpicker
A LOT of my tracks in iTunes have a second or two of silence at the end. This really, really bugs me. Is there any app or script or anything that will analyze a track and set iTunes' stop time for that track to eliminate the silence?

<bitching> iTunes really ought to do this automatically </bitching>
 
How about checking Preferences>Playback>Crossfade Playback and playing around with the slider?
 
winamp, for years has had a silence-skipper. any silences lasting more than 4 seconds, or any silences at the end or start of a track, that fall below a certain dB, get skipped. it;s really good, and one of the things that bugged me about iTunes when i first switched.
 
bok said:
How about checking Preferences>Playback>Crossfade Playback and playing around with the slider?
Well, that's something, but ultimately not what I want. It just destroys non-stop albums and any song that starts or ends with a bang. On top of that, the feature doesn't even seem to work properly most of the time (that's another issue entirely, though).
 
Hit command-i on the particular song, click 'Options' and set the stop time there :)
 
By my calculations, that would take somewhere in the neighborhood of 14 straight hours for my entire collection. :eek:

I might try to write a program to do this myself. The problem is that I have absolutely no experience processing audio. Gotta learn sometime, though, right? :)
 
Mikuro said:
By my calculations, that would take somewhere in the neighborhood of 14 straight hours for my entire collection. :eek:

I might try to write a program to do this myself. The problem is that I have absolutely no experience processing audio. Gotta learn sometime, though, right? :)

The information is stored in the 'iTunes Music Library.xml' file and can be edited quite easily. A nice opportunity to learn NSXMLParser ;)

I guess the cleanest approach to such an application would be to reverse scan each song using e.g. Core Audio to find the (relative) end, and store the stop time, id est track length minus the time of relative silence, back into the stop time attribute in the iTunes library file. Then you wouldn't have to re-encode each file as long as iTunes is the only target application.
 
I was thinking I'd use AppleScript. In fact, I just finished my whole system, using a combination of AppleScript and a REALbasic project I wrote. It seemed perfect....until I realized that iTunes' takes integers for its start and finish times through AppleScript. Meaning you can set the start time to 1 second or 2 second, but nothing in between. So it's worthless. :mad:

Editing the xml file would be easy enough, but I've tried manually editing the xml file many times, and the changes never "take" in iTunes. I came to the conclusion that iTunes only WRITES to that file (so that other apps can access the library data easily), but never READS it. It only reads from the "iTunes Library" file, which is some nasty, scary, mysterious, seemingly-impenetrable binary format.

So I went to the trouble of working it all out, but it seems like it's impossible after all. Bummer.
 
I spoke too soon. Nothing's impossible. It's just a matter of A) How dirty you're willing to get your hands, and B) How nasty an inelegant you're willing to make the final product.

I have sufficiently lowered my standards to get an almost working solution, albeit a nasty one. Without going into too many details, it relies on GUI scripting.

Now about that "almost" I mentioned. I've hit a problem that seems outside of my control, and I'm hoping someone can shed some light.

My program uses QuickTime to open the files and return waveform data for analysis. The problem is that for some reason QuickTime reads mp3s differently from iTunes, to the point where QT think some tracks are a second or two longer than iTunes does. So my program, when analyzing the tracks, is going by time measurements that aren't entirely compatible with iTunes.

Does anybody know WHY this is? I have one track in particular that's 591.699 seconds in iTunes, but QuickTime thinks it's 593.066 seconds. So when my programs sees that the last .07 seconds are silent, it returns a number a full second beyond what iTunes thinks is the end of the track.

If I knew why this happened, maybe I could hack up a workaround. Can anyone clue me in?
 
Well, you can try to analyze a few tracks and see if the track length difference between iTunes and QT is linear. Three tracks of different lengths should be enough--3, 10 and 60 minutes for example. Then you should be able to calculate how much time to subtract or add to get "iTunes time".

If the difference is not calculable, my guess goes towards some rounding or clock error in either of the two programs. Maybe someone knows on Apple's quicktime-api mailing list.
Good luck!
 
It's ALMOST linear. There seems to be a point-something-percent variation.

I've discovered a method that I think would hit the nail on the head. Instead of having my program return the finish time, I can have it return the amount to cut off the end. It seems like that lines up perfectly with iTunes. I'm still not really confident with this method, though. I'd really like to know where this time discrepancy comes from. It doesn't seem like it's the beginning or the end. I guess even if there is a slight problem, it probably won't amount to much more than a few milliseconds. I can live with that.

NOW the problem is, how the heck do I get the length of a track from iTunes? Again, iTunes only returns INTEGERS when you ask it for the duration in seconds. What a load. It's going to take more GUI-scripting hackery to get this done. But I can't turn away now, darnit. I'm OBSESSED!

(I guess this thread would be more fitting in the Programming & Scripting forum at this point, but anyway....)
 
Well, I'm done. Almost. It works pretty well, but there are a couple snags I have no idea how to fix.

First of all, it can't read iTMS downloads. Well, it can, but it reads them all as pure silence. I don't know why, since I'm using QuickTime, and QuickTime CAN play them.

Stranger yet, there is ONE mp3 in my library that it just can't process right (yes, just one). Again, it thinks the entire track is silent. It plays fine in iTunes, and it plays fine in QuickTime Player. No idea what the deal is with that, but I'm willing to write it off as an anomoly.

I'm going to have to update it to ignore m4p files and such "anomolies". That's a bummer, but I'm not sure what else I can do about it.

Would anyone be interested in using this program? It's a bit messy and complicated, what with all that GUI scripting, but hey, it works.
 
Back
Top