Broadcasting audio from ubuntu via HTTP (aka stream audio out to sonos on ubuntu)

This post is for all the folks who, like me, have tried (and failed out of frustration) 20 different times to stream local audio from an ubuntu machine to some other thing on the network via HTTP.  Today my goal was to get the Sonos in the office to stream from my machine — aka whatever was playing on my machine should come out of sonos.  I finally sat down and got it done with icecast and darkice today.  The basics for this article come from here.

OK, so without further ado, the basics:

sudo apt-get install icecast2 darkice
sudo nano /etc/default/icecast2

Change ENABLE=false to ENABLE=true.  The reason this is false by default is that icecast is actually a community radio streaming thing that is intended for multiple people to use.  Therefore it has some passwords in the default configuration file (/etc/icecast2/icecast.xml) that they want you to change before turning the thing on at first.  Since this is just us using icecast and we’re all on the local network, I chose to go with simplicity and defaults here.

Now, create a new config file someplace you like (perhaps ~/.darkice.cfg) which contains the following:

[general]
duration = 0 # duration of encoding, in seconds. 0 means forever
bufferSecs = 1 # size of internal slip buffer, in seconds
reconnect = yes # reconnect to the server(s) if disconnected
[input]
device = pulse
sampleRate = 44100 # sample rate in Hz. try 11025, 22050 or 44100
bitsPerSample = 16 # bits per sample. try 16
channel = 2 # channels. 1 = mono, 2 = stereo
[icecast2-0]
bitrateMode = vbr # variable bit rate (cbr for constant)
quality = 1.0 # 1.0 is best quality
format = mp3
bitrate = 256 # bitrate
server = localhost # or IP
port = 8000 # port for IceCast2 
accesspassword = hackme # source password to the IceCast2 
servermountPoint = mystream.mp3 # mount point on the IceCast2 server or any name
name = mystream

Now bootup icecast

sudo /etc/init.d/icecast2 start

Now start darkice (the thing which actually reads pulse and sends it to icecast. Icecast then provides an HTTP URI you can use to give out to others)

darkice -c ~/.darkice.cfg

Now head on over to your consuming device and give it the url http://MY_IP:8000/mystream.mp3 (replacing MY_IP with your machines ip, aka 192.168.1.105).  In sonos you go to the “Radio” tab, hit “Add” then type in that url and a fancy-shamancy name.  Click the radio you created and shazam, good to go!

Note: there is a 3-4 second delay using icecast.  I’m not sure how much of that is icecast vs. sonos, but for just audio streaming its great.  That is, until I decide I really want to watch a youtube video with the audio coming out of sonos and I spend a few hours putting jack in the system…

Note: this was all done on Ubuntu 11.10 using standard repo versions of icecast, darkice, pulseaudio etc.

The problem isn’t piracy, it’s your product and publisher.

<provocative opening statement> A common saying you hear now a days in arguments about piracy is “I think people should get paid for their creative work”.    Yeah, well I don’t. </end troll-bait>

I think you should get paid for how well the free market likes you and decides to pay you.  It is your job to figure out how to be a businessmen and make money.

But I’m just an author and don’t understand business!

Then hire the person who is supposed to understand these things — a publisher!  It’s their responsibility, it is why you hire them, to make money in the marketplace with your creative work.  Historically they’ve been quite good at this.  Now that the market has been made more competitive (piracy is, after all, just a competitor to the work a publisher traditionally does) guess who are the ones complaining loudest?  That’s right, the folks who are supposed to be competing in the marketplace — the publishers.  Rather than compete against a competitor they are complaining for regulation to help keep their business afloat.

To paraphrase Gabe Newell’s Piracy is a service problem:  If you are being pirated, it means there’s something wrong with the service to begin with.  Somebody finds it more enjoyable or values more the experience of pirating your work than to get it via the channels you are offering.  Therefore you need to find a way to make your product more valuable than the pirated one.  Let me repeat that: It is your responsibility, as the person who wants to make money, to find a way to make your users happy enough that they want to pay you.

I don’t know of any other example of a business where I can launch my business, make money, have a competitor come in and then beg the government to make them go away.

Anybody who is complaining that piracy hurts their business is simply avoiding the problem that they aren’t providing a product that the marketplace likes enough to make money. Sure, piracy is incredible efficient so it makes your problem harder but that’s not the marketplace’s fault. Technology’s job is to make life more efficient and better for end users, I like to call it progress.

So rather than legislate to defend the old business models of a sector which was supposed to be market savvy to begin with, why don’t we let the market be efficient and have people innovate and let the businesses or technology that can provide the most end-user value win?

Discuss.

What are you doing, Boxee Box?

<rant>Its been almost a year since I started using my Boxee Box. Here are the new features I have noticed

  • Spotify Support
  • Grooveshark Support
  • Netflix Support

Things they made WORSE

  • Pandora — used to have an awesome visualizer and play for hours, now has a terrible visualizer and the darn thing freezes up after an hour or so due to (presumably) some kind of memory leak
  • The YouTube app inexplicably stopped working last week.

Things that are STILL broken

  • UPnP Support — Trying to find other UPnP devices simply does not work.
  • Random crashes — At random times it’ll reboot the UI or even the whole machine.
  • SDCard reading doesn’t work.  Insert an SD card into the boxee box, it says “SD Card inserted” but never shows up for me to browse as the documentation says it should.

Things they for there-must-be-some-reason but is INEXCUSABLE to have not done yet

  • Amazon Video on Demand!  Rokus had this for eons!
  • Better social integrations and sharing.  Why can’t I share immediately what im watching or listening to with somebody else?  I want to connect with other couch potatos using boxee and interact with them!  Maybe a chat app?  Video camera integration?
  • UI Speed and Polish — I shouldn’t be waiting 10 seconds everytime I start an app!  It also takes an INCREDIBLE number of button presses and clicks to get anything done.  From bootup to pandora playing I have to push at minimum 6 buttons.  That’s simply a user experience nightmare.
Overall though I don’t hate the Boxee Box.  It’s Pretty Good.  That said, they’ve had a year to go from Pretty Good to Excellent and have completely let me down in that respect.  </rant>

Track Racing on the East Coast

I finally made it to a track this weekend., and had an amazing time!  There are a bunch of things I learned in general about track racing through this experience, as far as logistics of how to actually do it.

General Info

  • Tracks rent out in time intervals, at the rate of thousands of dollars per hour.
  • “Groups” (aka BMW Club, Porsche Club, SSCA, EMRA) rent out the track for a few hours or a whole weekend.
  • Every group runs the day differently, and some are much more serious and competitive than others.
  • I went with EMRA, which is not super competitive and whose rules are a bit more relaxed.  They allow stock cars, stock seatbelts to race.  You need to tape up any glass (sunroofs, headlights), and have a proper racing helmet (snell rated), but that’s about it!
  • SSCA is much stricter about cars — everybody needs a rollcage etc.  Don’t expect to bring a stock M3 here generally.
  • No matter what you’ll pay several hundred $ for a track day.
  • HPDE — High performance Driver Education Event.
  • HPDE Insurance is a great idea — usually you can get this either at the track or buy it online ahead of time.  I paid about $115 for insurance for the day.
  • There are several tracks within 3-4 hours of NYC — to find a track day you can either pick a car club and look at their schedule, or pick a track and look at the track’s schedule.
    • Lime Rock Park
    • Watkin’s Glen
    • Pocinos Raceway
    • New Jersey Motorstate Park (NJMSP)
    • Summit Point Circuit
  • Unlike Autocross you usually get a LOT of time on the track at an event like this.  Anywhere from 1.5 -> 3 hours!
Bring to the track:
  • Your own Snell 2005 or 2010 rated FULL FACE helmet!  (Expect to pay $300+ for a good one)
  • Blue masking tape — the stuff that doesn’t leave residue
  • Zip Ties (to tie on a timing transponder)
  • A Razor / Sizzor (to cut the zip ties at the end of the day)
  • An EMPTY car — nothing in the trunk, etc.
  • Fresh break pads!  (You eat these guys up at the track!)

HID Kits, Xenon Bulbs and Halogen headlamps — The Story

So I’ve done a handful of research lately on halogen and Xenon lights.  Below is a basic summary of my findings when investigating (and eventually buying) replacements for my stock Halogen headlamps in my 2006 Mercedes C55 AMG.

Disclaimer: I pulled this together from bits and pieces here and there.  I do not claim to be an authority on lighting, but I think most of this is reasonably accurate.

Info about Xenons

  • HID = High-Intensity Discharge (for purposes of this doc, HID == Xenons)
  • HID Kit == Xenon Bulb (mine are size ‘D2S’ for low beam, H7 for high beam) + Ballast + Wiring.
  • If you already have headlamps with HIDs or are replacing the bulbs in an existing HID with a different color / temperature you do NOT need a whole new kit, just new bulbs.
  • Higher temperature == more color and less light
  • Stock color / temp is 4300Kelvin.  5000Kelvin is a brighter white, 6000K starts to look a bit blue and 8000K is getting fairly blue.  I went with 8000K :)
  • HID kits are generally a bit flaky, but are very cheap
  • Stock halogens are 35W, and to avoid complications its not a bad idea to stick with 35W if your upgrading to Xenon.  If the ECU notices a different power draw from the headlights it might throw errors.
  • Mercedes should be coded from Xenons (via STAR / ODBII computer systems) to avoid error codes.
Info about upgrading from Halogens to Xenons
  • If you have halogen lamps you can take out the halogens, buy an HID kit and be good to go, total cost of upgrade on the order of a couple hundred bucks (2-300) TOPS.
  • HOWEVER — You could also replace the whole headlamp assembly, which has several advantages:
    • Stock halogen headlamps do not use projector lenses.  Projector lenses look significantly better with Xenons than the traditional ones.
    • OEM Xenon headlamp kits come with their own ballast etc. which is generally more reliable than a HID Kit.
    • Mercedes OEM Xenon lamps have leveling motors etc, which is a nice to have but a bit gimmicky.
    •  I bought a used OEM Xenon assembly from a friend on mbworld.org — going to install them later this week.  Hoping for the best!

One way to do Django on AppEngine

Disclaimer: I work for Google.  Any and all opinions expressed or interpreted below are mine own and not that of my employer.

I’ve built dozens webapps in the past 10 years (thats right, i was writing web apps at 13) using all sorts of tools.  It started with raw HTML and spaghetti code perl.  Then it moved onto spaghetti code PHP.  Then it was PHP in a framework.  Then it was asp .NET and finally for the past 3 years or so I’ve used exclusively Django.

So naturally when a friend of mine approached me with an idea for a project using Google’s new prediction API I immediately thought to use Django.

But what’s the fun of doing a project the same way you’ve been doing it for 3 years?  Django + Apache + EC2 is boring.  I figured, I work for Google, perhaps I should be using a Google hosted solution.  It was time to use AppEngine.

Full stop.  Think for a minute.  Django, a highly relational tool built on databases like Mysql and Postgresql, seems fundamentally at odds with the philosophy of AppEngine — non relational, highly distributed.  Fudge!

OK, breathe.  There has to be a way to make this work.  From some research I discovered:

  • You *CAN* use Django + MySQL in AppEngine.  The most common technique I uncovered involves hosting MySQL outside of AppEngine and establishing a secure connection from AppEngine to the remote DB.  This seemed a bit excessive and wasteful — the whole point of this exercise is to use AppEngine!
  • Or, you could use Django-Nonrel

Django-Nonrel is a version of Django that modifies the Django query generator to work ontop of a non-relational database.  Beware though, this has some inherent drawbacks.  Complex joins and inheritance, for obvious reasons, no longer work.  Before continuing any further read through the entire django-nonrel page and all the limitations and make sure you can live with them.  I was able to, you probably (with a bit of work) can too.

That doesn’t solve all our problems though.  We still don’t have a connection between the Django application and the AppEngine datastore.  Thats where DjangoAppEngine comes in.  DAE provides the following, incredibly awesome, capabilities:

  • A connection between the django-nonrel query system and the AppEngine datastore.
  • Automagically sets up AppEngine logging for your Django App.
  • Automagically sets up the Django URL handling system within the AppEngine app — all you need to do is setup your urls.py!
  • Most importantly, provides new hooks within manage.py to allow you Django Shell access to your production AppEngine datastore!  While not critical once your app is deployed, for development and debugging this capability is invaluable!

So, brave adventurer, be off with you!  Explore the wonderful world of building applications with the ever popular python ORM Django ontop of the ever scalable AppEngine platform!   My experience was slow and painful, and involved a lot of head scratching and googling, but in the end all was working.   Read the documentation carefully and bliss shall be yours too!

Link to my app coming soon…

    Trying out the Nexus S

    I got a Nexus S today, and here are my initial thoughts, when comparing it to my Nokia N900.

    • No LED indicator light.  This is driving me nuts.  It’s rather jarring to not be able to look at my device and know whether or not it needs my attention.
    • It’s FAST!  Opening applications is instantaneous, scrolling is smooth, no slow downs whatsoever after the first day.
    • Android multitasking is rather annoying coming from Maemo.  I’m not in love with how it works, its kind’ve like “every app is always open” and to switch back to an application you just reopen it.  Thats nice, but it doesn’t lead to any nice workflows with great multitasking.
    • There is a lot more application support in the android ecosystem, which is nice coming from Maemo.
    • The lack of a physical keyboard is going to take some getting used to.  I’m not particularly thrilled about the on screen keyboard quiet yet.
    • Installing applications is quick and painless.  Much less frustrating than on Maemo.
    • I can actually use the email client!  It has good search features!  It doesn’t take 20 minutes to load!  Oh happy day!
    • There are… ads….?  In my applications?  This is weird.  I don’t like it.
    • SUPER integration with all Google services, which is sort’ve a big deal for me now a days.

    The Google services integration is actually the deal breaker for me, and is probably what will keep me on Android going forward.

    Update: So I’ve been using the phone for a couple of days now.   Here are some more thoughts:

    • Battery life is ‘meh’.  I felt like i had a lot more control over the battery usage on the N900 — changing from 2G/3G, disconnecting from the network etc. where all much simpler operations on the N900.
    • Using the phone, just for day to day stuff, is a pleasure.  By far the most ‘fun’ to use where it ‘just works’ a very large percentage of the time.
    • Voice commands are simply *phenominal*.  ”Send text to daniel Hi dan, want to meet for drinks?” actually works about 90% of the time!  Or  ”Goto engadget.com” or “navigate to pizza” all work rather well.  It’s what voice recognition should be like.
    • The navigation app is slow and almost unusable.  Nuts.

    Introducing the Personal *nix Cluster Manager

    I was at home this holiday, with the family enjoying the Thanksgiving Holiday.  I was messing around with stuff on my netbook and realized I wanted files from my desktop back in my apartment.   Only problem was — I have no idea what my IP is back there (I moved recently).  I’m also too lazy to setup my own or pay for a proper dyndns solution.  Why is it that in 2010 I still have this kind’ve problem?  Shouldn’t there be some application I can run on all my client pcs which keep them meshed together?

    A bit of digging, couldn’t find anything.  So I wrote one.  Introducing the “Personal Cluster Manager for *nix/ssh systems”.

    First, an important assumption: This software is meant to be used by you and you only.  It probably won’t scale to 1000 machines and I’m perfectly fine with that.  I have a handful (10?) machines I care about keeping track of for my stuff and I imagine most of the people who are interested in this are on the same order of magnitude.

    Ok, enough nonsense, what is it?  There are three pieces:

    1. A client daemon that maintains a reverse ssh tunnel with a master, always connected and accessible node.  Theres a good bit of configuration to get this right, so theres also a little helper script to ask the user questions to get the right config values for the client.
    2. A “master” script.  This provides  an interface to a sqlite database which keeps track of what hosts we’ve seen, what ports their tunnels are on etc.  You can ask the master “show me all hosts you know about” or “which tunnels are active and usable right now?”.
    3. A curses based UI.  The UI pulls all its data from the master program, and doesn’t do any direct querying.  (This is intentional, as I intend to build other kinds of UIs and want all the data stuff to be handled underneath the UI).  The UI shows you what tunnels are active to which hosts, and with one keypress can give you a shell on any of the remote machines (using the reverse tunnel setup by the client).

    All 3 of the above are working in version 0.1 in github.

    A very poor quality screencast with typos and minor bugs left and right, but you’ll get the idea: (nevermind the ‘scrollz’ stuff, thats something particular about my local bashrc and nothing to do with PCM)

    AMD Joins Meego with Nokia and… Intel?

    Source Press Release

    Wow.  My first thought was “What, AMD and Intel working together?”  My second thought was “Awesome!  More people behind Meego!”   My third thought was “Wait, AMD is supporting a software platform?  That’s new.”

    One at a time:

    First — Intel and AMD both understand that they are in the fight for their lives right now, but necessarily just with each other, but with ARM.  ARM via Android and iPhone is taking over more and more market share in the global processor market.  All of our smartphones are running ARM, most of your tablets are running ARM and ARM is moving more and more into the netbook space.  A quick Google for “ARM vs X86″ turns up not technical comparisons of the two ISAs but instead recent article after recent article of market analysis between the different chips.  It therefore makes sense for both of them to get into the game and promote some cross-platform software.

    Second — I honestly believe right now that smartphone OS’s are a two horse race, iPhone vs. Android.  RIM and WP7 will fight it out for a small bit of enterprise market, but the lions share is the two goliaths.  Meego could very well be a solid third contender, which I think is awesome for many reasons.

    • More competition means consumers win.
    • Meego is also my personal favorite.  Debian in your pocket?  Sweet.  Meego promotes free and open source linux-desktop technologies whicih benefit not just the Meego platform but Linux desktops everywhere.  That’s right — every dollar that Intel, Nokia and now AMD sink into Meego goes into a technology that, more often than not, will be integrated into the next version of your Ubuntu or Fedora desktop.  Examples?  Telepathy, dBus, Tracker, gstreamer, webkit,  gtk, qt, clutter, kernel power management, low power drivers, apt, rpm and the list goes on.

    Thirdly, and what I think is by far the most interesting, is the possibility that this is the begining of a new era for AMD.  AMD for the longest time was heads down on designing and fabricating chips.  About 18 months ago AMD spun off the fabricating part of that equation into a company named Global Foundaries.  Since then AMD has been chip and system design through and through.  AMD’s chief competitor though, Intel, has for the longest time been a big hardware and software shop.  This strategy has worked rather well for Intel — promoting software which promotes their Intel chips.  Things like Moblin, the Intel C compiler etc. all contribute here.  AMD could really take advantage of this idea and run with it, running with what I am going to call the “Google Trick”.   There is probably a much better term for this, but what I mean is to support products and services which might not be direct revenue drivers in order to support complimentary products which do drive revenue.  Google I think is king at this — products like Picasa, Wave, Google Voice, Goog 411, Google Sketchup, Google Earth, etc. etc rarely make a dime, yet they all contribute to “Googliness” and eventually drive Google search, which is key.

    Thoughts?

    Full Disclosure:  I own AMD stock.

    A Must Watch: Barack Obama’s Post-Election Press Conference

    I do recommend downloading the mp4 and watching at 2-3x speed though… a bit slow otherwise.

    http://www.whitehouse.gov/blog/2010/11/03/president-obama-s-press-conference-lets-find-those-areas-where-we-can-agree

    Some great questions and responses from Barack:

    • What I feel is accurately describing WHY america is so frustrated with the current political situation
      • “In such a hurry to get things don’t we didn’t get a chance to reform HOW we get things done”
    • Working on economy, job creation
    • Describing how to reasonably go forward with respect to dissenting opinions on healthcare
    • “Talk specifics” — which previsions do we like and don’t like and how can we compromise to make the most progress and do the best for our country (as opposed to meaningless ‘lets just repeal this’ type conversation).