Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Automatic Download Of Music CD Tracks (Read 7920 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Automatic Download Of Music CD Tracks

I use EAC to rip all my store bought CDs.  99% of the time the track information, etc. gets filled in automagically from the freedb website.  I've assumed that commercial CDs must have a unique number code that allows freedb to find the track information.  Perhaps this is just wrong.

Anyway, I just created a CD from one of my vinyl albums.  I recorded the album to WAV files, did some processing and placed track markers.  Then I burned the CD.  I did choose an option to write CD Text and filled in the artist and album name.  But I actually don't know if my CD burner even supports writing CD Text.  Anyway, if I play the CD with Windows Media Player, it is listed as "Unknown Album" with no track names.  If I open EAC, it finds all the track names and fills them in.  I can't believe that samples of WAV files get uploaded to freedb, so how did this work?

Automatic Download Of Music CD Tracks

Reply #1
Windows Media Player does not support reading or writing CD text.  Exact Audio Copy does.  So, that's why EAC sees the track names on your mix CD... and WMP doesn't.

Anyway, on your first question... freedb, AMG, etc. use a CD 'fingerprint' based on the TOC to identify a specifc disc.  It's not perfect, but it does fairly well.

Automatic Download Of Music CD Tracks

Reply #2
I assume TOC is short for table of contents?

So is this "fingerprint" based on the words present in the TOC, and not somehow a match of the actual WAV files?  If so, that's still very interesting because I never entered any track names when I burned the CD.  I'm using Adobe Audition 2.0 and the only CD Text option was to enter the artist and album name which I did.  I even modified the album name by placing "(LP)" after the real title.  Do you think those two entries are what allowed a match?

Automatic Download Of Music CD Tracks

Reply #3
It's based on the starting positions of the tracks (so called "index 01" to be precise), which is what's the TOC about.

And it has some disadvantages, because it is unprecise. The audio can be different sometimes for different issues of the same album CD and the shorter the CDs are and the fewer tracks they have (i.e. Singles) chances are bigger for a real mix up.

If you have some singles or CDs with only one tracks, try it, chances are high that you get completely different artist, album and track names.

Audio CDs were developed 30 years ago, so it was impossible then to foresee what trouble certain aspects of the technology would bring in the future.

Automatic Download Of Music CD Tracks

Reply #4
Quote
It's based on the starting positions of the tracks (so called "index 01" to be precise), which is what's the TOC about.

First, to make sure I understand, is TOC table of contents?

Second, by starting positions do you mean the exact time positions that each track begins, such as 00:02:00 for track one and 04:32:17 for track two, etc?

I can see how it would be unlikely for any two CDs to perfectly match each other in this fashion.  Every song would have to be the exact same length.  But it also seems unlikely that I would perfectly match the freedb with my homemade CD.  How much groove silence I eliminated before track 1 was arbitrary.  I kept the exact silent intervals between tracks as the original LP.  But the amount of silence between side 1 and side 2 was also arbitrary.  Are you sure freedb doesn't use something besides just the starting positions of songs?  Plus, this album came out in 1984.  If there was a later CD release that is now in freedb, who's to say that the CD even had the same silent intervals as the LP?

Automatic Download Of Music CD Tracks

Reply #5
I had a competely untagged FLAC needledrop of an Interpol album, and just for kicks I used Foobar's Freedb tagger--and it worked! I suppose it thought it was the CD, it filled in all the fields perfectly.

I don't really know how it recognized it, but i liked it.

Automatic Download Of Music CD Tracks

Reply #6
As already mentioned, the Disc ID is generated based on the start points of each track (in frames) and (what wasn't mentioned) the total length of the disc (in seconds).  When people submit results they get to choose the genre and pass the information and the generated id.  There is nothing more to it than this!!!

Now, the way the id is generated allows for similar numbers with slightly different results (like what you might find when digitizing a needledrop).

Here's an example for all ID entries for Interpol - Turn On The Bright Lights (excluding genres):

57edf7f2
54edd1f2
65f2ddf4
69f2def4
58f2c4f3
55f44cf3
7ff484f5
77f484f5
70f48ef5
75f420f5
6ef45bf5
61f427f5
63f440f5
7c0b1f0b
7d0b7c0b

Automatic Download Of Music CD Tracks

Reply #7
Yeah, I figured it was something like that, but I didn't know the specifics.

 

Automatic Download Of Music CD Tracks

Reply #8
the Disc ID is generated based on the start points of each track (in frames)

Actually it's in seconds (rounded down). MusicBrainz, however, does use sector values, thus making the hash much more unique. Contrary to FreeDB, I don't think there's even been any MB DiscID collision yet (although it's possible).

Automatic Download Of Music CD Tracks

Reply #9
The wikipedia article is wrong (what else is new?), the start points of each track are in frames!

Have a look at the code yourself:
http://www.cs.princeton.edu/introcs/51data/CDDB.java.html
http://www.mathematik.uni-ulm.de/help/perl...05_03/CDDB.html

Also, if you look at the raw data in freedb you will see that the start points are in frames as well.

Automatic Download Of Music CD Tracks

Reply #10
From the first of those links:
Quote
The checksum is computed as follows: for each starting frame, we convert it to seconds by dividing by the frame rate 75

It's the durations in seconds (integers) that are used in the computation. Hence you could have 75 different durations (in sectors) all resulting in the same value in seconds, because of the conversion.

Automatic Download Of Music CD Tracks

Reply #11
...and I was ready to blame the CIA or Fox News! 

Well that does make more sense considering how easily freedb is able to get correct results for submissions that aren't matches.

Thanks for the correction, skamp. 

Automatic Download Of Music CD Tracks

Reply #12
After a closer look, I believe that the Java implementation, while more accurate in itself, is wrong:
Code: [Select]
int totalLength = (frames[N] - frames[0]) / FRAMES_PER_SECOND;

I don't know Java, but I believe that isn't the same as:
Code: [Select]
int totalLength = (frames[N] / FRAMES_PER_SECOND) - (frames[0] / FRAMES_PER_SECOND);

The latter reflects the description in FreeDB's documentation (zipped .txt file):
Quote
t is calculated by subtracting the (M * 60) + S offset of the lead-out minus the (M * 60) + S offset of first track (yielding the length of the disc in seconds).

Code: [Select]
t = ((cdtoc[tot_trks].min * 60) + cdtoc[tot_trks].sec) - ((cdtoc[0].min * 60) + cdtoc[0].sec);


I just tried both methods to see if it would make a difference, and it did. FreeDB's method (the latter, with each value in seconds rather than in frames for the substraction) computes the DiscID a80b260b, while the Java implementation returns the DiscID a80b250b. Both entries show exactly the same track offsets in sectors, but different durations in seconds.

Edit: it doesn't pass FreeDB's test CD either.

Automatic Download Of Music CD Tracks

Reply #13
Following your enthusiasm on the subject, I actually created a short batch file that would calculate the disc ID from a directory full  of waves...
Code: [Select]
@echo off

SET _tframes=
SET _tnum=0
SET _dsum=0

CLS
SET /P _tframes=Total pregap size in frames (press Enter for the default of 150):
IF "%_tframes%" == "" SET _tframes=150
SET _start=%_tframes%

for %%f in (*.wav) do call :get_times "%%f"

CALL dec2hex %_dsum% _dsumh _dsuml
IF %_dsuml% == 1 SET _dsumh=0%_dsumh%

set /a _tsecs=(_tframes-_start)/75
CALL dec2hex %_tsecs% _tsecsh _tsecsl
:pad_tsech
set /a _tsecsl+=1
IF %_tsecsl% NEQ 5 (
  SET _tsecsh=0%_tsecsh%
  GOTO pad_tsech
)

CALL dec2hex %_tnum% _tnumh _tnuml
IF %_tnuml% == 1 SET _tnumh=0%_tnumh%

ECHO.
ECHO Disc ID: %_dsumh%%_tsecsh%%_tnumh%
GOTO end

:get_times
set /a _secs=(_tframes)/75
set /a _tnum+=1
set /a _tframes+=(%~z1 - 44)/2352
:digit_sum
SET /a _dsum+=_secs%%10
SET /a _secs/=10
IF %_secs% GTR 0 GOTO digit_sum
SET /a _dsum=_dsum%%255
GOTO :eof

:end
ECHO.
SET /P _pause=Press any key to end . . . <nul
pause>nul
Like what I've done with other batch scripts I've written, it can be modified to accept flac files or any other types that can easily give up a the decompressed length.

EDIT:  What I don't understand (for example) is how an album with 11 tracks can result in the disc id ending with the digits f5 such as one of the ids I gave for Interpol's Turn On The Bright Lights!

Automatic Download Of Music CD Tracks

Reply #14
I don't suppose there were more than 11 .wav files in your directory?

Automatic Download Of Music CD Tracks

Reply #15
Naw, how did the last two digits get to be f5 for a disc with 11 tracks...
http://www.freedb2.org/freedb/newage/7ff484f5
???

However...
-11 is f5 and -2940 is f484 but I didn't see anything about using 2's compliment.

Automatic Download Of Music CD Tracks

Reply #16
Sounds like signed / unsigned integer issues... I have that exact same CD, here is the correct DiscID: 800b7b0b.

Automatic Download Of Music CD Tracks

Reply #17
Sounds like signed / unsigned integer issues... I have that exact same CD, here is the correct DiscID: 800b7b0b.
Perhaps for the entire thing...
800B7B0B = 2148236043
7FF484F5 = -2148236043