Definite Lack of Genius

Today I spent some time working on playlists under iTunes.  It didn’t actually take too long; only a few albums (records? directories? whatever it is in these newfangled times) in my iTunes library were suitable for the occasion (a wedding reception) so I didn’t have to decide what to keep and what to leave out. Well, until I got to the naughty soul songs. But more on that some other day!

I did start trying out to have the typical “band show” progression for the playlist that I think most radio stations use as their algorithm for song choices in a day part.  I know on stage bands like to start out with a high-energy well known song, and then another high-energy song, but then the third cut is kind of off-topic: a way to change to the middle of the show. If you have enough of a repertoire then you pick an old song that is medium tempo, or you play a cover that fits that criterion. The middle of the show needs a bit of a lull, so you try out new material there. Then around the sixth or seventh song you play a big hit again but switch immediately back to new stuff (hey, maybe it will stick). The crucial bit is the 10th, 11th, and 12th songs; those are the ones that people are thinking about leaving on, so you play great songs with lots of energy. And save a big number for the encore. Radio stations do roughly the same thing scaled to a two or three hour span divided up into chunks rotating around commercial breaks.

So the algorithm is big, big, lull, big, lull, big, big ,big. But I was planning out six hours of music (two is the minimum for a dinner, and six to be safe in case the party keeps on keepin’ on). I just couldn’t try to figure out a good pattern for 12-14 songs an hour.  Maybe I should add commercial breaks?

So I tried out Apple’s Genius Mixes or Playlists, but it was too hard to get the lists just right because I think the genres for some of the songs in my library were a little off. It’s no good when Marvin Gaye suddenly is followed by a Slayer song. I didn’t know they were country.

I think it is interesting nowadays when I see companies like Zynga or Blizzard using psychological manipulation techniques that the music business have been using for years. The principles of gamification are the same as the ones when a DJ teases your favorite song right before the commercial break. String along the addict so that they will remain exposed to the product the maximum time. The longer you are exposed to the product, the more likelihood you will spend money. This is the only way a free service can make money, and radio has pretty much always been free (until Sirius and XM appeared). Radio had to learn all the lessons of time spent listening decades ago, but game designers are just now implementing those lessons in games for time spent playing. I wonder why the music business isn’t applying the same devilish cleverness they used in the past eight decades to their on-line businesses? They would rather just sue.

Whitespace, Shmitespace

I finally have my Sirius radio installed! I have an XM already installed here, and it is aimed perfectly; I get tons of satellite signal.  However, aiming the Sirius was a little problematic. The instructions say the satellite is in the northern midwest, so if you aim at North Dakota from wherever you are, your antenna has tons of aspect with the satellite transmitter. For whatever reason that method is not working. I wonder if since Sirius and XM merged things are working a bit differently?  I would think that I would know about any new satellites, but I can’t explain why my current aiming gets any signal at all.  My guess is that all of the houses around are causing problems, but I get a good view with the XM. Radio engineering is complicated.

Most of today was spent learning how Java handles XML.  It’s like every other XML parser out there (it is basically just Xerces, I think), and at this point it is old hat.  But I still need to write my little playground tests to see just how things work. Inevitably, there is a wrinkle!

For some reason the Java (I am using Java SE 1.7) XML Text class does not correctly report when a node is only whitespace.  I don’t understand the purists who insist that including all of the tabs, newlines, returns, and spaces should be there for all cases.  They are pretty much useless if you are just trying to grab data.  I understand needing them if you want to replicate a document or something, but every parser should be able to discard those nodes during parsing so that it reduces the amount of checking for these useless pieces when you are actually doing something with the XML.

I may be doing something wrong, but from looking at the docs I think everything is correct. In fact, for the DocumentBuilderFactory I set setIgnoringElementContentWhitespace to true and everything still had the various whitespace thingies.  From looking around the web it seems that this is a regression in Java SE 1.6, but I figured it would be fixed in 1.7? Guess not.

So I added a method to my parser class (as many people said had to be done):

* Return whether a text node is whitespace only or not
* @param tn The text node to check
* @return true if the node is whitespace only, false if it has content other than whitespace
public boolean IsNodeWhitespaceOnly(Text tn)
    // when it starts working again, return isElementContentWhitespace
    // now, have to iterate through the content

    String value=tn.getTextContent();

    for(int i=0;i<value.length();++i)
            case '\n':
            case '\r':
            case '\t':
            case ' ':

                // non-whitespace found
                return false;

    // only whitespace found

    return true;

This works fine for testing Text nodes, but it is a bummer to have to incur this overhead after it could be easily set when initially parsing the data.  I hate to stay focused on this much more, but I have to rule out my Java ignorance. I need to make myself believe that Oracle is lazy and didn’t fix the bug in 1.7.  Maybe I can make a tape repeating that while I sleep.

Anyway, with the basics of XML figured out, next is writing the parser that stores the maze XML data in Maze class data structures.  Things are heating up!

Shelves ain’t Programming

I spent half of today finishing the prep for my development machine, which was mostly downloading and installing Eclipse and the Android SDK.  My previously-owned MacBook will follow later, since I am going to develop everything in straight Java first and then port the Java basecode to Android and iOS.

I considered going with one of the cross-platform toolkits, but most of these cost money, and it seems that they don’t deliver on all of their promises.  I have also looked at some of the bytecode cross-compilers like XMLVM and it just feels like too much trouble.  Add in that I believe I would not only learn more doing the ports, and I gave up on the whole single code-base thing.  This has certainly been my experience trying to develop cross platform; you end up having multiple teams tweaking the code to work on the different configurations.  Well, that was with C++…Java can be a different story.

The use of Java for my development projects is a major driver for me too.  It really is the closest thing to cross platform, at least from a browser standpoint (the aforementioned different story).  But I don’t want people bringing up a browser on iPhone to use my software.  I am holding out hope that iOS will support some form of Java directly instead of having to go with native development.  There are rumors…

The other half of the day was spent getting my Ubuntu server and my Shoutcast server out of my office.  The Shoutcast server is an old friend running Windows XP in a Shuttle breadbox form factor (much love).  I use it to distribute tunes around the house (mostly streaming with my phone using XiiaLive, an awesome Shoutcast app on Android).

Having both of these boxes in my office added to my normal development machine makes for a lot of heat.  So moving things to the IT room (well, it’s our junk room!) has made for a big temperature difference.  Although I may have to move them back if it gets too cold this winter!

The biggest part of the effort was putting together and installing the Ikea shelf and mounting the new 16-port TrendNet switch that is the new backbone of my network (nearly all Gigabit now, except I can’t bear to replace my trusty router). The shelf ended up going pretty fast…well as fast as an OCD engineer can go. The end result uses three supports and is super-stable, so I am quite happy with how it went.  It is pretty much perfect for putting the server PCs on.

The switch is a slightly different story.  I bought it assuming it had some sort of way to wall mount it, but this wasn’t the case.  Apparently this version is meant to be rack mounted, and so it had the little 1-inch square of screw holes for attaching a 1U bracket.  Well, this doesn’t work when you need to mount to an exposed stud.  I thought about buying something like a rackmount kit made by TrendNet, but I didn’t really want to wait.  And $15 (AntOnline isn’t Prime!) is a little more than I want to spend for a dumb bracket.

So I went out to Home Depot and got four cheap angle brackets.  I have tons of screws left over from PC builds, and I found a set of four that fit the little 1U holes.  A little bit of creative procedure (level, mark, drill, screw) and I got a pretty good result.  The switch is stuck to the wall like a barnacle and it looks alright.  But it’s in an unfinished room…the rough look is trendy for a junk space!

It ain't pretty, but it is born-again hard and ready to push bits.
It ain't pretty, but it is born-again hard and ready to push bits.

I think that’s the last of the infrastructure stuff, except for getting my Sirius radio installed (I need that coax adapter!).  Next step is writing the tool to make the maze layouts for Project Alpha. Real code ho!

Rough first day

Today is the first day of my new job as owner and operator of Zairon Engineering.  Things have been rough.  Or at least not going the way I want them to.

I have been fighting a cold, and last night it decided to kick in full force.  So I have been dealing with being sick all day, in addition to all of the tasks I had to do today.  I even postponed going to the city government to get the information for business licensing, just because I didn’t feel like it.

When I woke up, my priority was to get my Sirius radio connected here at the home office. I thought I had the SMB female-to-F male adapter that I need to connect the Sirius antenna to the coaxial cable running from the exterior of the house but I only have the other kind (and three of those to boot).  So I have to track down one of those, and they are hard to find so I am stuck waiting until I get it delivered from somewhere.

After tabling that, I started back with my Ubuntu server, which I am going to be using for Subversion, wiki, and general file storage.  I needed to add a pair of 3TB disks in RAID1 for the general file storage (I have a pair of 2TB drives in RAID1 for Subversion/wiki already).  Plus, the on-board Ethernet for the motherboard doesn’t support Wake-on-LAN, so I was going to add a 1Gbit card I had at my old job to try to get that going.

I managed to zap my original Ubuntu server installation by accidentally pairing my compact flash (where Ubuntu was installed) with one of the 3TB drives and blasting the files when the RAID controller created the logical volume.  I was stupid to do it, but I have some reasons:  originally the CF was on SATA5 and my DVD drive was on SATA6.  I hooked the 3TB drives up to SATA1 and SATA2, but then Ubuntu didn’t like that.  I switched everything around, and then recreated the logical volume.  Well, the first time with the 3TB drives on SATA1 and SATA2, those drives were first; now the selections were CF and then the 3TB drives.  So I blindly chose the first two, and didn’t pay attention.  Well, now I will.

So I am reinstalling everything, including making a certificate for Apache and all that IT admin stuff.  I was hoping to get some quick prototyping on my maze engine started today, but I am guessing that I flushed the chances of that.

But I am going to be optimistic!  I am just getting all of the stupid out before things get going.