A better way to do it?

For quite a few years now, I’ve been using Lilypond as my software of choice for any music-notation-related tasks.

As well as being incredibly powerful (and fairly straightforward to get a basic handle on, at least for someone who had  quite a bit of previous experience typesetting mathematics in LaTeX, using a text editor; LaTeX and Lilypond have a lot in common, at least conceptually speaking), it has the attractive feature of being completely free.

The basic idea of Lilypond (which aims to be “a program that creates beautiful sheet music following the best traditions of classical music engraving”) is that you prepare a text file containing a description of the music that you want to typeset, written in a text-based notation complete with various markup commands, and then feed it through a processor that churns out a beatifully formatted page (or many pages, although I’ve usually only used it for fairly short pieces) of music.  The Lilypond website has plenty more detail if you want to know more about how it works.  One of the benefits is that you can easily do things such as transposing an entire piece of music into a different key, often with a single instruction (in fact one of my main uses for Lilypond is where I have a piece of music in one key that I need to transpose into another, either to make it a better pitch for singing or playing or to provide a copy for transposing instruments to use).  As well as producing PDF sheet music, you can get it to output midi files and I think there are converters available to turn Lilypond source into various other formats, although I’ve so far only ever had need for the basic PDF output.

This is somewhat different from most sheet-music editing software I’ve seen, which tends to take a WYSIWYG approach to the task, complete with a snazzy graphical interface. That’s all very well and good but one thing I particularly like about Lilypond (similarly to LaTeX for more general, mathematical or other tech-related typesetting tasks in contrast to a word processor; indeed, there is at least one music extension for LaTeX (or more accurately for TeX, for which LaTex itself is an extension), though I’ve not explored it) is the power  and (paradoxically, once you’ve ascended a shortish, if rather steep, learning curve) the simplicity, you get with the text-based approach, leaving actual realisation details to the processor unless you specifically need to over-ride them (OK, so the learning curve is actually potentially pretty long but it’s not so steep after the initial shock and you don’t need to master that much of the system to be able to do quite a bit of useful stuff).  Therefore, despite once or twice having a quick look at Denemo, a graphical front-end for Lilypond, I’ve always stuck with using my text editor of choice (usually either Vim or Emacs) and running my source files manually through the Lilypond processor.

However, the other day I came across another tool which seems to take a midway approach between the text-editor/CLI approach and the GUI one.  This is Frescobaldi, a “lightweight, yet powerful LilyPond music and text editor with a built-in PDF viewer”.  What you get is essentially a text editor that, while lacking many of the heavyweight features of Vim or Emacs, seems to have plenty of capability for editing Lilypond source code (including much nicer syntax highlighting than I’ve found for Lilypond in either of those editors – this is a very useful feature that has on many occasions helped me to find minor punctuation errors that have caused processing of the entire file to grind to a halt) and the ability to quickly generate a PDF file at the touch of a button; the PDF version is visible in a window to the side of the source file (and the processor log is visible just below it, which is also handy for debugging purposes), so you can see mistakes, edit them and have another run with the processor.  At least for smallish files, this is pretty close to real-time editing of the actual output files and retains the benefits of direct access to the source.  There are some other handy features too, such as autocompletion of function/variable names and a Lilypond help browser on hand (both of which are very useful as there’s quite a lot of stuff to keep track of and it can be difficult to remember the exact name or syntax of a given command).

In theory, Frescobaldi is probably a sufficiently powerful editor to be useful for other tasks than Lilypond editing.  However, it is very much optimised for that task and I’m unlikely to start using it for more general purposes (and I’m certainly not keen to give up the power of Vim for most of my text editing tasks).  The big question is whether the benefits brought by Frescobaldi for the purpose of Lilypond editing outweigh the loss of the Vim power-features that aren’t there.  So far the answer seems to be a resounding “yes”, so I think that Frescobaldi is likely to remain my tool of choice for Lilypond work for some time to come.

Incidentally the programme is named after Girolamo Frescobaldi, an early baroque composer known chiefly for his keyboard work, who was apparently quite a significant influence on later composers (including Bach himself).



Working within one’s limitations

I find spreadsheets to be quite powerful and certainly very useful tools, and I use them quite a bit both at work and at home.

Most of the time I work with either Excel or the LibreOffice equivalent (Calc) but sometimes it’s quite handy to use the online (or, these days I suppose you might say “cloud-based”) Google Drive (formerly Google Docs) spreadsheet.

This has some benefits, mainly the fact that it is accessible from any computer with a working internet connection and gives you access to documents without needing to copy them manually from one place to another and have the appropriate software (other than a web browser!)  installed on all machines, but also has some fairly major limitations compared to more traditional and full-featured spreadsheets.  Possibly not the biggest, but one that I run into very often, is the lack of a “fill series” function (or at least one that I can find).

The ability to automatically fill data across a range of columns or rows is a very handy time- and labour-saving device.  Most often, copying the contents of a cell into adjacent cells below or to the right of a given cell is what’s needed and most spreadsheets not only provide commands for doing these but usually also give keyboard shortcuts (Ctrl-D and Ctrl-R respectively), both of which I use on a regular basis when I’m working with spreadsheets.  (Actually, as I recall, the default key binding for LibreOffice these days asigns Ctrl-R to “align right” but I have mine customised to use it for “fill right” instead, as I tend to make more regular use of that command).

There are various other fill commands, including “fill up” and “fill left”, most of which I rarely ever use, but one that is often quite handy, albeit not as often as “fill down” or “fill right”, is “fill series”. This can be used to automatically generate various sequences of numbers.  The ones I use most often are “linear” (used for an arithmetic progression – I usually just use it with an increment of 1 to generate a set of consecutive numbers, e.g. 1, 2, 3, 4, 5… ) and “date” (which, as the name suggests can auto-generate a sequence of dates).

Unfortunately, Google Drive’s spreadsheet seems to lack a “fill series” command.  It does, however have “fill down” and “fill right” (albeit only accessible via keyboard shortcuts – they don’t show up in the Edit menu, where most spreadsheets (or at least LibreOffice Calc and, as I recall, older versions of Excel) seem to keep a submenu of fill commands), as well as cut and paste commands (including several “paste special” options), so it’s not too difficult to come up with a workaround that, while marginally less streamlined than a proper “fill series” command is still far preferable to manually typing a whole series of figures.

The trick is to enter your initial value in one cell, then set up a formula in the next cell (down or across) to generate the next value in the series, use the available fill commands to copy the formula into the rest of the cells you want filled with the series (it will automatically adjust the cell references, so the value for the third cell will be generated from the value in the second cell – the one just calculated from the initial value – and so forth) and finally select the whole range of cells, cut and paste as values (one of the “paste special” options) to ensure that you don’t later get any weird effects from copying or re-ordering cells.

As an example, if you wanted a simple list of numbers 1 to 10 in the first column of a fresh new spreadsheet, you’d start by putting the value “1” (without quotes) in the first cell (A1), then move down to A2 and enter the formula “=A1 + 1”, which would calculate and insert the value “2” into that cell (while retaining the formula iteself in the background.  Next you’d select the range of cells stretching down from A2 to A10 and hit Ctrl-D to fill down.  It would copy the same formula into each cell, adjusting the references as it went (so A3 would contain the formula “=A2 + 1”, etc.) and you’d end up with the numbers 1 to 10 as desired.  If at this point, however, you decided that you wanted the numbers to run down from 10 to 1 and therefore told the spreadsheet to sort the values in reverse order you’d end up with some strange results because it would move the formulas around and get its knickers in a twist (not wishing to get too technical!).  To get round the problem, you should, before attempting to sort the data, select the complete range of cells, cut them (with Ctrl-X) and then choose “paste special” (either from the Edit menu or the right-click context menu) and select “Paste values only” from the submenu.  After this, if you examine the contents of the cells you’ll find (as you might expect) that the formulas have been replaced by plain old numbers and you can now safely sort or move them to your heart’s content.

Of course, if you only want numbers 1 to 10 it’s not that hard to put them in by hand, but if you want to go up to 100 or 1000 (or several million) it would get increasingly tedious, so it’s handy to be able to automate the process.

I suppose to be fair to Google, it’s (presumably) not setting out to be a fully-featured heavyweight spreadsheet and at least it gives you enough tools to be able to recreate the “fill series” functionality with the exercise of a little ingenuity.  However, it does have a “fill range” command (accessed via “Ctrl-Enter”) which I’ve not seen in other spreadsheets; this acts essentially like a combination of “fill down” and “fill right” by copying whatever’s in the top left cell of a selected rectangular range into all the other cells in the range (updating formula references as appropriate).  While this is quite nice, it’s much more obvious and quick to replicate this functionality using Ctrl-D and Ctrl-R, so I can’t help feeling that it would be more useful if the Google spreadsheet could implement “fill series” functionality and assign that to the “Ctrl-Enter” hotkey instead (on a positive note, that idea has enabled me to find a good keyboard mapping for  “fill series” in LibreOffice, which conveniently didn’t seem to be using “Ctrl-Enter” for anything).

155.891 smoots (or maybe two)

When I started my occasional series of posts about length measurements just over a year ago, I mentioned that there were two reasons why I had chosen to use the Menai Suspension Bridge as the reference object for all the different units (to be measured via the Google Maps DMT wherever possible).  One reason was that I regularly traverse this landmark.  The other, as I said, was a bridge-related connection to one of the units which was to be related in due course.  Now is the time!

The smoot is a unit that originated in October 1958 when a bunch of engineering students at MIT used one of their number (Oliver Smoot, later to be Chairman of the American National Standards Institute (ANSI) and President of the International Organization for Standardization (ISO)) as a measuring stick to measure the length of the Harvard Bridge.  One smoot is equal to Oliver Smoot’s height (at the time of the measurement), which was 5’7″ (i.e. 67″ or 1.7018m). The bridge’s length was measured to be 364.4 smoots plus or minus one ear, with the “plus or minus” intended to express uncertainty of measurement.  That’s about 620m in the rather more boring but somewhat more common metric system.

The Menai Suspension Bridge, according to my measurement on Google Maps, is 155.891 smoots long, so it’s a bit less than half the size of the Harvard Bridge.  Incidentally, the Menai Suspension Bridge looks very similar to the Széchenyi Lánchíd (Széchenyi Chain Bridge) in Budapest:

Széchenyi Chain Bridge, Budapest

The Budapest bridge was actually built about 15 years later by a different engineer (and modelled on a bridge over the Thames).  Wikipedia lists its length as 375m, which Google Calculator tells me is about 220 smoots.

In case you’re wondering about the possibility of two smoots indicated by the title of this post, it’s actually a reference to two Smoots since Oliver has a cousin, George Smoot, a physicist who won the Nobel Prize (for physics, unsurprisingly) in 2006 and has appeared as a guest star on The Big Bang Theory (which is quite appropriate since much of his physics work has been on the big bang).   Arguably, George is more famous than his cousin although I’m not aware that he has any units named after him.  I decided to go ahead and write this post after I discovered (from Wikipedia, where else?!) that today is George Smoot’s birthday.  So, happy birthday George (in case you should ever happen to read my blog, which is admittedly fairly unlikely)!

10444.7 inches (or 31334.1 barleycorns)

If you’ve been following my blog for a while, you may remember that early last year I started a series of posts on the subject of units of length measurement based on the Distance Measurement Tool feature of Google Maps, using the span of the Menai Suspension Bridge as a test object for comparing the different measurements.

The last couple of units I looked at (beard-seconds and Olympic swimming pools) were decidedly esoteric, but both derived essentially from standard metric units (a beard-second is 5nm and a swimming pool is 50m so it’s not surprising that, as I’ve just noticed, an Olympic swimming pool is exactly 10,000,000,000 beard-seconds long).

This time I want to return (mostly) to somewhat more mainstream units and also diverge from the metric path as we consider inches and related measurements. These form the length part of the so-called Imperial system of measurements which, according to Wikipedia, was formally introduced to the UK by the Weights and Measures Act of 1824, although the actual units themselves are somewhat older. Since 1995, all Imperial measurements in use in the UK are defined in terms of metric units and measuring devices used in trade are legally required to display metric measurements. In practice, many people continue to use Imperial measurements for many purposes.

In principle, I’ve always been a firm supporter of the metric system as it makes a lot more logical sense to me. For instance, I find it much easier to remember that there are 1000 millimetres in a metre and 1000 metres in a kilometre than to remember that there are 12 inches in a foot and 5280 feet in a mile (I had to look that last one up on Google!). However, a couple of years ago I read an interesting book entitled About the size of it (by Warwick Cairns, published in 2008 by Pan Books), which advances the thesis that Imperial units are actually based on various measurements relating to the human body and are thus easier for people to visualise.

For instance, a foot (which is about the same as 30cm – apparently it’s actually 304.8mm) is the length of a standard British size 10 boot, which is the average shoe size for an adult male. As it happens, my feet are size 10. This is obviously fairly approximate as individual boots (for a size 10 foot) vary somewhat in length but it means that it’s quite easy to pace out a length of, say, roughly 6 feet and consequently somewhat easier (or so Mr Cairns says, and I’m inclined to agree with him) to visualise a length of 6 feet than one of 1.8m.

An inch (now officially 25.4mm) is, according to Cairns, essentially the thickness of a human thumb. Although different people have hands of different sizes there is, apparently, less variation in the thickness of thumbs than you might think and certainly they are close enough to a standard size to be quite useful for approximating distances.

I would have to do some experimenting to be sure, but I’m fairly certain that I’m more accurate when I try to estimate (suitable) distances in feet or inches than when I try to do it in metric units (despite my best efforts, in the past, to make myself work in metric). For accurate measurements or calculations, metric would still be my first choice in general, but for estimating or visualising distances (on a human scale, at least) I have always found imperial units to be somewhat more natural and now I have a better understanding why that is.

Another Imperial unit that Cairns mentions, which as far as I can tell was not included in the Weights and Measures Act, is the barleycorn. This, as the name suggests, is the length of an average grain of barley and happens to be exactly a third of an inch. Although no longer regularly used as a unit of measurement, the barleycorn is apparently the basis of the British system of measuring shoes. Here’s a condensed explanation (see Cairns’ book for more detail): A child’s size 0 shoe is based on the size of an average child’s foot when they first start needing shoes, which is 4 inches (aka. 1 hand – you can probably guess where that unit came from); thereafter, shoe sizes go up in barleycorns (e.g. a size 1 is 4 inches + 1 barleycorn, i.e. 4.33 inches, size 2 is 4 inches + 2 barleycorns, size 3 is 4 inches + 3 barleycorns, i.e. 5 inches, etc.); a child’s size 12 shoe is 8 inches (or 2 hands) long (i.e. 4 inches + 12 barleycorns (4 inches)). The next size up (8 inches + 1 barleycorn) is considered a child’s size 13 or an adult size 0 and thereafter the adult sizes continue by adding barleycorns. This means that an adult size 10 is 8 inches + 11 barleycorns or 11.66 inches (11 and two thirds, to be precise), slightly shy of a foot (i.e. 12 inches); the discrepancy is explained by the fact that shoe sizes measure the size of the insole, which is slightly smaller (by about a barleycorn, in fact) than the external size of your boot. In other words, if I want to measure distances in feet as accurately as possible, I should put on a fairly sturdy pair of boots.

The span of the Menai Suspension Bridge, as measured with the Google DMT for the purposes of this blog series, is 10444.7 inches, which is the same as 31334.1 barleycorns or 870.393 feet.

5.30591e+10 beard-seconds

It’s about time for the next part in my series about units of length measurement and this time I’ve decided to go for one of my favourites: the beard-second.

I had not heard of this particular unit until I came across it in the Google Maps DMT, but it is sufficiently established to appear in a Wikipedia article (albeit not a page unto itself).  This doesn’t go into great detail (or, indeed, any detail) about its history but defines it to be the length an average beard grows in one second.  There are at least a couple of more precise definitions in terms of established units – 1 beard-second is either 100 angstrom (which is the same as 10 nanometres) or 5 nanometres.  Apparently Google uses the latter definition for its calculations.

This unit is supposedly inspired by the light-year but useful for very small distances instead of very large ones.

The span of the Menai Suspension Bridge, as measured with the Google DMT for the purposes of this blog series, is  5.30591×1010 beard-seconds (5.30591e+10 in the computer-friendly version of scientific notation, in case your browser doesn’t support the HTML5 <sup> tag).  If you’re not familiar with the notation, that means roughly 5 followed by ten zeroes (that is, about 5o billion in the American sense of the word, which seems to be becoming accepted as the international standard version).  In other words, if I sat at one end of the bridge, I’d have to wait a very long time for my beard to grow long enough to reach the other end!

265.296 Metres

To kick off my series about length measures and the Google Maps DMT, I decided to start with one of the more common (and, arguably, useful) units on offer: the metre (m).

The metre (or meter to our American cousins) is one of the seven basic units of the SI system of measurements favoured by the world scientific community, which is the modern form of the metric system.

There have been several definitions of the metre since it was first proposed by English philosopher John Wilkins in 1668.  Apparently Wilkins proposed setting 1m to be the length of a pendulum with a half-period (IIRC that’s the time taken to swing from one extreme to the other – a full period being the time to complete a swing there and back again) of 1 second.  During the eighteenth century this original definition vied with another that defined the metre as one ten-millionth of the length of the Earth’s meridian along a quadrant (that is the distance from the equator to the North Pole) at sea level.

When the French Academy of Sciences defined their metric system in 1791 (around the time of the French Revolution), they opted for the latter definition, since the length of the pendulum required to give a 1s swing is affected by the slight variations in strength of the earth’s gravitational field at different location while the length of the meridian is constant (assuming, of course, you can measure it with sufficient accuracy in the first place).  As far as I can tell, this was the first official definition of the meter.

For nearly a century, from 1875, the length of the metre was defined to be the length of a specific metal bar measured under specified conditions (the gory details, along with a lot more information about historical definitions of the metre, can be found in the Wikipedia article linked above).  This was replaced in 1960 by a definition based on the wavelength of a particular line in the emission spectrum of Krypton-86 in a vacuum (presumably a constant for all Kr-86 atoms and therefore a, theoretically, more easily transferable measurement than the length of a single metal bar kept in Paris).

In 1983 the current definition of the meter was agreed, namely the length of the path travelled by light in vacuum during a time interval of 1  ⁄   299,792,458 of a second.  This is, of course, dependent on the definition of a second (which I won’t go into now, as this is supposed to be an article about length measurements) and the constancy of the speed of light in a vacuum (one of the cornerstones of Einstein’s theories of Relativity).

As an SI unit, the metre comes supplied with a whole bucketload of standard prefixes to denote decimal multiples of the basic unit.  This means that you can write distances from the very small (e.g. the diameter of a helium atom is about 0.0000000001m or 0.1nm (nanometres)) to the very large (e.g. the diameter of the sun is about 1,400,000,000m or 1.4GM (gigametres)) without excessive leading or trailing zeroes.  For everyday purposes, kilometres (1,000m) and millimetres (0.001m) are especially useful.

The span of the Menai Suspension Bridge (shore to shore, as measured using the Google DMT) is 265.296m.  My regular commute to work (using approximate start and end points, measured using the Google Maps navigational tools and my usual route) is 4.2km.

A Bridge How Far?

A few years ago, while playing around with Google Maps, I stumbled across an exciting experimental feature which is still available (evidently still experimental and definitely still quite exciting) – the Distance Measurement Tool.  To enable this you have to go to Google Maps Labs (a button just above the copyright information on the left-hand side of the Google Maps screen, at least how it appears on my browser today) and select the tool.  It then puts a small icon showing a picture of a ruler at the bottom left of the map screen.  Clicking on this activates the tool.

The DMT enables you to measure the straight-line distance between points on the map, allowing you to string several points together to approximate any path.  You have to put the points in manually and there doesn’t seem to be any way of editing any but the first and last points, which slightly limits its usefulness, but it is still quite fun to play with and does enable you to measure distances between things that are not on the roads (which you could measure using the navigation tools).

In its default mode, the tool gives you a choice between metric and English (aka Imperial, i.e. miles, feet and inches etc.) measurements.  However, next to the unit selector there is a link which, as I recall, used to be labelled Geek Mode and is now called I’m feeling geeky.  If you click on that, it replaces the brace of radio buttons in the unit selector with a drop down list containing an impressively long collection of units ranging from the commonplace (inches, yards or miles), through the well-known but not used every day (except perhaps by astronomers or other specialists – things like light years or Didot points) to the decidedly obscure (beard-seconds or Jewish second temple sacred cubits).

Over the next few weeks, I thought it would be quite fun to write a series of posts exploring some of the units that are available in the Google Maps DMT.  In each one, I will focus on a single unit (or perhaps a series of related units) and see what information I can find out about it (or them).  To give a useful point of comparison I will, each time, state the length of the span of the Menai Suspension Bridge (shore to shore as it appears on the Google map) in the chosen unit of the day.

There are two reasons for choosing this specific landmark.  One is that I cycle (or walk) across this bridge on my way to and from work every day, and it was the most convenient section of my daily commute (where I hatched, or at least developed, the idea for this series) to clearly define and  measure on the map.  The other is its special relevance (by virtue of being a bridge, rather than this specific bridge) for one of the units to appear at some point in the series – you’ll just have to keep reading to find out which.

There is a version of the DMT on the Google Maps for Android app, but that one doesn’t appear to have a geek mode.  Indeed, I haven’t yet figured out if it’s even possible to get it to work in metric. 😦

NB in case you were wondering, the title of today’s post is inspired by the film A Bridge Too Far, which Wikipedia describes as an “epic war film”, although I don’t think I’ve ever actually seen it.