Wednesday, June 30, 2010

Stream Your Music with iSub and Subsonic

iSub is pretty amazing. This app for your iPod Touch or iPhone plays music stored on your computer wherever you go, provided you can get online using a WiFi connection or (with an iPhone) AT&T's 3G network. So anywhere you can get online, you can play your music with iSub ... and you do not have to "sync" your music to your mobile device in order to do so.

iSub works with Subsonic, a music-streaming background server application that runs on a Mac, a Windows PC, or any computer running Linux or Unix. I run Subsonic on the iMac which houses my iTunes music library, so what follows in this post is basically Mac-oriented.

The combination of iSub and Subsonic does approximately what the Simplify Music software suite does, as covered in this earlier Simplify Media 2 post. The Simplify Music 2 client app for the iPhone and iPod Touch is roughly equivalent to iSub in functionality, while the Mac-based version of the Simplify Media 2 desktop server software (there are different versions for different computer platforms) is roughly equivalent to Subsonic. Unfortunately, Simplify Media's developers have pulled the plug on the suite of software, so the Simplify Music iPhone/iPod app is no longer available from the App Store. That's why the advent of iSub is so timely now.



Getting Started with Subsonic


Getting Subsonic up and running on your Mac so that iSub will have access to your music collection isn't all that easy, sad to say. Downloading the Subsonic installer package, installing the software, and running Subsonic for the first time are simple enough, of course. (The Subsonic installation instructions for various computer platforms are available here.) Once Subsonic is downloaded and installed in your Mac's Applications folder, you fire it up in the ordinary way, by double clicking on its Finder icon. The Subsonic app itself is minimal-to-the-max, though, because once it is up and running, you're going to interact with it not as an application but through your web browser (!).

For the record, here is what the Subsonic application's window looks like, when it's not hidden entirely (as normally it will be):



In other words, the Subsonic application is really just a background "media server." It sits there on your Mac and waits until some "client" — on the same Mac, on another computer, or on some other device anywhere else in the wired or wireless world — connects to it.

To connect as a client to the Subsonic server on the same Mac computer that the server is running on, you need to open in your web browser the web page whose URL is http://localhost:4040. The web page is one that the Subsonic application itself makes available. The "4040" designation is crucial to its availability, but taking advantage of it requires some preliminary setup.

(On other OS's the URL that you need to point your browser to is often exactly the same: http://localhost:4040. However, Windows is different; you need to point your browser to just http://localhost, without the "4040" designation. I can't comment on how easy or hard it is to get Subsonic up and running on Windows using that URL. What follows is, as I already said, basically Mac-oriented.)

The "4040" designation is a "port number": an arbitrary numeric designation that the Subsonic server on the Mac (and on several other OS's, but not on Windows) uses to identify itself to, and to communicate with, its clients. Its clients may include:

  • a web browser running on the same computer the Subsonic server is running on (which I'll call the "server host")
  • a web browser on any other computer
  • an iPhone running iSub
  • etc.

So you have to make sure that the server host (the computer running the Subsonic media server application) makes port number 4040 visible to the outside world. The ordinary way to do that is to configure "port forwarding," a.k.a. "port mapping," on the router connected to the server host — my router is an Apple AirPort Extreme base station — to forward all network traffic received from or sent to a Subsonic client, such as iSub on my iPhone, from the router to the server computer, using (you guessed it) port number 4040.

Port numbers are like "attn.: Ms. Smith" beneath the address on an envelope. They make sure incoming messages get routed to the right computer: Ms. Smith's or Mr. Jones's. The port number, in addition, makes sure it gets delivered to the right application or media server running on that computer.

However, Ms. Smith might have, in effect, been replaced by Mr. Jones. Port mapping on the router takes care of this. The router "knows" to replace "attn.: Ms. Smith" on incoming messages with "attn.: Mr. Jones."

So the router has to know in advance what "attn. designees," i.e., port numbers, to expect to see, and whether to treat any of the designees as an alias for one of the other designees.

I ran into difficulty getting port mapping on my Apple AirPort Extreme base station set up properly to forward port 4040's traffic to my iMac computer that is running the Subsonic server. I ran out of patience with that process, which involved using the somewhat arcane Apple AirPort Utility, and sought another, easier solution. I found one in ...



Lighthouse


Lighthouse is a "dynamic port forwarding utility." (It runs on Macs only —if you are using Windows, hopefully http://localhost "just works" without any special attention to port forwarding.)

A dynamic port forwarding utility is software that does network port mappings/forwardings without you having to touch the configuration of your router.

If you purchase Lighthouse ($12.99), download and install it, and start it up on your Mac for the first time, you'll be presented with an informational screen that clues you in to a crucial fact: Lighthouse is not really an application per se! Rather, when you run it, it turns itself into an icon in your Mac menu bar that, when clicked, gives you a drop down menu like this one:



After dealing with the niceties of the "Registration..." menu item — you do need to register Lighthouse, receive a registration code in e-mail, and enter the code into the "Registration..." dialog, so that Lighthouse will keep working after its 14-day trial period has expired — you'll need to select "Edit Port Mapping Profiles...". That produces a window like this one:




The above is my own "Edit Port Mapping Profiles..." window after I'd created the "Subsonic" profile that is highlighted in the top part of the window. I created that profile by clicking the + button beneath the profiles list in the top part of the window (which comes pre-loaded with a number of other profiles that you can simply ignore).

Clicking that + button yielded a new profile called "Empty Profile." I next double clicked the "Empty Profile" name and replaced it by typing the name "Subsonic." I then double clicked the Description area next to "Subsonic" and entered "A profile to make Subsonic work" ... though, be it noted, both the name of the profile and the description can be whatever you wish to make them.

Then, with the "Subsonic" profile still highlighted in the top part of the "Edit Port Mapping Profiles..." window, I clicked on the + button beneath the bottom part. That yielded a new set of Profile Details that I then edited manually:

  • I double clicked on the default Public Port number, which was "1"," and changed it to "4040"
  • I did the same for the default Private Port number, making it "4040" as well, basically saying that port 4040 is not an alias for a different port number
  • I made sure the Type designation was "TCP" (which was, in fact, the default designation)

Then I clicked on the "Enable this profile" check box to ... well, to enable the profile, so that it could be "started." Next, I clicked the Change button, bringing up a standard Mac OS X File Open dialog that allowed me to select the Subsonic application residing in my Applications folder. Doing that step set things up so my newly created "Subsonic" profile would automatically get "started" — i.e., activated — every time my Subsonic application is launched. (In Account Preferences on my Mac, I have manually set up the Subsonic application as a Login Item for my main user account, so Subsonic now gets launched automatically whenever that account gets logged into. That happens by default each time I restart my Mac. Accordingly, unless I intentionally use the Lighthouse "Stop Profile" menu item to stop the Subsonic profile, that profile always stays on.)

Since Subsonic was already running at the time I set up my "Subsonic" port mapping profile in Lighthouse's "Edit Port Mapping Profiles..." window, I needed to click on the Start Profile button in that window to manually begin using port 4040 in the intended way.

Then I simply clicked the Save & Close button in Lighthouse's "Edit Port Mapping Profiles..." window. It was time for ...



Using Subsonic


With all that done, I could finally access http://localhost:4040 in my Safari web browser. That brought up:



What was wanted was for me to enter "admin" as both username and password. But instead of doing that, I clicked on the blue "here" hotlink. That brought me to http://localhost:4040/index.view:



(Entering "admin" as both username and password in the Subsonic login page takes you to that  same "Getting started" page.)

Once you are on the "Getting started" page, you can, by clicking "Change administrator password," link to another web page that allows you to respecify the administrator password — an excellent idea. You just click the "Change password" check box on that page, enter the desired new password, confirm it, and click Save.

You'll then be taken back to the Subsonic login page so you can re-login as username "admin" with the new password that you have just chosen. That, in turn, takes you back to the Subsonic "Getting started" page — which is also, by the way, the default Subsonic "Home" page — so that you can now click "Set up music folders" and point Subsonic at your music folders.

You'll then see this Subsonic Music Folders settings page:



The first time you use this page, all you'll see are two empty "Add music folder" boxes (in the screenshot above, I've already set up a music folder). In the leftmost box (the "Name box") you'll just enter an arbitrary name; I used "iTunes Music." Into the rightmost box (the "Folder box") you'll enter a fully qualified path to a folder containing (either in itself or in its subfolders) all your iTunes music files.

Tip: to enter a fully qualified path name into the box the easy way, just drag an icon of the folder from a Finder window to the Folder box in the Subsonic Music Folders settings page.

The associated "Enabled" box should, by default, already have a check mark in it, but if it doesn't, you can just click on it to give it the check mark. Then click Save, and Subsonic will immediately recognize all the music files in that folder and all its subfolders!

Here's my full Subsonic Music Folders page showing, along its left side, my entire music collection, organized alphabetically by artist name (click the image to enlarge the image):



(For simplicity's sake, I'm ignoring the fact that Subsonic can also use music files in formats that iTunes cannot. If you have such files on your computer, chances are they are in a different folder than the one your iTunes music files reside in — and you'll need to repeat the Music Folders designation process you are now doing in order to make Subsonic aware of that second folder. In fact, you can repeat this "Add music folder" set of steps as many times as necessary to point Subsonic to all the music folders on your computer.)

From this point on, you'll see on the left side of every Subsonic web page (as long as you're logged in) an alphabetical list of all the artists represented in your music collection. If you like, you can now start experimenting: click on, say, the letter "M" to bring up a list of artists whose names begin with that letter.

If I do that, I find that one of my "M" artists is "The Mamas and the Papas," and if I click on it, I see:



If I click on the particular entry for the album eponymously called "The Mamas and the Papas," I get:



Now if I click the little triangular Play icon to the left of "Trip, Stumble & Fall," the song begins to play, and I see (click to enlarge):



Notice that the song has automatically been added to the "Player 1" playlist shown at the bottom of the window, so I can if I like continue adding songs to the same playlist and then save the playlist for future use ... however, the use Subsonic playlists is beyond the scope of this particular blog post, sorry.)

I do need to point out, though, that neither Subsonic nor iSub can utilize the playlists you have in iTunes.

Now it's time to talk about how to set up Subsonic to play your music, not just from the browser interface on the Mac running the Subsonic server, but from apps like iSub that interact with the server remotely over the Internet.

To do that, you'll need to go back to the Subsonic "Getting Started" page. You can do this by clicking on the "Home" icon at the top of every Subsonic browser page (or, click http://localhost:4040/index.view).



Configuring Subsonic's Network Settings


On the "Getting Started" page, click on "Configure network settings" to bring up (click to enlarge):



The key thing here is the "Access your server over the Internet using an easy-to-remember address" check box. You'll need to check it, fill in the empty http:// box with a (hopefully) unique nodename — I chose a version of my name: "epstewart" — and click Save. (If you choose a nodename that someone else is already using, presumably you'll be asked to choose a different nodename.)

What setting up this nodename buys you is that it "hotwires the Internet" so that the URL http://nodename.subsonic.org — modified to contain the actual nodename that you've specified, of course — works wherever you are, on whatever computer or other Subsonic client you happen to be on. (Subsonic calls http://nodename.subsonic.org your "personal server address," by the way)

Keep in mind that that you will need to contribute money to Subsonic to be able to keep your nodename alive permanently. Go to the Subsonic website and, somewhere on just about any page, find the PayPal button. Click on it. You will be taken to a page in which you can log into your PayPal account to make the donation. The default amount of the donation is 20 euros, which (depending on the current exchange rate) comes to about $25.

Or, if you don't have a PayPal account, you can alternatively click on a link, found on the first PayPal page that you come to, that will allow you to donate with just about any credit card.

Once you donate, you'll receive e-mail with a license key in it. Copy and paste the license key into the page brought up by clicking on "Donate" link in the top right corner of the Subsonic web browser interface. Once you do that, the "Donate" link will disappear, and you're good to go.

Note also that, on the "Configure network settings" page, it is quite all right for the status shown beneath "Automatically configure your router to allow incoming connections to Subsonic" to show "no router found." Because you are running Lighthouse on your Mac, you do not depend on a router to do port forwarding. The status of Subsonic's "automatically configure" function is irrelevant.

What's more, you do not need to put a check mark in the "Automatically configure your router to allow incoming connections to Subsonic," if you don't want to.



Adding Users to Subsonic


Next, you'll probably want to create at least one Subsonic user identity other than "admin." Inasmuch as you are currently logged in as "admin," to do that you'll just click on the Settings button at the top of any Subsonic page, and then, in the page which comes up, you will click on "Users" in the row of options immediately below the "Settings" page title.

I did this, chose "New user" in the "Select user" menu, filled in some further information, and got (click to enlarge):



Notice that I put check marks in all the boxes, so this particular user (me) will be able to take advantage of all of Subsonic's capabilities (including being a Subsonic administrator). Also:

  • I left "max bitrate" set at "No limit." Alternatively, I could have limited myself to any one of several streaming bitrates from 32 Kbps to 320 Kbps.
  • My chosen username was "epstewart," which happens to match the Internet nodename I used earlier in this procedure, though strictly speaking it doesn't have to.
  • I entered a password of my choosing and confirmed it.

I then clicked the Save button to register user "epstewart" with the Subsonic server running on my Mac. I could now log out of Subsonic as "admin" and log back in as "epstewart," using this login page (click to enlarge):



Notice that I checked the "Remember me" box so that Subsonic would remember my "epstewart" username, along with my associated password.

When I next clicked the "Log in" button, Safari too asked me if I wanted it to remember my "epstewart" login details; I responded in the affirmative. (To get Safari to be able to fill in the username and password boxes automatically, I needed to check the "User names and passwords" option in its Autofill Preferences panel.) Now, whenever I bring up the Subsonic login page in my Safari browser, "epstewart" is filled in automatically in the username field, and my password is filled in in the corresponding password field as well.

Logging in to Subsonic as "epstewart" for the first time brought me back to the familiar Subsonic "Getting started" page. After that initial login, though, logging out and logging in again return me to whatever I was doing when I logged out. Subsonic remembers what each user is doing at the time of logging out.

It's actually a bit more complicated than that; for one thing, each user is given access by Subsonic to, potentially, any of several music "players" that have been created to hold playlists. Subsonic calls each player by a unique name, "Player n," where "n" is always a unique number across all registered users. If "epstewart" logs out on Computer A while "Player 2" is active, but has previously logged out on Computer B while "Player 3" is active, logging back in on Computer B will return him to "Player 3," the most recently active player that is associated with his username on that computer, Computer B. But if "epstewart" logs back in on Computer A, "Player 2" will be the active player.

If you get tired of always seeing the "Getting started" page, then when it is visible, click Don't show this again. Now, rather then the "Getting started" page, whenever you log in to Subsonic or click on the "Home" icon, you'll arrive at a "Welcome to Subsonic!" page instead. This page, by default, presents you with a continuously changing selection of randomly chosen albums from your music collection. You can click on any album you see, and its list of songs will magically appear, ready for you to play any one of them. Subsonic has lots of niceties like that, but they're best reserved for a different blog post than this one.

Anyway, if you have done all of the above, you are now able to run the Subsonic client interface on any computer, not just the one running the Subsonic server. Just open any browser and type in the URL http://nodename.subsonic.org, replacing nodename with the one you set up earlier.

My nodename is "epstewart," so my URL is http://epstewart.subsonic.org. Your URL will be different, because your nodename is different.

So, to repeat: if I point a browser on any computer to the URL with my epstewart nodename in it, I'll magically see the familiar Subsonic login page! Once I log in as "epstewart," I am then able to find and play all of my music.

Warning: the following brief aside is a bit technical, so if you don't follow it, you can just move on.

The http://epstewart.subsonic.org URL gets automagically changed to http://10.0.1.2:4040/login.view... in the browser URL field. 10.0.1.2 happens to be the current local IP address of my Mac that is running the Subsonic server application. 4040 is the designated Subsonic port number, as discussed earlier. And login.view designates the web page from which you can log yourself, using your username and password, into the Subsonic server.


End of technical aside.

Now it's time to learn about ...


The iSub App

To obtain the iSub app, you need to buy it for $4.99 at the iTunes Store (you can do so by using the App Store app on your iPhone/iPod, or you can just click here an get it online via iTunes).

The following applies to version 2.1.2 of iSub, which is due for an update any day now. It may or may not remain accurate when the new update arrives.

Once iSub is installed on your iPhone or iPod, to begin using it, just tap the iSub icon:



You'll briefly see this screen ...



... and then a list of sample music (or, actually, a list of the artists responsible for this collection of sample music) that you can listen to if you don't yet have your own Subsonic server up and running. You have yours up and running, so you'll just tap the gear icon at the upper left of the Artists screen to bring up the Servers screen. Here is my Servers screen after I had already gotten iSub set up the way I want it ...



... but you'll initially see just an empty list of servers. You'll need to tap the Edit button at upper right, which turns the Servers screen into an editing screen, and then tap the + button at upper left ...



... to bring up ...



... into which you'll enter your Subsonic website name, with its unique nodename, as well as your username and password:



The you'll tap the Save button to take you back to the Servers editing screen, which will now show:



Tap Done at upper right, then tap the entry for the newly defined server, to bring up:



Tap "Make Default Server" to get:



Tap "Ok" and then press the Home button on the iPhone or iPod to take you out of iSub. Then tap the iSub icon again to restart iSub. This time, the Subsonic server you are running on your Mac will provide iSub with a list of the artists in your own music colleciton. Here's mine:



(If you tap the gear icon again to bring up the Servers screen, you'll now see a star next to your server, indicating that it is the default iSub server.)

Let's say I want to find a song by the Mamas and the Papas. I tap "M" in the alphabetical column at the right side of the screen, and see:



I tap "The Mamas and the Pa..." and, voilĂ , I get a list of my (two) Mamas and Papas albums:



I tap "The Mamas and the..." to get the songs from the group's eponymously named album, and get:



Alas, this album is, in my library, a partial album with only two tracks in it. (Someday, I'll have to get the whole album!) Let's say I want to hear "Trip, Stumble & Fall." I tap its entry in the iSub list and, as the music begins to play, I see:



While the music is playing, I can tap the album cover art to see an Info screen:



Tapping again takes me back to the cover art, but if I like, I can swipe the Info screen to the left to see a list of all the songs (all two of them, in this case) on the album:



You can tap any of the songs to play that song. Or, swiping the screen to the left once more brings up a screen showing the status of iSub's buffer:



Here, the buffer is full, since 383/384 indicates a very nearly full buffer. If the top number is noticeably lower that 383, the buffer isn't full. If it's quite a bit lower, its green color will turn amber. If it's close to empty, red.

iSub (version 2.1.2, at least) is implemented in such a way that as each song ends, the buffer drains to 0/384. Then as the next song begins, the top number builds from 0 to 383 (or higher) again. I'm telling you this because you'll find that iSub 2.1.2's inability to pre-buffer the next song can in certain situations cause long pauses between songs.

Anyway, once the song(s) you want to play are finished, you can tap the left-pointing arrow button at upper left of the screen multiple times to bring you back to your Artists list.

From there, you can tap the Albums icon along the bottom of the screen to see:



From the Albums screen you can navigate to whatever music you want to hear and play it, exactly as in playing music from the Artists screen.

In theory, you can tap the Songs icon at screen bottom to bring up a list of all your songs. However, that doesn't work for me. Ben Baron, the developer of iSub, has told me that there is some sort of mismatch between iSub version 2.1.2 and Subsonic that causes iSub to have "a hard time loading large collections such as yours [I have over 14,000 songs in my collection] because of the method used to grab the songs from Subsonic. I've completely rewritten the song loading algorithm for the upcoming version 2.2 so that it no longer has this problem ... ".

iSub also has the ability to utilize playlists you create in Subsonic in a web browser ... but Subsonic's playlists capability is beyond the scope of this already-way-too-long post.

I wish you satisfying iSubbing ...