Showing posts with label lost. Show all posts
Showing posts with label lost. Show all posts

Wednesday, 25 May 2016

Old CD Ripping Code

I just received a mail from "Experts Exchange" telling me a question I participated in would be deleted... When I opened the question, in question, I have no recollection of answering this whatsoever... it's not even really my style of coding...

I always Alman bracket alignment, never K&R...


------



I can't comment about "MusicBrainz" however, when using freedb (http://www.freedb.org) you need to compute an ID for the CD you have taken a track from, you can find all this information on their site in the "Software->Howto" sections:

But in essence, when you connect to their server to identify a track, you need to provide a disc ID.  This is an 8-digit hexadecimal (base-16) number, computed using data from a CD's Table-of-Contents (TOC) in MSF (Minute Second Frame) form.

--- Below is taken directly from the freedb.org "how-to" file regarding generating an ID to use with their service ---

The following is a C code example that illustrates how to generate the CDDB/freedb disc ID. Examples in other programming languages may be found on the freedb web site at http://www.freedb.org in the developers-section. A text description of the algorithm follows, which should contain the necessary information to code the algorithm in any programming language.


struct toc 
{
      int      min;
      int      sec;
      int      frame;
};

struct toc cdtoc[100];

int
read_cdtoc_from_drive(void)
{
      /* Do whatever is appropriate to read the TOC of the CD
       * into the cdtoc[] structure array.
       */
      return (tot_trks);
}

int
cddb_sum(int n)
{
      int      ret;

      /* For backward compatibility this algorithm must not change */

      ret = 0;

      while (n > 0) {
            ret = ret + (n % 10);
            n = n / 10;
      }

      return (ret);
}

unsigned long
cddb_discid(int tot_trks)
{
      int      i,
            t = 0,
            n = 0;

      /* For backward compatibility this algorithm must not change */

      i = 0;

      while (i < tot_trks) {
            n = n + cddb_sum((cdtoc[i].min * 60) + cdtoc[i].sec);
            i++;
      }

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

      return ((n % 0xff) << 24 | t << 8 | tot_trks);
}

main()
{
      int tot_trks;

      tot_trks = read_cdtoc_from_drive();
      printf("The discid is %08x", cddb_discid(tot_trks));
}


This code assumes that your compiler and architecture support 32-bit integers.

Monday, 25 November 2013

Where the fuck is our £180?

The wife and I have been saving a little bit of money each week, all year, so we can buy the kids (nieces and nephews) a nice Christmas gift, this cash was kept in an envelope at the in-laws, and the wife went to collect this on Friday.

Now, she remembers picking it up and counting it, then thinks she put it down again... Somewhere, or in a pocket, or whatever...

Yes, you get the picture, it has been lost.

So, no Christmas pressure off of our wallets, oh no, utter and total waste, and not only that, but the wife has lost it, I'm pretty sure she dropped it outside here in the street between the car and the front door, and some lucky bastard has walked off with a £180 Christmas bonus...

But the wife of course, blamed me... Now, I admit I just asked her to think about where she'd last seen it, what pocket it was in, what she was wearing... so you know, I was being unreasonable, asking her to THINK!... And then of course, asking her to do things a set way, like... Keep money in your purse... or better yet, as I originally suggested keep the fucking money in the savings account in the bank so it can't get lost!

Oh no, all my fault, my problem, mine to sort... So annoyed, so utterly and fucking annoyed with it all.