Rock Out with Your Console Out

Playing and managing your music in text mode.

Some of you probably have played audio files from the terminal with one-line commands, such as play, or even used the command line to open a playlist in a graphical music player. Command-line integration is one of the many advantages of using Linux software. This is an introduction for those who want the complete listening experience—browsing, managing and playing music—without leaving the text console.

Thanks to the Ncurses (New Curses) widget library, developers can design text user interfaces (TUIs) to run in any terminal emulator. An Ncurses application interface is interactive and, depending on the application, can capture events from keystrokes as well as mouse movements and clicks. It looks and works much like a graphical user interface, except it's all ASCII—or perhaps ANSI, depending on your terminal. If you've used GNU Midnight Commander, Lynx or Mutt, you're already familiar with the splendors of Ncurses.

An intuitive interface, whether textual or graphical, is especially important in a media player. No one wants to sift through a long man page or resort to Ctrl-c just to stop an annoying song from playing on repeat, and most users (I'm sure some exceptions exist among Linux Journal readers) don't want to type out a series of commands just to ls the songs in an album's directory, decide which one you want to hear and play it, and then play a song in a different directory. If you've ever played music with a purely command-line application, such as SoX, you know what I'm talking about. Sure, a single command that plays a file is quite handy; this article, however, focuses on TUI rather than CLI applications. For many text-mode programs, Ncurses is the window (no pun intended) to usability.

Note to developers: if you want to write a console music player, take advantage of the Curses Development Kit (CDK), which includes several ready-made widgets, such as scrolling marquees and built-in file browsing.

Now, on to the music players!

Mp3blaster

Mp3blaster was the first console music player I ever used. That was in 2007, by which time it already was a mature and full-featured application. Its history actually dates back to 1997, before the mainstream really had embraced the MP3 format, let alone the idea of an attractive interface for controlling command-line music playback. Back then, it was humbly known as "Mp3player".

Despite the name, Mp3blaster supports several formats besides MP3s. Currently, these include OGG, WAV and SID. Keep an eye out for FLAC support in the future, as it is on the to-do list in the latest source tarball.

One nice feature of Mp3blaster is the top panel showing important keyboard shortcuts for playlist management. You can scroll through this list using + and -. There is also a useful chart on the right side that shows ASCII art playback symbols (such as |> for play) above their respective shortcut keys. Press ? for detailed help.

You can customize any of the keybindings in your configuration file, which is usually located at ~/.mp3blasterrc. I had to change several of these in order to use Mp3blaster in GNOME due to conflicts with my global hot keys. Mp3blaster's default keybindings are better suited for use without X.

Figure 1. A Playlist in Mp3blaster

Herrie

Herrie, meaning "clamour" in Dutch, was first released in 2006. Somehow it has escaped mention in many articles on console music players, but the Herrie community group on the music Web site Last.fm shows true fan dedication.

Herrie is great for Last.fm users because it's so easy to set up track scrobbling. Most of the music players in this article support scrobbling in some capacity—it's all open-source software, after all, and in theory, you can write a script to make anything do anything—but configuration is exceptionally simple with Herrie. All you have to do is put your user name and password in your ~/.herrie/config/herrie.conf file. Note that the password should not be in plain text; rather, you should type in the output of printf %s p4ssw0rd | md5 as stated in the configuration file itself.

Figure 2. Herrie shows the current playlist on top and a file browser on the bottom.

MOC

Music on Console (MOC) is a good choice for music libraries that consist of OGG, WAV and MP3 files. It's easy to use out of the box, boasting a two-paned interface similar to that of Midnight Commander, with a file browser on the left and your playlist on the right. The default keybindings are intuitive—mostly single letters that stand for what they do, such as n for "next track" and R to toggle random play, so command-line newbies need not fear any Emacs-style digital acrobatics.

MOC is my go-to Linux music player these days. It's fast and slick, and it looks just how I want now that I've edited my ~/.moc/config file to adjust the colors and the widths of each window pane. Another plus is its support for the JACK Audio Connection Kit (JACK).

The command to start MOC is mocp.

Figure 3. My Customized MOC Layout

Emacs + Bongo/EMMS

If Emacs-style digital acrobatics are your modus operandi, check out Bongo and the Emacs Multi-Media System (EMMS). Both media players run inside Emacs and provide similar functionality. The main difference is that EMMS is designed to run unobtrusively in the background, while Bongo emphasizes the user interface.

Bongo and EMMS are written in Emacs Lisp. You can install them the same way you'd install any other Emacs package; this may vary from distro to distro, but no matter what operating system you're using, you'll probably end up editing some Lisp configuration files. One of the first things to configure is your list of back ends. These programs don't actually do the dirty work of playing your music files; rather, they are front ends for other programs.

You can link any back end of your choice to a file type as well as pass custom command-line arguments. For example, one of the back ends Bongo recognizes by default is mpg123. If you want it to use, say, mpg321 instead, it's just a matter of editing that line in your configuration file or using Emacs to access Bongo's built-in customization dialog with M-x customize-group RET bongo RET. You can add a custom back end with a few lines such as these:


(define-bongo-backend mpg321
  :pretty-name "MPG-Thr33-Tw0-0ne"
  :extra-program-arguments '("--loop 0")
  :matcher '(local-file "mp3" "wav"))

Although I use Emacs from time to time, I'm no guru; I admit that the time I spent with Bongo was flustering. For instance, I pressed Return to start playing a track—easy enough—but then realized I didn't know how to turn it off. I entered M-x apropos RETURN bongo and read through the list of Bongo commands until I found the one I needed: M-x bongo-stop. The GitHub home page reveals that you also can stop playback immediately with C-c C-s, and there are other key combinations for fancier tricks, such as 3 C-c C-s to stop playback after the next three tracks finish playing.

That example is a fair representation of my whole experience with Bongo so far. It can be scary if you don't know your way around Emacs very well, but it's extremely powerful and full of options that you'd probably never thought of before.

If you're a Vi/Vim fanatic, consider Vimmpc and Vimp3.

Figure 4. An Emacs session with the Bongo player in the bottom window, Bongo's README in the top window and Emacs Code Browser (ECB) on the left side.

______________________

Rebecca "Ruji" Chapnik is a freelance creator of miscellanea, including but not limited to text and images. You can find her experiments at http://rujic.net

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

+1 cmus; randomplay for random play

Kevinhss's picture

cmus for hassle free music. I just discovered randomplay looking for random number generators it the mint repos' and it is great. does what it says and remembers acroos sessions.

Reply to comment | Linux Journal

solo ads's picture

Your personal message emailed to 500,000 UNIQUE Prospects.

All interested in your service or product. These are not just your regular everyday emails.
The list members chose to join it by double-opting in. Most people have found that the list is highly responsive.
What more could you ask for? A one time personal-emailing to 500,000 UNIQUE Prospects is
just *$9.95. Purchase it now and we Will Boost The UNIQUE Prospects To 1,
500,000. We feel It will please you to know that we have
been an internationally recognized company for over twelve years.

You better hope you surf to our website before your competition does.

Dont Forget To Use Promo Code 233 For a Lifetime Global-Marketing Membership.
Start Success Now!

re

acacsacacascicacasal's picture

thanks!

Michel Gru's picture

Thanks Rebecca, wasn't aware these were out there, and that many of them.
I really prefer console in favor of GUI.
Maybe you can write an article on the excellent ffmpeg too?

Thanks again,

Michel

Somehow, nvlc passed me by.

Dave Keays's picture

Somehow, nvlc passed me by. Thanks for the tip. Now I don't have to pull my head out of the command line just to listen to music files.

Dave Keays, freelance webmaster

MOC

moc lover's picture

I have been using MOC with transparency for a long time. It is perfect.

+1 for cmus. Been using it

gt's picture

+1 for cmus. Been using it for years. very lightweight, to the point, without any bloat.

I am quite surprised that the author didn't know of cmus, as she has mentioned quite a few obscure ones.

Anyway, good article. It'll sure help a lot of people looking for console players.

Forgot CMUS

Billy Larlad's picture

The author deserves credit for being quite thorough. Unfortunately, one of the omissions is a big one; to me, cmus is the best music player there is, holding its own against all other TUI, CLI, or GUI programs.

forgot about cplay

Craig Hollabaugh's picture

I've been using cplay for years,

https://github.com/holizz/cplay

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix