Rock Around the Shell Rock Around The

Rock Around the Shell Rock Around The

LINUXUSER Command Line: Music Tools Music tools for the command line ROCKROCK AROUNDAROUND THETHE SHELLSHELL You don’t always need a GUI- based tool to play MP3 and Ogg Vorbis tracks. In this month’s col- umn, we look at tools for rocking from the shell. BY HEIKE JURZIK www.sxc.hu f you have a fast machine, players [2] player. There is no difference mat for streaming applications, Ogg pro- such as amaroK or JuK are not only between the major features of these vides a container for codecs such as Vor- Ia treat for your ears – they also give tools, so the options we will be looking bis and FLAC. The Ogg Vorbis codec for you lots of eye candy. But even if you at apply equally to both. lossy audio compression [3] also offers have an older machine, you don’t need The simplest way of calling the pro- superior quality to MP3. The vorbis-tools to do without music while you work. gram is to type mpg123 file.mp3 or program package, which most distribu- Thanks to small footprint command line mpg321 file.mp3. While happily output- tions now include by default, has a use- players for MP3 and Ogg Vorbis, a text- ting sound through your speakers, the ful selection of tools: based console is all you need. program writes additional information • ogg123: A command line player, The other advantage these programs on the console (Listing 1). Besides pro- which works in a similar way to offer is that they integrate nicely with gram version information, the output mpg123 or mpg321. other shell commands. You can search includes information such as the title, • oggdec: A simple decoder that con- your disk for sound files and automati- artist, and album (assuming the ID3 tags verts Ogg Vorbis files to WAV. cally feed the results into a playlist. And are set correctly), as well as the MP3 file • oggenc: Converts WAV and AIFF files if you are converting to WAV format – to quality. If this is too much information to Ogg Vorbis streams. put a collection of tracks on an audio for your liking, you can prevent this out- • ogginfo: Displays information about CD, for example – the command line is put by setting the -q flag. Ogg files at the command line. definitely preferable to any GUI. To interrupt the player, press [Ctrl]+ • vcut: Cuts Ogg Vorbis files. [Z] to send the process to the back- • vorbiscomment: Supports editing of Light Music with mpg123 ground. Typing fg moves the process Vorbiscomment tags. and mpg321 back to the foreground and continues The ogg123 player is all you need to play mpg123 [1] is a command line tool that where you left off. To quit the command an Ogg Vorbis file. Listing 2 shows sam- goes back quite a long way, having line player, press [Ctrl]+[C]. ple output. Again, the normal process served for years on both Linux and Unix control commands apply: [Ctrl]+[Z] platforms. As mpg123 was not released Talking about Ogg allows you to pause the output, fg con- under the GPL, Joe Drew developed a Ogg is an alternative to the MP3 format. tinues playing, and [Ctrl]+[C] quits the completely free alternative – the mpg321 As a completely open, non-patented for- player. Just like mpg123 and mpg321, 86 ISSUE 56 JULY 2005 WWW.LINUX - MAGAZINE.COM Command Line: Music Tools LINUXUSER you can suppress the informational out- might like to call find to locate those ply play the tracks in sequence but uses put by specifying the -q parameter. audio files: a random play (shuffle) mode instead. As mpg123 and mpg321 understand the At One Fell Swoop mpg321 $(find ~ -name "*.mp3") same parameters, this trick also works To play multiple files back to back with for MP3 files. mpg123, mpg321 or ogg123, simply This find command starts in your home specify the filenames when calling the directory (indicated by the tilde), and Converted command: searches all sub-directories for files with To store your MP3 collection on a nor- the .mp3 extension. The dollar sign and mal audio CD, which you can then play mpg321 U the parentheses tell bash to pass the out- on your stereo, for example, you first 05_Lily_Of_The_Valley.mp3 U put from this command as an argument need to convert the compressed sound 08_Stone_Cold_Crazy.mp3 U to mpg321. files to WAV format. mpg123 and 09_Dear_Friends.mp3 Things start to get more tricky if your mpg321 give you the -w option for this. files include blanks or non-standard Note that you need to specify the output or characters; the typical result is a storm file before the input file: of protest in the form of error messages. ogg123 U But a simple shell trick will help set $ mpg321 -w file.wav file.mp3 01_Barenaked_Ladies_-U things right: ... _Celebrity.ogg 02_U [3:47] Decoding of U Barenaked_Ladies_-U find ~ -name "*.ogg" U file.mp3 finished. _Maybe_Katie.ogg ... | ogg123 -@ - -z As you can only process a single file in Of course you can use typical command The find command runs first; any files it this way, it is a good idea to call mpg321 line shortcuts and specify things like finds are piped to the ogg123 call, which within a for loop, thus automating the mpg321 *.mp3 to play all MP3 files (or reads from standard input (-) and edits conversion procedure for multiple files. ogg123 *.ogg for all Ogg Vorbis files) the list of files as a playlist (as specified To convert all the MP3s in a directory to below the current directory. Pressing by the -@ option.) The final parameter, WAV, you would type: [Ctrl]+[C] interrupts the current track -z, makes sure that ogg123 does not sim- and allows you to skip to the next track. for i in *.mp3; do mpg321 -w U To quit the program in this case, you Listing 1: mpg123 Output `basename $i .mp3`.wav $i; done need to press [Ctrl]+[C] twice in quick succession. 01 $ mpg321 01_Keep_ This call assigns every file with the .mp3 If the audio files on your system are Yourself_Alive.mp3 extension to the i variable, and then runs not neatly organized below your home mpg321 -w against the variable. The first 02 High Performance MPEG 1.0/2.0/ directory but are instead spread across parameter is again the output file (made 2.5 Audio Player for Layer 1, subdirectories all over your disk, you up of the base name without the .mp3 2, and 3. extension, and with the .wav extension GLOSSARY 03 Version 0.59q (2002/03/ instead); the second parameter is the 23). Written and copyrights by output file $i. ID3: Audio files (including MP3, Ogg Joe Drew. The command for converting Ogg Vorbis, WMA, and AAC) store meta- information in so-called ID3-Tags. The 04 Uses code from various people. Vorbis files to WAV format is not as long- ID3 tag standard describes two variants: See 'README' for more! winded: the oggdec program automati- cally replaces file extensions, and simply ID3v1 and ID3v2.x. ID3v1 tags restrict 05 THIS SOFTWARE COMES WITH ABSOL expects the file to be decoded: the meta-data to a 128 byte block with a UTELY NO WARRANTY! USE AT YOUR fixed structure at the end of the file. In OWN RISK! contrast to its predecessor, ID3v2 (ver- $ oggdec sunrise.ogg sion number 2.4 is current, and thus the 06 Title : Keep Yourself Alive OggDec 1.0 full name is ID3v2.4) no longer places Artist: Queen Decoding "sunrise.ogg" U the tags in the last few bytes, but pre- 07 Album : Queen to "sunrise.wav" ceding the audio data. The information Year : 1973 [100.0%] can take up to 256MBytes and is orga- nized as a series of frames (which can 08 Comment: be up to 16MBytes.) ID3v2 tags can store Genre : Rock To convert all files at a single pass, sim- a lot more information (even images), ply type oggdec *.ogg. 09 and additionally support the Unicode character set. The two ID3 standards are 10 Playing MPEG stream from 01_ Terminal Ghetto Blaster not mutually exclusive; an application Keep_Yourself_Alive.mp3 ... You may have noticed that the command accessing the meta-information will 11 MPEG 1.0 layer III, 128 kbit/ line tools we have looked at thus far lack simply choose the tag variant it under- s, 44100 Hz joint-stereo interactive controls. If you need an stands. application that gives you these controls WWW.LINUX - MAGAZINE.COM ISSUE 56 JULY 2005 87 LINUXUSER Command Line: Music Tools without the overhead of a GUI, mp3blaster [4] may be just what you are looking for. As the name suggests, the player can handle MP3s, WAV, and Ogg Vorbis files; the player is included with most distributions. mp3blaster does not require a GUI environment; thanks to Ncurses, it is quite happy to run in a terminal window and gives you push button controls. To launch the player, type mp3blaster at the command line. The available key- board shortcuts are displayed at the top right of the window; [+] and [-] browse to the right or left in the list to allow you to view the other commands. mp3blaster gives you really informative output when playing audio files, including tech- nical details about the file itself, the play Figure 1: The integrated help feature describes the major functions. sequence, and the next song on the play- list. You can type a question mark (?) to To play a file, use the arrow keys to automatically adds all the songs on the display or hide the integrated help navigate to that file and then press Enter.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    4 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us