Sunday, February 10, 2013

Death to shuffle!

I have been relying on Plex for my media playing needs for a couple of weeks now (as I mentioned previously) and it has lead to an interesting revelation. I hate the shuffle button. Let me explain.

I most often use Plex via the web app and its interface is a bit simplistic for music streaming. There are no playlists, queues, repeat or shuffle options. You select an album that you want to listen to (or an individual track if you want) and press play. It plays through the album, in order, and that's it. If you want to skip around, you have to do it manually. Ditto if you want to put another album on. At first, I was looking for more options and functionality thinking that it had to be there. Surely I was just missing something. But I wasn't. It just doesn't have the familiar functionality of other music players. But I soon came to realize that this is exactly what I want from a music player.

Previously, my music listening experience usually included listening to a random selection of songs from my entire collection. Sometimes I would play through the tracks from all albums of a single artist, again usually at random. If I ever listened to an album through front to back, which didn't happen often, I would have several albums queued up and there would be no clear distinction between them. I even have key bindings to "next track", "previous track", and "play/pause," so with a twitch of my wrist I could skip tracks. As such, I let my music collection get into horrible disarray. I had singles lying around, parts of albums, mislabeled tracks that would show up under several different artist listings. Finding and playing a single album was often difficult anyway.

So after switching to Plex and being "forced" into respecting the Album again thanks to its limited interface, I have since re-connected with my music in a way that I have been missing for so long, but didn't know what to do about it. I'm going to go into a "back in my day" spiel here, forgive me:

When I was younger I spent much of my spare cash on CDs. I had hundreds of them, and cherished my monster Case Logic folders full of discs. I loved spending time in record shops, fingering through racks of plastic cases, searching for something new to listen to. I had made a ritual of opening a newly purchased CD, always just after leaving the store, peeling the plastic shrink wrap away just so, popping the cover off at the hinge to make removing the sticker across the top easier. The art, the liner notes, the disc itself were all part of the experience and made the whole thing tangible.

Playing music in a single disc CD player added to the interactivity. You had to make a deliberate choice, flipping past other options. While it's not a monumental effort to change discs, doing so is enough of a hindrance that I didn't do it often. Once an album was on, I left it on and let it play through.

MP3s, as much as I love them, have taken this experience from me. After some reflection, I'm now realizing that this is not OK. Music used to be hugely important to me, and since making the switch to 100% digital music, I've lost most of my passion. This isn't entirely the fault of the MP3. I'm older and busier and don't have as much time to search for new bands or learn more about my favorite artists. I don't have a car any longer, and I always found the car to be a great place to enjoy music. On top of that, I've lived in a rather transient state for the last 10 years, and always in apartments, so I haven't collected any stereo equipment to speak of. I listen to music on my laptop almost all of the time. This isn't an environment that is conducive to sitting back and taking an album in.

Anyway, my stripped down media player is letting me get back some of the "old school" experience that I'm now realizing that I've been missing, especially when playing something on the iPad. The album art displays across the full screen, which I hold in my hands. This feels kind of like sitting next to my stereo listening to something while holding the disc, admiring the artwork. I only wish that I could get a full liner notes experience, and flip through a set of artwork, lyrics, and whatever other treasures the artists chose to leave me. Now that so many people consume their music using devices with big, beautiful touch screens on them, it's time that some kind of MP3 linear note system becomes standard. I want to dig deeper into my music, and interact with it again.

I can live without CDs, without a physical product in hand. I can get used to shopping for music on Amazon or iTunes rather than in a (preferably musty) record shop. But I argue that the Album, as a concept, still has tremendous value and should be given respect again. This guy knows what I'm talking about. Plex, with its lack of a shuffle button, has helped me do just that. And the Album should still be, as it always was, more than just an auditory experience. Just like a movie is more than just something to look at, an Album is more than just something to listen to.

Monday, January 21, 2013

Master of my domain

I'm in the middle of a total overhaul of my home network and multimedia collection. Here are some details and thoughts on the matter.

I got a free computer from work a couple of months ago (P4 3 GHz, 2 GB ram) and have since bought and installed a 1 TB hard drive, installed Lubuntu, and set it up on my home network as a file and media server. It's plugged into the TV, but mostly operates sans head. When I need to tinker around with it, I do so via SSH or NX (my favorite remote desktop solution) from one of the laptops. I also setup some samba shares so that it would be easily accessible from our Mac. So now our network consists of the server, an iPad, a MacBook, and my work laptop.

One annoying thing about the iPad is that it's not very convenient to import videos or music onto it. One has to use iTunes (blech!) which doesn't accept many video formats, so conversion is usually required using e.g. Handbrake. In an effort to make my media easily accessible from any device, I installed Plex on the server, and it's fantastic. I just point it to my TV and movie directories, then it automatically grabs information about the shows from the web and displays them nicely in the app. I can access my entire library over the network via a web interface and stream content to any computer in the house. I can also watch everything on the iPad with the excellent iPad app (not free, but well worth the $5). There is no need to re-encode the videos, either, because the software does that on the fly, if necessary. I haven't noticed any performance issues using an older computer as the Plex server, but that might be because I don't have much HD video content.

Plex is great for music, too. I've moved my few hundred GB music library onto the server, and can listen to the entire collection from any device. My collection was a MESS though, so first I used Picard to organize everything. Picard is a nifty tool that scans MP3s and matches them with albums in its database. It can use file names and ID3 tags to search, as well as the audio "fingerprint" from the MP3 itself. I just review what it finds, accept its suggestions, and it will fix the ID3 tags and move/rename the files for me. Their database is extremely extensive, from my experience. I have a lot of obscure stuff and I have only found a few things to be missing so far.

I also have a LOT of photos distributed between a couple of portable HDDs, my laptop, and my wife's Mac. They're totally unorganized so I never look at them and this bothers me. To remedy this I've moved all of my pics to the server, but I want to be able to manage them intelligently from afar (i.e. the other side of the apartment). For this I'm using Lightroom on the Mac to organize and edit our photos. Lightroom is really powerful as both a photo manager and a non-destructive editor. It doesn't alter pictures directly, rather it maintains a "catalog" parallel to the photo files. All edits and Lightroom specific metadata (tags, ratings, etc) are stored in the catalog, as well as a pointer to the photo. Since the catalog doesn't actually contain the image data it doesn't take up nearly as much disk space as the photo library. So I store all of the pics on the server but maintain the Lightroom catalog locally on the Mac (making sure to backup regularly).

So now I just have to worry about backing everything up. The plan is to setup some cron jobs to execute rsync commands from the laptops every day. I only need to backup a few things like the Lightroom catalog and some documents (those that aren't already on the cloud... so not many actually). As for backing up the server, I have an external HDD attached to the server at all times to make a second copy of our photos (again, backed up via a cron'd rsync command every day). I will also keep a copy of my music and videos on a separate portable HDD. Those don't need to be backed up more than once a month or so since my media library doesn't change that quickly. 

So in the end, our digital content is much more secure and accessible, and that gives me a warm, fuzzy feeling inside. 

Monday, December 24, 2012

Teaching a computer to play Connect Four, Part 2

In this post, I will briefly describe the Connect Four game play code that I've written to act as the base for my machine learning experimentation. At the moment, I am working with v1.0.0 of the code.

Feel free to checkout the latest version of the code or follow the progress on my GitHub page.

The basic game play part of the package consists of three main components:

Board: the game board object.
C4Bot: the player object.
main: The function used to play a game.

I will now describe each of these briefly.

Teaching a computer to play Connect Four, Part 1

Lately I've been studying Machine Learning from various sources on the web, including the great lecture series by Andrew Ng at Stanford (videoscourse website). Why? It's really cool and people are doing amazing things with it these days (Exhibit A). On top of that it should provides some useful tools to have in my toolbox as an astrophysicist.

So far I've been surprised to learn that I am already pretty well versed in many of the underlying methods of machine learning (the course has mainly involved a bunch of model fitting using Maximum Likelihood estimation to this point and I happen to know a little something about that), although I expect that once we get to the topics of "unsupervised learning" and neural networks I will start swimming in uncharted waters. Regardless, the course already has me thinking about data in different ways and considering a variety of new and interesting applications like robotics, speech-recognition, machine vision, etc.

As I go along I want to have a simple project that I can use to play around with because it's hard to truly learn something without getting some hands-on experience. Taking inspiration from Arthur Samuel's checkers-playing program (thought to be the first self-learning program), why not write an algorithm that would learn how to play a game? I could work with with checkers of course, but I don't have a checkers program lying around and am not keen on writing one. Connect Four (aka Four-In-A-Row) on the other hand is a rather simple game but should still have enough complexity to give me something to work on. OK then, Connect Four it is.

In just a few hours this past weekend I managed to build a "sandbox" for machine learning in the form of a Python based Connect Four application. On top of defining the game rules, I've also developed a database for storing information about board configurations. This is all a work in progress. I haven't come up with a satisfying solution for teaching the software how to play the game yet, but with this foundation in place I can finally start tinkering around.

In the next post, I'll describe the Connect Four software that I've written including the features designed to help write ML code. Future posts will follow my progress in developing an ML algorithm that will learn how to play the game.

Until then, I've put the project up on GitHub, so feel free to check out the code as I go along.

Sunday, July 24, 2011

Introducing Pyll Popper - A Dr. Mario clone in Python using Pygame

I've always wanted to try writing a simple computer game, but have never found the time to sit down and do it.  Part of the problem is that until recently I have not been very proficient in a suitable programming language.  Not only would I have to spend time learning game programming techniques, but I would also have to brush up on my general programming skills as well. 

Lately, I've been writing a lot of code in Python for work, and as a result I would finally consider the 'lack of general programming skills' hurdle jumped.  But is Python a suitable language?  It's certainly not a good choice of language for a game that requires high performance, e.g. a FPS, but for a 2D side-scroller or puzzle game it should be fine.  To help there is the Pygame library, whose various classes and functions will handle a lot of the dirty work that goes into manipulating graphics objects and handling I/O.

So with my new found Python proficiency, and Pygame to help me out, the time is ripe for making this project happen.  OK, so what game to code?

I've got it! A Dr. Mario clone!  Should be easy enough... simple graphics objects, simple rules, simple everything.  Plus, it's fun as hell, and Dr. Mario clones are relatively rare (at least compared to, say, Tetris clones). 

Fast forward to today.  After only a couple of Sundays worth of work I have written a bare bones, but fully playable, version of the game.  You can see a screen shot above.  Nice graphics, huh?

Now comes the hard part.  What should I call it?  I need to follow the usual convention of putting Py or Python in the name since it was written in Python.  The most obvious choice is Dr. Python, which was my first working title (as you can see in the window title of the screen shot).   Unfortunately there is a text editor that already goes by that name, so I have to try harder.  What about Python, M.D.?  Or Pyll Popper?  Yeah, that's a bit more creative.  Pyll Popper it is. 

In an upcoming series of posts I will describe the development of Pyll Popper, particularly describing how to use Pygame for such a project.  In the meantime, feel free to try the game.  It is cross-platform, or at least it should be (I've only tested it on Linux).  To play you will need to have installed python (obviously), and both the pygame and numpy libraries.  For my code there is no installation necessary.  Just unzip, make the .py file executable, and run it from the command line. 

The controls are simple.  Move a pill left or right using the arrows, and rotate using the 'z' and 'x' keys.  To pause, press 'p' (some diagnostic information will be spit out at you as well).  To quit, simple close the window or hit 'Esc'.  If you find any bugs... no wait.  When you find bugs, be a pal and let me know.

Dev. diary posts to follow...stay tuned.

Download Pyll Popper (right-click and 'Save Link As...')