Re: freedb track info fetcher?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Oct 10, 2006 at 03:18:12PM +0200, Mario Lang wrote:
> There are a lot of CDDB based tools for linux, but they all seem
> to depend on the physical disk being in the cdrom drive.

The CDDB disc ID is based on the number of tracks and the track
lengths. So if you can accurately calculate that from some
soundfiles, you might be in business.

I haven't found the algorithm defined anywhere, but maybe these excerpts
from the DiscID python module will serve as explanatory pseudocode.
It's at http://cddb-py.sourceforge.net/

BUT... I'm not sure how "leadout" is extracted; that might scuttle your
idea.


# If called from the command line, will print out disc info in a
# format identical to Robert Woodcock's 'cd-discid' program.

def cddb_sum(n):
    ret = 0
    while n > 0:
        ret = ret + (n % 10)
        n = n / 10
    return ret

def disc_id(device):
    (first, last) = cdrom.toc_header(device)

    track_frames = []
    checksum = 0

    for i in range(first, last + 1):
        (min, sec, frame) = cdrom.toc_entry(device, i)
        checksum = checksum + cddb_sum(min*60 + sec)
        track_frames.append(min*60*75 + sec*75 + frame)

    (min, sec, frame) = cdrom.leadout(device)
    track_frames.append(min*60*75 + sec*75 + frame)

    total_time = (track_frames[-1] / 75) - (track_frames[0] / 75)

    discid = ((checksum % 0xff) << 24 | total_time << 8 | last)



 
-- 

Paul Winkler
http://www.slinkp.com

[Index of Archives]     [Linux Sound]     [ALSA Users]     [Pulse Audio]     [ALSA Devel]     [Sox Users]     [Linux Media]     [Kernel]     [Photo Sharing]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux