I am trying to calculate the start of audio (SOA) position in an mp3 file.
I've had some luck working it out, but need some maths help.
The first header contains 10 bytes as per
Identifier "ID3"
Version $04 00
flags %abcd0000
Size 4 * $0xxxxxxx
Those last 4 bytes should point to the SOA.
e.g 49 44 33 03 00 00 00 00 08 00
Although I don't understand it, the SOA is calculated by
Code:
Dim ID3 As String * 10
Dim C As Long
Dim d As Long
C = 2 ^ 14
d = 2 ^ 7
If Left(ID3, 3) = "ID3" Then
Taglen = Mid(ID3, 7)
SOA = Asc(Mid(Taglen, 2, 1)) * C Or Asc(Mid(Taglen, 3, 1)) * d Or Asc(Mid(Taglen, 4, 1))
End if
This returns 1024 from the last 3 bytes of the size, it is wrong and should be 2048
It may well be if the all 4 values were included.
Can anyone tell me how to factor in all 4 values in the above ?
If I'm on the right track, 05 7F 7E 73 should = 12582781.