Results 1 to 4 of 4
  1. #1
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    479

    How to calculate complex file offset


    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.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Where did you find that formula?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    479
    Gawd knows! But I remember it was so good. Without it there was no way to get the SOA.
    But it was wrong, although it worked with mp3's with a low SOA
    And I have now sorted it. More fluke that good management
    e = 2 ^ 21
    C = 2 ^ 14
    d = 2 ^ 7
    If Left(ID3, 3) = "ID3" Then
    Taglen = Mid(ID3, 7)
    SOA = Asc(Mid(Taglen, 1)) * e Or Asc(Mid(Taglen, 2)) * C Or Asc(Mid(Taglen, 3)) * d Or Asc(Mid(Taglen, 4))


    I do wish my maths was better. be good to do the reverse, find the 3 values for the number

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Could you provide sample data and complete procedure?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 07-12-2018, 05:13 PM
  2. Replies: 5
    Last Post: 05-23-2016, 10:57 AM
  3. open to new record offset
    By ShostyFan in forum Access
    Replies: 2
    Last Post: 02-07-2015, 06:02 PM
  4. Replies: 1
    Last Post: 08-12-2013, 02:05 PM
  5. Runtime error with ActiveCell.offset
    By Eowyne in forum Programming
    Replies: 2
    Last Post: 04-22-2011, 10:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums