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
ls the songs in an album's directory, decide which one
you want to hear and
play it, and then
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 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, 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
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 |
as stated in the configuration file itself.
Figure 2. Herrie shows the current playlist on top and a file browser on the bottom.
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
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
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
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
|Designing Electronics with Linux||May 22, 2013|
|Dynamic DNS—an Object Lesson in Problem Solving||May 21, 2013|
|Using Salt Stack and Vagrant for Drupal Development||May 20, 2013|
|Making Linux and Android Get Along (It's Not as Hard as It Sounds)||May 16, 2013|
|Drupal Is a Framework: Why Everyone Needs to Understand This||May 15, 2013|
|Home, My Backup Data Center||May 13, 2013|
- Nice article, thanks for the
4 min 18 sec ago
- I once had a better way I
5 hours 50 min ago
- Not only you I too assumed
6 hours 7 min ago
- another very interesting
8 hours 42 sec ago
- Reply to comment | Linux Journal
9 hours 54 min ago
- Reply to comment | Linux Journal
16 hours 48 min ago
- Reply to comment | Linux Journal
17 hours 4 min ago
- Favorite (and easily brute-forced) pw's
18 hours 55 min ago
- Have you tried Boxen? It's a
1 day 47 min ago
- seo services in india
1 day 5 hours ago
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi
It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?