Howto: Use cplay like a pro

I’ve been talking big lately, trying to endorse the use of old, outdated computers as torrent slaves or multimedia centers, but I haven’t done much to explain the nuts and bolts of some of the software I’m pushing.

Well, that’s got to change. I’m making a point of using some of the console programs and utilities I mention, and I’m putting together notes to myself (and other folks, of course). It’s only fair: If I’m going to persuade you to use your old 120Mhz Pentium Compaq 1020 as a music station, I need to avoid leaving you at the terminal prompt, without a clue of what to do next.

Console programs aren’t like normal GUI-driven programs, for the most part. If I set you down in front of any generic GTK-style application and give you a mouse, you’d probably have it all figured out — from its mission to its mechanics — in the space of less than an hour. There’s a common look and style between Word and Firefox and Blender and Deluge, and that helps you get comfortable with it.

Terminal-driven applications are much more intimidating. Now, instead of just the mouse and a maybe a menu bar, you’ve got 104 keys you could press, and any one of them might trigger a catastrophe. Plus key combinations, and in some cases, double and triple key combos. No menus sometimes. Sometimes it’s just a blank, black box and a blinking cursor — with no obvious relationship between how it works and how to get it working.

It’s enough to drive a person back to X.

Enough jibba-jabba. I’m using cplay these days, mostly because it’s not as common a choice as mpd plus ncmpc, and it has a little less intuitive layout than mp3blaster. If you need something more versatile, go with the former. If you need something more obvious, go with the latter. cplay falls somewhere in the middle — not ornate, but not as multifaceted either.

cplay is a lightweight and comfortable way of playing tunes without going overboard, and yet at the same time it’s as flexible and comprehensive as you’re willing to make it. cplay is a frontend, which means it doesn’t really do the dirty work of playing your music. Instead, it handles the starting and stopping, the volume control, the sequencing and searching.

The actual grunt work is handled by subordinate programs like ogg123 (part of vorbis-tools) and mpg123 (there are more options on the cplay package page). Unless I’m mistaken, vorbis-tools is installed by default, but you’ll need mpg123 or something like it if you want mp3 playback. So if nothing comes out of the speakers the first time you use it, make sure you have something available that can handle your tunes.

When you start it up, you get this.

Just a directory structure. If you didn’t know any better, you’d think you were using clex or something. And really, it works much the same way. Navigate to your music directory using the enter key to move through folders. The backspace key jumps up to the parent directory.

You might feel that without some sort of directory tree, it can get a little tedious navigating between directories. Pressing “o” lets you jump to a directory, but there’s also a bookmark system to help navigation. Pressing “m” gives you the opportunity to assign a key letter to the directory you’re presently viewing. Jump back to that directory from anywhere by pressing the apostrophe, and repeating the letter. Bookmarks aren’t saved between sessions, though.

After that, cplay is very simple in principle. Press enter on any supported audio title, and cplay will start playing it. When that title is over, it will stop. Pressing enter on another title, while it’s still playing the last one, will cause it to jump to the new title without finishing the old one.

That’s pretty straightforward. Now here’s where cplay goes from functional to flexible. Press the Tab key.

Now you’re looking at a playlist screen. Tab again takes you back to the directory structure. You can add files and directories to the playlist by pressing the “a” key. You can select a specific array of files and folders with the spacebar, and each one is marked with a hash symbol.

You’re free to bounce back and forth between the directory structure and the playlist as much as you want, and add as many songs and directories as are practical.

To manage your playlist, use the “m” and “M” keys to shift things up and down, and “d” to remove a track, “s” to shuffle and “S” to sort it. If you decide to dump it all, press “D” and you start fresh.

Now let’s take it for a spin. Build a playlist and press enter on a song. The tunes should start at the track you highlighted.

You can control playback with “n” and “p” — next and previous. The left and right arrows seek through the song, backward and forward respectively.

The “x” key stops play and the “z” key pauses. They both seem to have the same effect, but they’re slightly different: Where “z” pauses the client program (ogg123 or mpg123 or what have you), “x” actually stops it. Pressing “z” or “x” again causes the audio to pick up at the exact same point, so the effect is the same. But if you watch htop while you’re doing it, you’ll see “x” has a different effect on your process list.

One of the nicest things about cplay is the volume control. Instead of an up-down slider control, the number keys 1 through 0 jump straight to a proportional volume level. By default cplay changes the Master volume control; that I find a little presumptuous, so I usually start cplay with the -v flag, which tells it to use PCM instead.

cplay handles the common m3u playlist format too. To save the current playlist, press “w” and you’ll be prompted for a filename, which is automatically suffixed with m3u, and should be accessible from just about any other common audio player. To open a playlist in cplay, add it like a normal track, by pressing “a” while it’s highlighted in the file list.

And just so you know: Pressing “h” at any time brings up a brief help screen.

cplay does a lot of other things too. Pressing the exclamation point lets you issue a shell command, without interrupting the music and with a “$@” variable for the selected file. I haven’t had a lot of luck with that though, because issuing just about any command tends to kill cplay (but not the client player, so the music goes on :) ). It’s worth noting though, and it might not be a problem if you’re using another distro.

You can also build regex searches, if you’re keen on culling out a certain array of filenames. You can search recursively and invert searches as well. When your playlist or directory list becomes enormous and hard to find things, you can isearch through the names with the CTRL+S and CTRL+R keys.

Press escape to cancel out of the search mode.

So what doesn’t cplay do? Well, it won’t sync with your iPod. It won’t throw up a cutesy album photo of what’s playing, along with the IDv3 info. Streaming audio is beyond its reach. You can’t edit tags on the fly, and I haven’t found any way to control it remotely, such as through a network. And it’s not a music management suite, a la iTunes, which seems to be what the young-uns are all learning these days.

But the biggest selling point for cplay is this:

I’m running cplay in a terminal window there, and as you can see, the processor load is around 0.7 percent of my 1Ghz for cplay, with a negligible amount for the ogg123 client processes. And the memory profile is equally svelte: 0.8 percent of my 512Mb for cplay, only one-half of a percent for each of the ogg123 processes.

That means the total processor load is under 1 percent, and the memory profile is around 9Mb, sometimes more, sometimes less. By comparison, Audacious — which I consider a lightweight — uses more than 14Mb at a time and needs around 3 percent of my processor, spiking or falling here and there. And Winamp, running on the Inspiron 600m my parents keep in the other room, needs similar numbers. I don’t want to know what some of the heavyweight management suites need.

Spacewise, cplay is pitifully small. It has almost no dependencies outside the standard framework that comes with Ubuntu, and even if you install it with vorbis-tools and mpg123, you’re downloading less than 275Kb and using under 1.3Mb when installed. If your collection is strictly ogg format, like mine, you’re talking about less than 170Kb for the download and a measly 1Mb occupancy. I’ve written letters to Mom that take up more space than that.

So now, to reinforce my original point: That 166Mhz laptop with 64Mb and the 3Gb hard drive you have in the closet could easily handle the workload. With a very lightweight operating system and a minimal GUI, you could set up Ubuntu to run on a machine of that caliber, give it network (or even local) access to your music collection, and run it into a stereo or a decent pair of laptop speakers … and give it a little more life.

Next: How to whip rtorrent into an automated torrent management frenzy.

17 Responses to “Howto: Use cplay like a pro”


  1. 1 fareast May 1, 2007 at 4:12 pm

    Your site really rocks! And thanks for the tip about Jamendo; I have already gotten three nice albums from them. Still haven’t been able to figure out how to unpack your speed for Feisty guide, but I’m a relative Linux newb, so getting the answer is half the fun. Cheers!

  2. 2 K.Mandla May 1, 2007 at 6:03 pm

    Thanks! :D I was just tinkering with the box.net widget and trying to put those files into the sidebar. If you check that page again, I relinked them with the proper names, so they should be easier to decompress now. Cheers!

  3. 3 Geoff May 22, 2007 at 5:56 am

    I was pushing cplay through a CRT TV and it works a charm. However, with the guilt of global warming weighing heavily upon me, I’ve ditched the idea of yet another device sucking at the sockets.

  4. 4 Sy Ali August 9, 2007 at 2:38 am

    I finally got cplay working on my Zaurus. It’s awesome. =) I even got mikmod working too.

    I wish it had sidplay support. I might have to hack that in one day.. once I get a sidplayer working on my Zaurus.

  5. 5 james August 19, 2007 at 4:06 am

    Is there a way to add the whole directory to the playlist to play the music in the directory in shuffle mode?

    Thanks for the article!

  6. 6 K.Mandla August 19, 2007 at 6:19 am

    Hi James. I believe if you select the directory with the spacebar, you can add the entire substructure with the ‘a’ key. From there, check the help screen for the shuffle key (I’ve forgotten it, since I don’t shuffle up my tunes very often). Have fun!

  7. 7 james August 20, 2007 at 4:56 am

    Hi K.Mandla,

    Thanks for your quick reply!

    Selecting the directory is an option, another possibility which comes in handy here is “i” for selecting the inverse. This way I can select a few songs/directories/.m3us I don’t want to hear and then select the inverse - which is what i want to add.

    Shuffling the playlist is s when the playlist is displayed.

  8. 8 Erkkimon August 25, 2007 at 1:11 am

    A really good howto! Cplay can be used remotely using ssh and screen.
    1. Log in on the target computer using ssh. Note that the target computer needs to have ssh daemon running and you must have ssh installed on your client computer.
    2. Start cplay in screen, like “screen cplay”. Note that you must have screen installed on the target computer. Then close your terminal emulator.
    3. Now your player should still play music. If you want to edit playlist or something, log in again on your target computer and attach the screen in your terminal emulator commanding for example “screen -rx”.

    I’m not sure if I got what you meant with remote control in the howto but hopefully this helps you and people who read this howto!

  9. 9 DukeXC September 17, 2007 at 6:31 pm

    Hey, I ran across your site looking for a bittorrent client, and although I eventually changed clients, rTorrent was very useful for a while as I re-organized my RAM priorities.

    On linking to cplay and trying it I was simply amazed by the power its direct, no-nonsense interface provided, and had been using it quite happily until I very recently ran into sound quality troubles with the program - understandable as this guide is for weaker machines, but for an audiophile that slight hiss and crackle is a serious killer.

    While cplay is an incredible player, I’d suggest also giving cmus or moc a try. moc (music on console) is extremely similar to cplay but with some added functionality, a slightly more attractive interface and pristine sound quality. cmus, although not to my tastes, is actually a full-fledged music library app in curses, with some very interesting customizeability options.

    I love the site, I’ve found a plethora of useful apps here - I just thought I’d add my two cents, as I have since noticed a huge number of underappreciated terminal apps.

  10. 10 Paul December 4, 2007 at 4:26 am

    Is there any way to crossfade songs in cplay like in ncmpc?

    Thanks

  1. 1 Howto: Use rtorrent like a pro « Motho ke motho ka botho Trackback on May 2, 2007 at 4:13 pm
  2. 2 Terminally Incoherent » Blog Archive » A day without X Trackback on May 21, 2007 at 11:56 am
  3. 3 test 07/29/2007 « Strange Kite Trackback on July 29, 2007 at 10:47 am
  4. 4 My daily readings 07/30/2007 « Strange Kite Trackback on July 30, 2007 at 4:43 am
  5. 5 links for 2007-09-14 « Stand on the shoulders of giants Trackback on September 14, 2007 at 4:27 pm
  6. 6 Tiled window manager « Motho ke motho ka botho Trackback on December 13, 2007 at 10:26 am
  7. 7 Howto: Install cplay for the XO « Motho ke motho ka botho Trackback on January 23, 2008 at 6:38 pm

Leave a Reply




Welcome!

Most recent desktop


May 8, 2008
XFCE 4.4.2 on Crux Linux
750Mhz Celeron 128Mb PC100

Most recent game


Project: Starfighter on Crux
550Mhz Celeron 192Mb PC100

Be counted!

License

This work is licensed under the GNU Free Documentation License. Please see the About page for details.

Blogs worth watching

Ubuntu Feeds

RSS Planet Ubuntu

  • An error has occurred; the feed is probably down. Try again later.

Blog Stats

  • 589,277 hits

Categories