Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env luajit
- local function main()
- local fd = assert(io.open("Last_V8.sid"))
- local d={}
- repeat
- local char = fd:read(1)
- if char then
- table.insert(d,string.byte(char))
- end
- until not char
- fd:close()
- print(#d.." bytes read")
- local notes = {[0]="C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "H"}
- for i = 1, #d - 3 do
- local result = nil
- if d[i] == 255 and d[i+1] ~= 255 then
- result = {"@"..bit.tohex(i-1)..":"}
- j = i + 1
- local done = nil
- repeat
- local len = bit.band(d[j], 0x9f)
- if len > 127 then
- len = len - 128
- j=j+1
- end
- j=j+1
- local note = d[j]
- j=j+1
- if note < 100 and note > 1 then
- local oct = math.floor(note / 12)
- note = note - oct * 12
- table.insert(result, notes[note]..oct..","..len + 1)
- else
- done = true
- result = nil
- end
- until done or d[j] == 255
- if result and #result > 4 then
- table.insert(result, 2, "("..(#result - 1)..")")
- print(table.concat(result," "))
- end
- end
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement