Results 1 to 15 of 15

Thread: Extract ID3 tags from MP3s?

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2000
    Posts
    37

    Exclamation

    Hey Fellow Programmers:

    Is there a way I can extract ID3 tags from MP3s using VB? Like Album, Artist, Genre, Comments??

    Please help...thanks

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2000
    Posts
    37
    Thank you very much Kadaman!! That was much appreciated.

    I was wondering if there was a way I could make the program search for all MP3 files in a directory and look extract the ID3 tag from each one into a file or database?

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    You could use the dir function to retrieve the files, or the fso object
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5

    Thread Starter
    Member
    Join Date
    Jan 2000
    Posts
    37
    thanks

    I have a question about your code

    Before splitting up the ID3TAG into various parts, I just tried to show ID3TAG in a label. It didn't work. How do I see the contects of 'astring' or hte variable ID3TAG?

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    it's probably a nullchar there blocking the content, or maybe the text disappeared on another line in the label, it's a bit hard to tell you from here. Try to break somewhere and put ?id3tag in your immediate box
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  7. #7

    Thread Starter
    Member
    Join Date
    Jan 2000
    Posts
    37
    ok, I got it to read any mp3 file i select and show my the Id3tag.

    Now my second question is how can i select a directory, and make hte program search thru the directory for all mp3 files and read their ID3tag and put it in a database?

    I know i have to use a loop, but i'm not sure as to how to check for any file that ends in *.mp3 and check it's id3tag?

  8. #8
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Code:
    a=dir(path & "\*.mp3"
    do while len(a)
     If Left(ID3TAG(a), 3) = "TAG" Then ...
     a=dir
    loop
    Ok, this will retrieve the all the mp3files from your path, and put them into a database where the "..." are
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  9. #9

    Thread Starter
    Member
    Join Date
    Jan 2000
    Posts
    37

    Talking

    thanks a lot Kedaman!

    Just wondering but how did you know what the offsets are to get the information from the ID3 tag? Like which part shows the artist, album and stuff?

    Also that file finding code you gave, does it work with subdirectories too? Or just one level?

    Thanks again. I'll try out the code when I get home.

  10. #10
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I was hexaediting a mp3 file when i suddenly noticed that there was text stored in the end of the file. So i made my first ID3Tag editor.

    No it doesn't work with subdirs i have posted the code somewhere recently, go search for it
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  11. #11
    New Member
    Join Date
    Jun 2000
    Location
    Canada
    Posts
    1

    Wink Hex editing an mp3? what in god's name for?

    greetings,

    of what use exactly is the raw hex of an mp3? not meaning to be critical, but it intrigues me. what's in there that's recognizeable?

    on a semi topic related note, would this code still work if the mp3 were in use (ie: playing) and can you write to the ID3 tag in this fashion?

    while broken = true do
    hit it
    loop

  12. #12
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Heh, i actually didn't get anything of it, i just was testrunning my own hexaeditor on it. The mp3 encryption is evil. No, you can't change the running mp3, at least if it's playing or even paused in winamp. But i've got around that problem
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  13. #13
    New Member
    Join Date
    May 2001
    Posts
    3
    hey madd indian, maybe this snippet is of some use
    (recursing subdirectories looking for mp3s...)

    'just some helpfuncs...
    Private Function fileSuffix(fileName As String) As String
    Dim Index As Integer

    Index = InStrRev(fileName, ".")
    fileSuffix = Mid(fileName, Index, 4)
    End Function

    Private Function removeSuffix(fileName As String) As String
    Dim Index As Integer

    Index = InStrRev(fileName, ".")
    removeSuffix = Left(fileName, Index - 1)
    End Function

    Private Function addDir(path As String)
    Dim fileName As String

    fileName = Dir$(path + "\*.mp3")
    Do While fileName <> ""
    If fileSuffix(fileName) = ".mp3" Then
    Call addToMp3s(path, fileName)
    End If
    fileName = Dir$
    Loop
    End Function

    Private Function recurseSubdirectories(path As String)
    Dim subDirs() As String
    Dim nofSubdirs As Integer
    Dim directory As String
    Dim i As Integer

    displayInStatusBar ("Searching in " + path + "\")
    Call addDir(path)

    nofSubdirs = 0
    directory = Dir$(path + "\", vbDirectory)
    Do While directory <> ""
    If (GetAttr(path + "\" + directory) And vbDirectory) = vbDirectory Then
    If directory <> "." And directory <> ".." Then
    ReDim Preserve subDirs(nofSubdirs + 1)
    subDirs(nofSubdirs) = directory
    nofSubdirs = nofSubdirs + 1
    End If
    End If
    directory = Dir$
    Loop

    For i = 0 To nofSubdirs - 1
    Call recurseSubdirectories(path + "\" + subDirs(i))
    Next i
    Erase subDirs
    End Function
    /FooFighter

  14. #14
    Lively Member
    Join Date
    Apr 2001
    Location
    Utah, USA
    Posts
    121
    Just for info a great place to get information about the format of ANY (almost) file is at http://www.wotsit.org/ for MP#'s specifically http://www.wotsit.org/search.asp?page=5&s=music

    This place rocks

    Zevlag
    Josh -- Name
    Zevlag13 -- AIM

    www.WotsIt.org for all your file format spec questions!

  15. #15
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    note, it's been 11 months since he got what he wanted.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width