Slashdot Mirror


Cultured Perl: Fun with MP3 and Perl, Part 1

Ted writes "Every self-respecting computer and music fan needs to be able to manipulate MP3s -- the defacto standard for recreational digital music use. In this article, I'll look at ways to manage and manipulate MP3s (searching, tagging, renaming, commenting, etc.) using the autotag.pl application. I'll also take you through the application, illustrating how CPAN modules enable the application."

34 of 232 comments (clear)

  1. and like every Linux geek.. by rf0 · · Score: 5, Funny

    I'm going to say "Where the ogg version?" :)

    Rus

    1. Re:and like every Linux geek.. by ViolentGreen · · Score: 2, Insightful

      I'm going to say "Where the ogg version?" :)

      That's the beauty of open source. You have the perl script, look at the OGG documentation and write it yourself.

      --
      Not everything is analogous to cars. Car analogies rarely work.
    2. Re:and like every Linux geek.. by Simon+(S2) · · Score: 3, Informative

      here you go:
      An object-oriented interface to Ogg Vorbis information and comment fields, implemented entirely in Perl.

      --
      I just don't trust anything that bleeds for five days and doesn't die.
    3. Re:and like every Linux geek.. by Josh+Coalson · · Score: 5, Informative
      I'm going to say "Where the ogg version?"

      Right here. Or here for FLAC.

      Josh

    4. Re:and like every Linux geek.. by bwhaley · · Score: 4, Insightful

      I'm going to say "Where the ogg version?" :)

      At the risk of wasting some karma...

      I'm sick of hearing about Ogg. Great, it's free as in beer and freedom. I'm pro freedom. But seriously, it's not going to catch on. mp3 is here to stay my friends, and while ogg may be a technically superior format, the rest of the world is not going to convert the mp3 collection to ogg's. It's just not going to happen. And if nobody converts their files to ogg's, why would manufacturers waste development time and costs putting ogg support into their products?

      Maybe I'm being cynical but I think it would take a miracle at this point.

      --
      "I either want less corruption, or more chance
      to participate in it." -- Ashleigh Brilliant
    5. Re:and like every Linux geek.. by Minna+Kirai · · Score: 5, Insightful

      And if nobody converts their files to ogg's, why would manufacturers waste development time and costs putting ogg support into their products?

      So they can have a superior format without the risk of Apple or Microsoft quadrupling the license fees 9 months down the line.

      Actually, because Microsoft is pushing their own audio format, manufacturers will have a low-cost chance to push Ogg. They're going to have to expand the devices to recognize non-mp3 files anyhow... why not throw in the free integerized Ogg code while they're at it?

    6. Re:and like every Linux geek.. by dotwaffle · · Score: 2

      Errr. OGG support is like really tiny, and could EASILY fit into space left on a ROM etc... I'm sorry, but there is no excuse not to support all the major codecs on a player (MP3/OGG/WMA/WAV) as the data they take up is minimal. Who fills up a ROM chip these days anyway? They're ridiculously cheap, and they often have loads of space...

    7. Re:and like every Linux geek.. by pediwent · · Score: 2, Interesting

      Ah, but is that the correct analogy or is it more like VHS vs. Beta? Beta is a clearly superior videotape format, yet VHS had the manufacturer's support (you would think Sony would have remembered that when they came out with the memory stick). Try to find a Betamax VCR these days - good luck. I don't pretend to know which audio format will "win", but don't underestimate the impact of manufacturer's support and don't forget all the hidden business agendas present in decisions to support a given format. It's not only about technology.

    8. Re:and like every Linux geek.. by fiftyfly · · Score: 2, Insightful
      And if nobody converts their files to ogg's, why would manufacturers waste development time and costs putting ogg support into their products? So they can have a superior format without the risk of Apple or Microsoft quadrupling the license fees 9 months down the line. Actually, because Microsoft is pushing their own audio format, manufacturers will have a low-cost chance to push Ogg. They're going to have to expand the devices to recognize non-mp3 files anyhow... why not throw in the free integerized Ogg code while they're at it?
      Exactly. I'm certainly not going to rerip my 400+ disc collection but when buying new hardware codec support & expandability are very important to me. Just because I don't want to duplicate a massive prior effort doesn't mean that, one day, I won't have to.
      --
      "Sanity is not statistical", George Orwell, "1984"
  2. Another MP3 tagging library.... by tcopeland · · Score: 5, Informative
    ...written in Ruby, can be found right here. From the project page:

    mp3taglib is a id3v1/id3v2 mp3 tagging library for ruby, based on id3lib. At
    this early stage it already supports most of the fields of id3v2 tags. Mp3
    encoding informations can also be retrieved.
  3. Nice to know... by jargoone · · Score: 5, Informative

    It's nice to know you can do this, and I've used the modules referenced for custom fixes. But don't reinvent the wheel if you don't have to: EasyTag probably does 90% of what you would write something custom for.

    1. Re:Nice to know... by rf0 · · Score: 4, Insightful

      Hes an engineer so he will, like most of us spend 20 hours writing something when he could do it in 10 with someone else code or in 5 if doing it manually

      Rus

    2. Re:Nice to know... by redtail1 · · Score: 2, Insightful

      Good point about reinventing the wheel but I appreciate tutorials like this one when I've been wondering how to go about writing such a thing. Sometimes I want to learn how it is done more than I want to use the finished result.

  4. Perl.com article by twoshortplanks · · Score: 3, Interesting
    On a similar note, there's a perl.com article on using MusicBrainz that was published recently.

    Identifying Music with MusicBrainz

    --
    -- Sorry, I can't think of anything funny to say here.
    1. Re:Perl.com article by blech · · Score: 5, Informative

      To be fair, the MusicBrainz article for perl.com (that, full disclosure time, I wrote) doesn't cover as much ground as the Developer Works article, which seems to be going through all the steps needed to write an autotagger in Perl.

      However, I was a little dissapointed that Teodor didn't spell out more of his reasoning for his choice of modules. I covered the (then) available Perl mp3 modules for a talk at YAPC::Europe this summer, and if you're not sure which modules to use, I'd suggest having a look at the slides (80K PDF) and notes.

      In any case, I look forward to the second part of the article, to see how the script shakes out in the end.

      --
      DO NOT LEAVE IT IS NOT REAL
  5. Perkasdflop by Anonymous Coward · · Score: 2, Funny

    To be honest, I'm waiting for the Common Lisp port...

  6. Self-respect by trentblase · · Score: 2, Insightful
    Every self-respecting computer and music fan needs to be able to manipulate MP3s

    Have those lossless compression afficionados no dignity?

  7. Talking down? by GeorgeH · · Score: 3, Funny
    MP3s -- the defacto standard for recreational digital music use
    Really? I had no idea! What's next, the Internet on computers? Man, that would be cool, maybe they could put dancing hamsters on it.
    --
    Why can't I moderate something "Wrong" or at least "Grossly Misinformed"?
  8. Why stop with tagging? by Dr.+Zowie · · Score: 5, Interesting
    Perl (with PDL) is powerful enough to remix, comb-filter, compress, depop, noise-gate, and generally munge your mp3s as much as you want.

    We're in an exciting time when many of the scripting languages are being augmented to be able to handle Real Data (Numpy is another example).

  9. What about emacs MP3 mode? by crow · · Score: 4, Interesting

    Seriously, I've been thinking it would be cool to have an emacs mode for MP3 files. The raw data wouldn't be displayed, but the ID3 tags would be available for editing.

    1. Re:What about emacs MP3 mode? by Anonymous Coward · · Score: 2, Informative

      30 seconds with google revealed, among several MP3 player modes, this MP3 tag editor mode for emacs, released in 1999. Next question?

  10. genre splitting by digitalsushi · · Score: 2, Interesting

    Does anyone remember that perl module that would "listen" to the mp3 and decide which musical genre it thought it was? I'm not referring to matching the ID3 tags against something... it would make a guess based on stuff like the tempo and frequency range, et cetera. (I have no idea how it actually works, and I have no idea if it is even real. I just know I read about it a long time ago and figured someday it might be something a nonprogrammer like me could use)

    --
    slashdot: where everyone yells sarcastic metaphors to themselves to understand the issue
  11. Re:Tagging my ass... by Gwala · · Score: 2, Informative

    The only reason for that was that you couldnt add anything more to the beggining of the stream, unless you broke backwards compatibility. The first (?)128 bytes were assigned for the ID3v1 tag, in the initial MP3 standard, when ID3v2 was designed, adding it to the end of the ID3v1 tag would have resulted in nastly click's and pop's, when an older player didn't understand it. When it was added to the end, past the end of the track, it retained backwards compatibility (without ugly pop's), and allowed unlimited storage of additional data. ID3v2 is scalable enough, that if ID3v3 is realised for some god-foresaken purpose, it could be fitted on the end, without any future problems.

    That being said. Foresight that people would need more than what ID3v1 offered shouldnt have been too difficult to muster, an extra forced 256b surely wouldnt extend everyones downloads by too much.

    -Adam

    --
    #!/bin/csh cat $0
  12. Yeah! I love crypted source! by nirvanis · · Score: 2, Funny
    $filename =~ m/([^-_]{3,})\s*-\s*(.{3,})\s*\.[^.]+$/

    ;-)

    --
    nirvanis
  13. Re:Tagging my ass... by drinkypoo · · Score: 4, Insightful
    ID3 tags exist so that even "improperly" named MP3 files can have valid information. Also, would you prefer to encode artist, title, album, and track number information in every MP3? I god damn HATE it when people put ALL that in there. The filenames frequently exceed filesystem limits; They won't even fit on a mode 2 ISO9660 cdrom (let alone MODE1), so you can NOT put all that information into the title. An ID3-tagged mp3 will preserve all that information and more (You can even put lyrics into your ID3v2-tagged files) regardless of the filename.

    Filenames are not an appropriate place to store metadata because they are volatile when moving a file between media.

    --
    "You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
  14. Re:How come many Mp3's don't have this data? by blech · · Score: 5, Informative

    Generally, CDs don't have all the track information on the CD. RealPlayer, Windows Media, iTunes and so on all use a computed identifier of some sort, based on the length of tracks, typically, to look up the CD information from an online database.

    Of course, because this means that *someone*, *somewhere*, ended up typing in the data, there are errors in a lot of the data. Most of the CD lookup databases are very bad at handling compiliations, and can have problems with any of the items of metadata other than title and artist (for example, 'year' often ends up as the year the CD is ripped, not the year the music was produced).

    There aren't many programs that strip the data that's produced, though. Thankfully.

    --
    DO NOT LEAVE IT IS NOT REAL
  15. Re:MP3 is Evil by Anonymous Coward · · Score: 2, Interesting

    great I'll switch to it! where's the ogg firmware for my car stereo, my audiotron, my portable CD player, my Mp3 capable boom box, my pocket mp3 player and my dvd player...

    oh wait... Ogg isnt supported on any of those... so in order to support this "FREE" format I need to go spend $5000.00 on all noew gear...oh wait I can't even BUY anything that support's ogg except for one obscure pocket mp3 player...

    nevermind, I'll stick with the mp3 format that is free as far as I'm concerned and use the items I already own.

  16. I can tell by metalhed77 · · Score: 2, Interesting

    I did some testing between flac and ogg at its highest setting. Quite simply the ogg was very good BUT on certain parts, with some strange harmonics, the ogg would drop certain frequencies. Besides, with hard disk space so cheap these days I have no qualms ripping my music to .flac. I'm going to lose the CD anyway, might as well have a viable backup (/me cannot hold on to a CD for more than a few months without scratching it).

    --
    Photos.
  17. Re:How come many Mp3's don't have this data? by E-Lad · · Score: 3, Informative

    You're referring to CD-TEXT, a standard of sorts introduced by Sony where Artist, Album name, and track titles are encoded onto an audio CD in the subcodes.

    It's true, not every commercial pressed CD out there has this feature, and believe it or not, not every CD-ROM (particularly older ones) can read the subcodes to extract the CD-TEXT info.

    Sony Music includes CD-TEXT on all the CDs in it's catalog (to complement the CD-TEXT display features on most of it's car CD players.) I don't know about the other major labels.

    My own experience with small labels tends to indicate they're not large users of CD-TEXT, but you can find the odd release which does have it.

  18. MusicBrainz by Mr_Silver · · Score: 3, Interesting
    MusicBrainz::Client and AudioFile::Identify::MusicBrainz were not used because MusicBrainz appears to be a less comprehensive database of released CDs than FreeDB.

    True, but the point of MusicBrainz is not to hold a database of released CD's but more snapshots of MP3 tracks.

    At the moment, without MusicBrainz I cannot automatically populate my ID3 tags with the information about an album unless I get it out of the cupboard and type the details in myself.

    MusicBrainz allows me to do all this without any access to the CD's

    --
    Avantslash - View Slashdot cleanly on your mobile phone.
  19. More complete analysis of your "system" by jared_hanson · · Score: 2, Insightful

    It is based on the same system that killed many due to "patent protection" on AIDS drugs. Do not use or support an evil system, especially when alternatives are available.

    What the "system" you refer to does is set up a risk-to-reward ratio that encourages ideas to be pursued and developed. It is a serious money risk to develop AIDS drugs, or any other complex product for that matter. To encourage the capital outlay required, the reward is granted to encourage development.

    With out this "Evil" system, the AIDS drugs would likely not have even be pursued, and all the people would have died. Regardless of weather overpriced drugs cause some people to not be able to afford drugs, less people died with the current system than would have in a system in which no risk-reward ratio exists.

    Take communist Russia for example. When people are guaranteed equal pay regardless of effort, the effort level of everyone goes down. Eventually, no work is being done and pay drops to zero, resulting in a very bad situation. If there were to be no return on AIDS drug research, there would be no research even started. Of course, governments could always fund it, but governments need resources too. And the best system in which to increase resources in one that encourages rewards.

    --
    -- Fighting mediocrity one bad post at a time.
  20. Re:Hopefully iTunes will defeat mp3 by jdreed1024 · · Score: 4, Informative
    Ipod is only cool that it will play an mp3, their wierd itunes format is not desired as it is not compatable with 99.9% of the hardware out there.

    Besides, I will not tolerate ANY DRM in my music files.

    By "weird itunes format", I assume you're referring to the AAC MPEG4 format, which is an industry standard.

    Also, there's only DRM in files that you buy from iTunes Music store. Please stop spreading the FUD that "AAC == DRM", because it's simply not true. Just like "EXE file" does not translate to "software which needs a registration key" and "VHS tape" does not translate to "protected by Macrovision". AAC is an open MPEG4 format to which DRM _CAN_ be applied. By default, it is not applied.

    Also, what do you mean by "A2D" converter? Why would an MP3 player, which decodes digital signals into analog signals which your ear can hear need an "analog to digital to converter"?

    --
    There is no sig, there is only Zuul.
  21. Re:I remember by (trb001) · · Score: 2, Insightful

    You had 'discovered' a new way to store music...that being a small in size, digital way to store music. Prior to mp3, there was no way to store music digitally without taking up a lot of honking space. Remember, this is also before hard drives were sickly big (in 1996 when I started ripping to mp3, I had a 6 gig hard drive...and that was large).

    Ogg is *nothing new*. It's different, not *new*. Until mp3 licensing fees start affecting Joe User, he's not going to care about different formats. MP3 is mainstream, Ogg isn't, and the audio quality difference matters about as much as the quality difference between mp3s and cds...that being none at all, except to the 1% of people that are self-proclaimed audiophiles.

    Ogg is wonderful, sure, but your argument that it's equivalent to the mp3 revolution is lacking.

    --trb

  22. Re:defacto? by Alan · · Score: 2, Insightful

    When was the last time you heard someone say they were going to download some wmas off the internet? MP3 is what people use to refer to digital music files, be it an actual mp3, a wma, an ogg, or whatever.

    Personally I think that wma will gain a foothold only because the default tools in windows only rip to that, but I think that mp3 is "easier" as all the hardware and software that plays digital music play it. It might not be as good as ogg or aac or wma, or allow the music industry to control it through DRM, but it's the lowest common denominator that everyone understands and supports.

    Also, I doubt that there's a WMA *only* hardware player out there :)