|Data types and iTunes
||[Jun. 11th, 2007|08:43 am]
1) What I'm doing|
The implementation of the CD Info databases iTunes uses seems frequently quite poor. Occasionally it's actually gone so far as to screw up any audio program using it so that it doesn't know there's a disc inserted, necessitating redoing it... Plus most of my audio collection is audiobooks -- some on physical bought cds, some ripped from Audible or audio tape onto my backup cds.
I'm trying to implement my own personal-use equivalent of the databases in XML--after all, I know what book the disc I've inserted belongs to, so I don't want a 'CD Info' style database of every disc ever imported or burned (or, worse, every disc someone's ever had through CDDB). Especially since CD Info is broken to the extent that if you ever insert an audio CD with a single long track (like a track that may have been burned from an Audible download or an audio tape or podcast to be cut into tracks later), it will then match it to the last 'long single track' cd you inserted, even if the track lengths are different, and I know I'm not the only one this has happened to, because the Toast forums are full of complaints from people who get the CDDB info from 'some random gapless CD' or some CD which happens to match the details among thousands and thousands of CDs.
So what I want is for the script to look through details for between 3 and 10 discs at a time, typically (on the principle that it's less fragile than trying to check thousands at a time). I get the data by writing it out to file when it's correct (using the excellent XMLLib osax to get the data into a file). Then I've got it on file if the CD info breaks yet again and has to be rebuilt.
2) The Problem
I think I've got it to work, but why am I getting a problem with spurious differences between the track lengths written out to XML and the track lengths in iTunes when they look the same. I get the track length of the track from the XML file (in a 'length' tag) and it looks like "217.345993041992". I get the 'duration of aTrack' from iTunes, and that also looks just like "217.345993041992". Both of those should be values in seconds, presumably real, or able to be coerced thereto, but when I check for equality using both values as real, they don't match (and if I subtract one from the other I get some spurious value). I'm checking both values 'as string', which works, but why wouldn't it work as real, because both values are in seconds and real rather than integer?