[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Reading and writing mp3 metadata
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Tue, 30 Apr 2013 08:51:17 -0300
> TID3 = record
> signature: array[0..2] of char;
> title, artist, album: array[0..29] of char;
> year: array[0..3] of char;
> comment: array[0..29] of char;
> genre: byte;
> end;
>
> My first difficult is: how to represent a Lua 128 bytes structure like that.
> And how can I read the last 128 bytes of a file and attibutes it to a
> structure, probably a table, with this fields, sized with the given
> values?
function subl(s,i,l) return i+l,s:sub(i,i+l-1) end
f = io.open("foo.mp3","rb")
h = f:read(128)
f:close()
t = {}
i = 1
i,t.signature = subl(h,i,3)
i,t.title = subl(h,i,30)
i,t.artist = subl(h,i,30)
i,t.album = subl(h,i,30)
i,t.year = subl(h,i,4)
i,t.comment = subl(h,i,30)
i,t.genre = subl(h,i,1)