Showing posts with label mystery. Show all posts
Showing posts with label mystery. 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.

Sunday, 8 March 2015

Phantom Capacitor Blown

Ever hear a capacitor let go?.. Ever had that deep stomach lurch as you hear a piece of electronics give up the blue ghost?

I did last night, stood up to plug in a new USB device - a new USB Flash drive - and as it went in... I heard, through my headphones, what I distinctly remember to be the cry of the god of capacitors, Pop!

But the machine stayed on... Okay, okay, damage limitation, shutdown, power off.. power off at the wall...

Open the machine, check the caps around the CPU, check for leaks, check for bulges, check for anything.... Nothing...

But I heard it??

Maybe it's the USB device itself.... Pull the plastic casing off (I wish they'd make them less robust)... Oh, there are no caps on it, and there are no obvious signs of damage, save the now chopped open case...

I heard a cpacitor go, I'm sure I did... I stand up again to push the PC back into place.... Sit down... Pop!

Holy shit, the same noise, but the power is off...!!!! It's the wiring in the house itself, it's the breaker, it's... It's.... It's my fucking belt buckle hitting the desk.

Doh.

Tuesday, 24 February 2015

Working with Taiwan Twinglish Embedded Development Kits

You know sometimes, I wish people would just write a manual.  I've just come across a chap who wants to sell a development kit to the company I work for, he's in Taiwan and very excited, he knows all about his kit, and he's been on the phone bulling it up for the boss.

He has ticked all the boxes with the boss, and they've gone a head and ordered the extortionately priced item, and it's arrived on my desk.

I took one look, and asked "Where's the manual", there isn't one.  Because this is a development kit... Right, what power does it take.. No-one knows, the only way to tell has been to look at the chips and see what the lowest possible power feed should be to the lowest value chip.

Which prong was the negative?... Only could tell that by tracing - by eye - back from an obvious earth plane and a couple of large caps and checking that the line was the negative rail.

This level of just basic documentation, being lacking, immediately makes me worry about the whole bundle.

They're trying to sell this, but I think they're actually trying to get a native English speaker - i.e. me - to write their manual for them.

Next thing, how do I build software to run on this kit?... They don't know... Seriously, this is what the chap has said to me, "It in C, write in C"... okay, what compiler you got?... "We no got compiler"...

So I have to go to the chip vendor and ask for their compiler?... These people throwing this kit together don't have a compiler?  And don't have any recommendation of which compiler to use?....

Luckily I can look at the board and see the processor, so I know what architecture I'm going to target, but I was about to ask "What's the architecture", and I'm pretty sure he'd not know.

How to get the software as built onto the kit, also seems a mystery, there's no obvious portable slot, no ethernet, no USB, no serial... I can't believe I have to burn EEPROM's and plug them in... In this day and age, I've been told "Firmware take your software in, firmware do it"... but not been told how.

I swear, I could pull the last shreds of my hair out with this, not least because I have to appraise this for use by our whole UK arm before this guy jumps on a pre-booked plane ticket from Taiwan over to here.... Gah