July 26th, 2003, 03:10 PM
Reading mp3 id3, something wrong with genre/year
Something is wrong with the Genre/Year of this.. Genre is 1 less than it's supposed to be, and If there is a comment, it shows up with the year, ("1999COMMENT HERE"):
typedef struct _id3tag
unsigned char track;
unsigned char genre;
int ReadID3(const char* Filename, id3tag *ID3Tag); //0==error, 1==sucess
int main(int argc, char **argv)
printf("Genre %d\nYear %s\n",ID3.genre,ID3.year);
int ReadID3(const char* Filename, id3tag *ID3Tag)
if(!(buffer=='T' && buffer == 'A' && buffer == 'G'))
//Found id3 tag, let's fill out our id3tag struct
ID3Tag->title[x] = buffer[x+3]; //take 3 off cause of TAG
ID3Tag->title = '\0';
ID3Tag->artist[x] = buffer[x+33]; //33 = TAG + title
ID3Tag->artist = '\0';
ID3Tag->album[x] = buffer[x+63]; //TAG + title + artist
ID3Tag->album = '\0';
ID3Tag->year[x] = buffer[x+93]; //TAG + title + artist + album
ID3Tag->year = '\0';
ID3Tag->comment[x] = buffer[x+97]; //TAG + title + artist + album + year
ID3Tag->comment = '\0';
if(buffer > 0 && buffer < 256)
ID3Tag->genre = buffer; //If its between 1-255, put it
ID3Tag->genre = 255; //255 means unused
//ID3 1.1 compatibility (Track field)
if(ID3Tag->comment == '\0')
ID3Tag->track = ID3Tag->comment; //If comment ends at 28.. then 29 is the track
ID3Tag->track = 0; //0 mean's unknown track
Last edited by movEAX_444; July 27th, 2003 at 12:00 AM.
July 26th, 2003, 07:10 PM
Re: Binary I/O functions in C, to read mp3 id3
I haven't actually played with it, but wouldn't you want to make that a negative offset from the end? E.g.:
July 26th, 2003, 07:58 PM
SEEK_END read's backwards 128 bytes (or whatever you want it to), -128 doesn't work I get an error. Another way to do it is just to start reading from filesize - 128.
July 26th, 2003, 09:01 PM
Ok I think SEEK_END is with a negative, I got it to work with no error. You were right. I am getting closer to getting at least something working.
haha it wasn't working because the mp3 didn't have an id3 tag.
Last edited by movEAX_444; July 26th, 2003 at 09:03 PM.