Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Audio Related Programs

by vroom (Pope)
on Jan 06, 2000 at 23:46 UTC ( #1819=sourcecodesection: print w/replies, xml ) Need Help??
Smartphone/Media Center integration via XMPP over GoogleTalk
on Aug 03, 2009 at 14:03 UTC
by mikelieman
In celebration of the birthday of Jerry Garcia ( b. 8/1/1942 d. 8/9/1995 ) I present a Perl script which allows a smartphone user (e.g.: Blackberry ) to control an instance of Amarok 1.4 running remotely on a media center PC by chatting with the daemon through Google Talk.

A few weekends ago, we were sitting on the porch wondering which of MANY Red Rocks shows we had queued up on the media center PC we were listening to at the moment when we started discussing ways to get the information about what we were listening to displayed conveniently.

A few hours later, after dismissing some ideas involving scrolling LED marquees over the cabin door, I got the idea that "Jeff's blackberry can run Google Talk. I can have the a script pull data from Amarok via its DCOP integration{1} and use XMPP to send 'Now Playing' messages" over Google Talk to the daemon's friends.

Once we had Song Change notices being sent, the natural extension was to have a two-way conversation. By the next morning we had transport and volume control integrated. A week later, I spent an hour or two adding *very basic* playlist construction support, and that was pretty much all you'd ever need.{2}

You'll need a Google Talk account, and the people who get control and notices need to be setup to chat with the Google Talk account ( I used the Gmail UI ).

Once the server has friends to chat with, fire up Amarok, fire up this script, and it'll connect to Google Talk and start notifying of song changes and accept volume, transport control, and playlist management commands.


{1} Which in going to require an abstraction layer or something to accommodate Amarok 2.0's different yet still standards conforming desktop integration API.

{2} While testing, we ended up quickly adding 2 more features ( not shown). "X" will just stop what the server's doing, load a pre-set playlist and just start playing that -- for times when you just want music up, but don't have the time to construct a playlist. And a patch to return to $MUSIC_ROOT if you get confused where you are browsing for content. The playlist construction features need some work.

Random-fill media device
on Sep 19, 2008 at 02:22 UTC
by colakong
A script to fill a flash device with randomly-selected music from your collection. I created this to fill my Samsung S3 (using the Korean UMS firmware), as Rhythmbox doesn't have an auto-fill feature.
on Aug 29, 2007 at 19:34 UTC
by Perforin
Little script which plays mp3,wav,wma and midi files!
Album Information Database
on Jan 04, 2007 at 16:23 UTC
by bitsmart
These two scripts are designed to store and retrieve tracks with BPM (beats per minute). Intended for DJs and EJs to find tracks with similar BPMs for the purpose of making mixes. The code is commented in a very elementary way because these scripts were designed for teaching, myself and others. I wrote these in 2001. "" - Adds whole albums/singles/12" records to a simple text database. "" - Queries the simple text database and returns tracks with same BPM.
on Mar 05, 2006 at 03:48 UTC
by jfroebe

This is a work in progress but I've started downloading various podcasts so I can put them on my iPod.  I ran into two problems:

  1. The mp3 files were not bookmarkable, which means that I had to fast forward to where I left off if I wanted to listen to something else for while.  For long podcasts, this can be very annoying!
  2. My iPod can not play RealAudio files.
So I created make_m4b which is able to convert mp3 or realaudio files to a mpeg4 audiobook file.  The iPod is able to play the file and save a bookmark so I can go play it later if I want to without having to fast forward.

The requirements for make_m4b are:

While, this can be used with Windows, I have not tested it. 

This is a variation of Ryan Hayward's code.

Yes, I know system() is bad and I will clean it up later. (I've been sick for a number of days).

on Jun 29, 2005 at 09:38 UTC
by Ctrl-z
Utility to resynchronise iTunes with tracks orphaned on an iPod, or alternatively do a full iPod backup. Big caveats - see POD (err, not iPod) before using
Automatically Encode Ogg / MP3s
on May 18, 2005 at 18:51 UTC
by Vautrin
Basically what this file does is read in a list of filenames, and use those filenames to encode all wav files in the directory to either Ogg or Mp3. Basically it lets me run $ cdparanoia -B to create all the wav files, and then use the following syntax to call
$ ./ "Filelist" "Genre" "Artist" "Album" "Encoding"
Where Encoding is either "ogg" or "mp3", and Filelist is a list of tracks, one after another.
MP3/OGG Data to .xls
on Dec 16, 2004 at 07:57 UTC
by All_Star25

This script takes a directory name as the first argument, parses through it, outputting the artist, title, length, bitrate, filetype, and filename of each MP3 or OGG file in the directory as columns in an Excel spreadsheet (the filename of which is determined by the second argument). As a method of keeping track of progress, it adds a dot to "Processing" after every 100 entries.

Known issues: Files without tags do not work so well. Some OGG/MP3 data may not be entered in some cases, including certain types of VBR encoding ( this is a limitation of the modules used ).

Uses MP3::Info, Ogg::Vorbis::Header::PurePerl, and Spreadsheet::WriteExcel;. Tested with ActivePerl build 810.

MP3/OGG Directory Parse & Playlist Generation with Hyperlinks
on Dec 04, 2004 at 00:53 UTC
by All_Star25
This piece of code takes in a directory as an argument, goes through the directory (but does not include subdirectories), and creates a HTML playlist, with a hyperlink for each entry.
XMMS Controller
on Nov 03, 2004 at 14:32 UTC
by throttle
Well, I often listen to music when I'm working, so I put xmms in background and I play all the mp3s that i have. But I don't like all of them, so i have to resume XMMS' icon (in fluxbox it's a bit boring) and change song. So i wrote this little script. It doesn't occupy much space on the screen, so you can have this in the foreground without problem, and you can change song whenever you want, without having to resume xmms (that must be started before you run this script). This was my first working (and someway useful) perl script. I wrote it this summer.
It needs Tk to work properly, so install it.
Convert FLACs to MP3
on Oct 22, 2004 at 20:36 UTC
by davis
Hand it a playlist, and it'll convert the files in that playlist to MP3 format. This is a script I hacked up and intended to finish properly (add ability to convert to Ogg Vorbis), but never did. FLAC's file attributes (tags) are decided by whoever encoded the file, so you may need to adjust it to suit your needs.
Lyrics Fetcher
on Apr 16, 2004 at 00:25 UTC
by saskaqueer

Locates and downloads lyrics to (hopefully) any song. Simple object interface so you can roll your own. I threw this together because the Lyrics::Fetcher:: modules on CPAN are horrible. The regexes used to extract the lyrics are of course fragile and are likely to break upon any changes to the lyric sites :) I updated the method in which the lyrics are extracted. It is now one general regex, so it should stand the test of time slightly better. It will still break (partially) if any of the lyrics sites modify their templates. I'll try to keep this up to date as maintenance is needed.

There is no guarantee that the first match returned will be the correct song. That is why I use multiple sites, it gives you a fighting chance. Chances are you will receive some lyrics with additional info at the top (songwriter, etc) that I can't filter out easily. So you get stuck with some extras once in a while.

"Intelligent" ID3v2 Tagger
on Jul 21, 2003 at 05:29 UTC
by The Mad Hatter

Given a directory, this will go thru and try to figure out artist, album, and title from the directory structure and filename. A few options allow you to tweak how it gets the information. Once it has gathered the info, it then writes an ID3v2 tag. I would support Ogg Vorbis, but I couldn't find a module on CPAN that could write tags to Oggs. Requires MP3::Tag, File::Find::Rule, File::Spec, and Cwd. (The last two are in the core.)

Nota Bene: Use at your own risk. If this messes up your pristine music collection, makes your socks smell, computer implode, or generally screws up anything, I am not liable.

on Dec 24, 2002 at 16:37 UTC
by pfaut

This program is an MP3 player with a Tk interface. It uses a database to keep track of how recently songs have been played so that it can play songs at random selecting from the least recently played songs.

Merry Christmas!

on Nov 13, 2002 at 22:34 UTC
by Aristotle
Some people archive their CD audio albums as a single MP3 with a CUE sheet supplied. This script uses mpgedit to slice such a monolithic MP3 album into individual MP3 tracks (without reencoding any audio data) and id3tool to tag them with the information from the CUE sheet.
on Sep 25, 2002 at 09:48 UTC
by dbp

This module presents an object-oriented interface to Ogg Vorbis files which allows users to view Vorbis info and comments and to modify or add comments. You can get the whole module here. It is also on CPAN.

Thanks to everyone who helped me with my Inline::C questions over the past few weeks. Also, if anyone finds errors in this code (esp mem or perl reference leaks) I'd like to hear about it.

Update: Note the new name (old was Ogg::Vorbis::Info). Dropped CPAN q as I've put it on now. Code is updated to reflect name.

Winamp random m3u
on Mar 08, 2002 at 15:23 UTC
by OzzyOsbourne
Creates a random playlist of the number of songs that you input. Edit a the $dir1 and $out vars.
Create a playlist for
on Dec 31, 2001 at 06:50 UTC
by gav^
I was fed up of not having a playlist in each directory of mp3s, mainly as I'm lazy and just want to click on the .m3u file :) I also had a stack of playlists that had full paths which broke things when I moved stuff around.

This script with create a playlist in each directory that contains mp3s, nothing else exciting.

M3U Playlist Generator
on Dec 17, 2001 at 09:56 UTC
by xunker

Short Desciption: Produces an .M3U style playlist from a specified path

More Detail: There have been a few other playlist makers posted, but I've given this one the moniker "better" because it's generates useful WinAMP-style .M3U playlists, not just a list of .mp3 files. It finds all MP3 files below a given path, and stores both the file path and the ID3 info (if availble; if not, it uses the filename) in the output M3U file.


  • get rid of the 'shortname' hash -- it works, it was easy, but it's a tacky hack.
  • check for ID3v2 tags ( didn't bother because this was written for my Mp3 collection that I ripped only with ID3v1 tags).
  • Check for the OS it's running on and use proper line terminator ("\n" or "\r\n") and proper directory separator ('/', '\' or ':') accordingly.

This was written for my in-car MP3 player/computer, so when I download new music to it, one double-click will refresh/rebuilt/sort the default playlist, adding the new music just downloaded. Before I did this I had to open the direcotry in WinAMP, sort it and save it. That's a pain with a screen that's a mere 2.2 inches diagonal.

It's not too optimized, but it can still process an archive of 1,300 files in about 1 minute (Pentium 133, 32 Meg, Win2k Pro).

Requires MP3::Info to be installed.

on May 17, 2001 at 22:30 UTC
by strredwolf
I got tired of other scripts/etc which took info from CDDB and failed to rip a CD into MP3's. So I wrote up my own scripts! The first one (wscd2wav) gets the CDDB info, uses cdparanoia, and puts the .wav into it's own directory, setting a symlink for each one. The second one (scan4wav2mp3) looks for the symlinks, reads where the .wav is, and uses lame on the .wav. So far it's working very well.

To use, open up two xterms (or use splitvt or screen) and change into the directory you want the MP3's to go to in both. Run wscd2wav in the first, scan4wav2mp3 in the second.

WolfSkunk ShoutForward
on Mar 23, 2001 at 04:28 UTC
by strredwolf
Crude script which takes a MP3 from a site, downsamples, and reshouts it out to an Icecast server. It'll also work with a Shoutcast server, if you shout to the next port up.

Needs MPG123 and LAME. Contact me if you want to know more about Wolfox Radio.

eXpanium file converter
on Feb 19, 2001 at 13:16 UTC
by C-Keen
This is a fast hack I wrote for converting my mp3 files to dos 8.3 format. This is how my eXpanium mp3 player wants them. Since mkisofs does not preserve the .mp3 extension this hack is necessary. Enjoy! P.S.: Please have mercy with this piece of code since it is my first attempt in perl :-) Suggestions, comments, encouragements... are welcome.


This new version includes a recovery feature and many bug fixes. I have also included some code from the suggestions. Thanks to ervey body who helped me with that. P.P.S: Yes I know the file shortening process could still be more flexible with the files it gets but I will get it done sooner or later :-)

mp3 organizer
on Jan 31, 2001 at 00:27 UTC
by sacked
This script reads in a list of mp3s (assumed to be in one directory) and organizes them into directories by artist/album. It first attempts to use the id3 tag, but if one is not found, it falls back to parsing the filename for the artist name. I use this script every so often because I download all my mp3s to one directory, and it gets cluttered quickly. The script doesn't have the desired results, however, if mp3s without id3 tags have a hyphen in the filename, but don't have the artist first (e.g., "ice ice baby - vanilla ice.mp3").

This is my first post, please feel free to offer comments/criticism. Thanks!

Update: I removed the system calls to /bin/mv and replaced them with calls to rename, after a tip from salvadors.
on Dec 31, 2000 at 10:50 UTC
by crazyinsomniac
I was talkin' w/my dad, about when he was in the army and stuff, and he got to talkin' how he was great w/radio/morse and that type stuff, so i made this script that translates between morse and text and 'sounds' it out. It has a bunch of options and pod ;)
MP3 Playlist generator
on Jul 06, 2000 at 06:25 UTC
by Viking
This generates MP3 playlists from a given directory. It handles sub directories too. Useful for mpg123 or xmms.
MP3 Album collector / list creator
on May 29, 2000 at 18:03 UTC
by Corion
A (quite versatile) program to categorize a directory of mp3 files into albums and to create (HTML-) lists for each album
MP3 to CD Audio
on Jan 06, 2000 at 01:48 UTC
by vroom
This is a script that I wrote to burn mp3s onto audio cd. You can also use a data mode if you just want to move the data to CD
Log In?

What's my password?
Create A New User
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2020-03-30 19:53 GMT
Find Nodes?
    Voting Booth?
    To "Disagree to disagree" means to:

    Results (176 votes). Check out past polls.