Sunday, February 28, 2010

Lilypond - music notation hard core

GarageBand for MacOSX comes with some great free music lessons.

I've been working my way through the piano ones, and they're excellent for keeping up the focus and motivation by giving some quick results, and in the "Play" section rewarding you with an accompaniment for your efforts that makes even an average performance sound pretty good.

Trouble is, when you have a minute or two with the keyboard and just want to practice some of what you've learned going back to GarageBand and firing up the lesson, scrolling to the part you're having trouble with is quite a pain.
It would be really handy to have some way to print out the score - but there isn't.

Well there is a tool that makes it pretty easy to code up musical scores, especially ones that have lots of repititive sections like the GarageBand lessons.

Its called Lilypond, and although it requires some command-line fu, to get it to do your bidding the results are nothing short of spectacular.

The first step is to go to the Lilypond site and download the version for your computer.

When you first run Lilypond it will show a sample file with a short scale. The section with "Welcome to Lilypond" is bracketed with %{ and }, so its treated as a comment - the rest of the sample file is lilypond music notation!

Choose select all, and delete the contents of the sample file, and replace it with your own notation.

Get started quickly by picking one of their templates that is close to the result you want, and modifying it rather than starting with a blank slate.

The notation may look a bit daunting at first, but its actually pretty simple and you can learn just enough to achieve your goals by following the excellent documentation.

I laid out my notation with the treble staff first, and then the bass - all with one measure to a line. That allowed me to quickly find the measure I had made a mistake on (since lilypond conveniently numbers your measures).

Once you have your text file prepared, you run the "Typeset file" command from the "Compile" menu and the PDF of your music appears.

Here's a screenshot of the final result.

To start working really effectively with Lilypond, you should understand that at its heart its a simple command line tool, designed for one job - taking Lilypond files, called something like "", processing them, and producing musical score as a result.

Here's how to run Lilypond from the command line, assuming its installed in MacOSX's /Applications folder:
/Applications/ -o "~/Documents" "~/"
The ~/Documents is the folder where the resulting files will be dropped.

Given that Lilypond is really a command line application the GUI program that you get on MacOSX or Windows is kind of tacked on and really isn't needed - in fact the editor that comes with Lilypond is really meant to be a "get you past first base" kind of thing.

I personally use the VIM editor, which is hard core - not for everyone. If you're a fan of vim however, you can find a set of indentation and colouration files inside the application:

Copy those into your .vim directory to get nicely indented and syntax highlighted editing inside vim.

To work with lilypond from the command line, on MacOSX download a handy script, and run it from the terminal. The script has the above lilypond invocation inside, and will wait for you to pass the path of your file to it, and then present you with the result. You then get the option to either run lilypond again on your file (presumably after you've made some edits) or to quit.

Good luck with your next great score!

Saturday, February 6, 2010

Hot, Flat and Upgefscked

I hope the campaign is successful not just in shaming the coalition into action, but also in waking up our elected representatives; currently making a hash of their only marginally better policy on climate change.

The opposition keep name-calling, hoping that their slinging of the dread word "tax" will stick to Rudd's cap-and-trade policy.

The irony is that a tax would be the best policy of the lot - David Victor, Stanford University Professor and expert on international coal markets:

I think we have vastly oversold the role of the market in the solution to this problem...

As Dr Victor grudgingly admits, ETS schemes are failing and only a tax would be a strong and clear signal - fixed and away from the vagaries of the market, so that Australian clean technology entrepreneurs, as well as all other green innovations and measures are actually economically viable.

Why would you catch a clean green bus, when your car is cheap to run on petrol? Why would you pay much more for an electric vehicle, when your gas guzzler is so cheap to buy and register by comparison?

This is 2010 - the year of the electric car, but we won't see any of them in numbers Australia because our governments are completely failing to create policies to make it attractive to manufacturers to ship them here. In the UK tax on new cars is figured based on their emissions ratings and thus EV's are very attractive there - zero emissions vehicles finally competing on a level playing field. In the USA tax credits are available for zero emissions vehicles - for example resulting in a $7500 saving on the Chevy Volt.

Why are electric vehicle entrepreneurs in Australia struggling to get off the ground?

Because here we just dig stuff out of the ground and ship it over seas. That's what we do, that's our plan for the future.

The Smart State? The lucky country? Nope, we're the Idiocracy. If it wasn't bad enough that we have Senator Fielding, Communications Minister Stephen Conroy and Attorney-General Michael Atkinson. Now we have Abbot and his ludicrous non-policy.

The problem for Australia with regards to climate change is that we've completely failed to realize the urgency, and the Abbott's of this nation are just lowering the average climate intelligence quotient right across Australia.

The heatwave conditions in Feb 2009 which filled the morgue in Victoria and spread wildfires were the pre-saging of more to come, according to the Australian Bureau of Meterology, thanks to climate change.

But more heatwaves when they come will not be our biggest problem here in Australia.

I've just read (on pg 80 of) Thomas L Friedman's "Hot, Flat & Crowded" (2009 edition) that the Sigma Xi group, commissioned by the UN to report on climate change, said in their February 2007 document "Confronting Climate Change" that the relatively small increase of 0.8 degrees C since 1750 has been "accompanied by significant increases in the incidence of floods, droughts, heat waves and wildfires".

But more fires and droughts when they come will not be our biggest problem here in Australia either.

Our bigger problem is that when the effects of climate change hit the countries most vulnerable to its effects, when their crops fail and disease spreads and generally things are looking like the four horsemen of the apocalypse have moved in for good: where do you think those refugees are going to go?

Here is where they'll go: the lucky country. While we battle bushfires, and raging ignorance, and compete to see how far we can stick our heads in the sand, desperate refugees will be arriving here in force. At the same time, our armed forces will be called on for international relief efforts, much as they were for the tsunami disaster in Banda Aceh in 2004.

While we turn up our air-conditioners, and argue that climate change is bogus because of some emails from East Anglia, the evidence of climate change will be arriving on our doorstep in ever-increasing numbers.

Oh, and Tony, good luck reanimating some the policies of our old dark lords with a return to "turn back the boats" policies - these people will have no country to go back to.

Apart from refugees, the other problem dwarfing fires, drought and heat that climate change will bring for Australia is that if we keep being as backward as we are regarding clean technologies is that soon no-one will want the stuff we're digging out of the ground.

China is investing massively in clean technologies, and indeed some of our top talent in solar technologies have gone there - others to the USA - due to the clear state commitment to controlling climate change with high-tech solutions, especially compared to the dismal picture here.

When these large Chinese plants come on line in the next 5 to 10 years their own local reserves of coal will be more than adequate to meet the needs of their dwindling coal plants.

By then it will be too late for Australia to turn around and beg those scientists to come back and start trying to foster a clean tech industry - we'll be sitting on a pile of worthless black dirt that no-one wants, and lagging so far behind the technology race that we don't have a hope of catching up.

Swamped with refugees and becoming a backward third-world country. That's not what I want for my Australia.

Come on K Rudd - show Abbot what a real forward thinking climate policy looks like, and make us the lucky country once again.