Occasionally, I go looking around on the internet for the chords for music I want to play. Tonight, I went looking for the chords for Warning Sign by Coldplay. Unfortunately, the pages I managed to find fell into one of two categories:
Now, there's nothing wrong with a chord like G♯. You can play it. It sounds good. The thing is, when you string a bunch of chords together, there's actually a reason that they sound good together. In this case, the reason is that the chords all fall in the same key. The chords in Warning Sign aren't really G♯, D♯ and A♯, they're A♭, E♭ and B♭ because the song is written in B♭.
The theoretical reasons for this go back to the theory of scales and keys in Western music. It's important to understand this if you're going to write chords for other people to play. So I've decided to spend my evening educating some of you amateur chord transcribers.
Let's start with the theory of scales. Scientifically, an octave is two notes where the higher one has twice the frequency of the lower. In music, an octave is shortest distance between two notes with the same name. C and C' are the C notes one octave apart. An octave is split up "evenly" into 12 notes, called semitones. (Actually it's a logarithmic scale, but from a music perspective they're considered equal.) Two semitones are a tone. The major scale is a "nice sounding" scale, and it's defined as a precise series of tone or semitone steps in sequence. The sequence which all major scales obey is:
tone, tone, semitone, tone, tone, tone, semitone
If you play the major scale on an instrument, you'll see that the gaps between the notes obey the series of steps above (tone, tone, semitone, etc). You'll also hear that it sounds quite good. Lots of music uses the major scale.
To give names to the notes, the C major scale is defined as the scale which has no sharps or flats in its scale, C D E F G A B C'.1 Where the gap between two notes in this scale is a tone, the note on the semitone in between is named as either sharp of the note below or flat of the note above (so the note between C and D is either C♯ or D♭). Where two notes in C major are separated by a semitone, like E and F, no extra note is remains to be named.
| C | D | E | F | G | A | B | C' | D' | E' | F' | G' | A' | B' | C'' | |||||||||||||||||||||
To define a major scale on any other note, it's a simple matter of starting at that note and following the steps. For example, a G major scale is G A B C' D' E' F♯' G'. Now you might wonder why the G scale is said to have an F♯ rather than a G♭. The reason is that the scale is considered to include all the notes, G A B C' D' E' F' G', you just adjust particular notes up or down to match the major scale pattern. What this means is if you want to make an F scale that matches the major scale pattern and includes all the notes between F and F', you'll quickly discover you need a B♭, not an A♯.
If you spend a bit of time writing our various scales and figuring out their notes based on this pattern, you'll notice that keys have either sharps or flats, but not both. In the situation of keys with many sharps or flats, you do in fact write notes like B♯, even though you'll play them as C.
To arrange keys into a logical structure, musicians group them by whether they have sharps or flats, and order them by the number of sharps or flats they have:
| # Accidentals | Sharps | Flats |
|---|---|---|
| 0 | C | |
| 1 | G | F |
| 2 | D | B♭ |
| 3 | A | E♭ |
| 4 | E | A♭ |
| 5 | B | D♭ |
| 6 | F♯ | G♭ |
You can continue to extrapolate this table out, adding more and more accidentals. The sharp column goes up by fifths, the flat column falls by fifths.
Now that you know all this theory, you can understand my gripe with the chords transcribed as G♯, D♯ and A♯. To find a key in which these three chords feature and also fits with the song, you really do need to extrapolate the table above until you get to A♯ major. It has a ridiculous 8 sharps.2 Try writing out the song's chords in musical notation in this key and you'll find it quite hard work.By contrast, if you consider the song to be written in B♭, it makes the musician's job much easier. B♭ major appears right near the top of the table, arguably making it one of the five easiest major keys to play music in. The chords become logical, the notation becomes simpler, and improvising around the chords also becomes practical.
So if you're going to write out some chords for your favourite pop song, please make sure you know the music theory. Work out what key the music is in so you can use the correct chords.
1Curious readers might wonder why the designers of Western music chose the note C rather than, say, A as a basis for the logical naming of notes. The truth is that the note naming is in fact based on the scale of A, but it's based on the natural minor scale of A. Launching into a discussion of the various minor scales and other modes was a diversion I thought best avoided. (back)
2Yes, I know, 8 sharps isn't ridiculous. Yes, you've played a piece on the piano with 10 sharps or flats in your sleep, and by comparison A♯ is trivial! But c'mon, we're talking about Coldplay here, not some impressionist music written by a brilliant composer like Chopin or Liszt. (back)
Chris and I had a short discussion last week about what the default content type for Confluence attachments should be. On occasion, we have data uploaded by a user with no content type information provided. Chris had already implemented the fix to serve this data as application/octet-stream. I was worried that the default should be text/plain, based on something I could remember reading but couldn't put my finger on. I decided to have a look further into the situation tonight.
My first stop was the MIME Wikipedia article, because I knew the HTTP Content-Type header was derived from the same header used in email messages. It led me to the MIME RFC which states the default content type for MIME messages is text/plain:
Default RFC 822 messages without a MIME Content-Type header are taken by this protocol to be plain text in the US-ASCII character set, which can be explicitly specified as:
Content-type: text/plain; charset=us-ascii
This default is assumed if no Content-Type header field is specified.
Of course, that doesn't mean the default for HTTP would be the same. HTTP is usually used for transmission of HTML data — it is the Hyper Text Transfer Protocol after all — so a different default might make sense. The HTTP spec actually does have quite a different standard. Strangely, it appears as almost a footnote, completely separate to the discussion of the Content-Type header itself:
Any HTTP/1.1 message containing an entity-body SHOULD include a Content-Type header field defining the media type of that body. If and only if the media type is not given by a Content-Type field, the recipient MAY attempt to guess the media type via inspection of its content and/or the name extension(s) of the URI used to identify the resource. If the media type remains unknown, the recipient SHOULD treat it as type "application/octet-stream".
Since we should provide a content type and the media type is also unknown to us, it turns out that application/octet-stream is exactly the right thing for Confluence to do. We definitely don't want to delve into the perils of Content-Type sniffing.
The unsubscribe mechanisms of websites always frustrate me. Understandably, they're not usually the focus of the business that is about making new customers. However, they're still important so as not to alienate customers that might want to just not receive email notifications about your site.
It's my efforts to unsubscribe from the Newegg technology store that are currently frustrating me. However, first I need to explain how I got subscribed in the first place to notifications from a store that doesn't even ship to Australia.
About 18 months ago, I read a somewhat interesting article on AnandTech about how the Newegg warehouse system works and finally got to the end where they offered a prize of a new AMD system to the readers.
Before signing up for the competition (whose website has now disappeared), I spent some time looking through the terms and conditions to find out whether I had to be a US citizen to be eligible. No information there. I look through their website, the About page, the contact page, terms of shipping and so on, and there seemed to be no apparent restrictions in where they shipped to.
I completed the entry form, which requested my email address, name and so on, which I submitted. At the final step of the submission, it blocked me from completing it because my IP indicated I was in Australia, and the competition wasn't open to anyone outside the US because they don't ship there.
However, the fact that I didn't enter the competition apparently didn't stop them adding my email address to their mailing list, since I started receiving Christmas offers from them last week.
Fair enough, I thought, I'll just unsubscribe using the link at the bottom of the notification email. I was directed to their unsubscribe form, entered my email address, and clicked ‘Unsubscribe’. The page timed out.
So I just deleted the email, and forgot about it for a while. This week, they were back, offering me post-Christmas sales. It was time to really unsubscribe. Fortunately in this instance, hitting the unsubscribe button worked successfully, and I received a confirmation email (emphasis added):
Your request to unsubscribe from the Newegg.com Newsletter has been received.
Please allow 10 business day for your subscription preferences to update completely. If you receive a Newegg.com Newsletter after the 10 business day please forward the email to the following address with a brief description of the problem.
We hope you will return in the future as a subscriber. If there is anything we can do to improve our Newsletters, please let us know.
Not only is their English awful, but ten business days?! How can it possibly take them ten business days to remove my email from their database? This from a company that claims to have a remarkably efficient stock management system, according to the original article I read. Looks like similar attention to the finer details of their website would pay off.
Last night I had a tricky decision to make. I left my apartment to catch the lift upstairs to lend some clothes to a friend. While waiting for the lift to come, I looked out the window noticed something strange going on down on the street.
Three young people, a girl and two boys, ran along the street and stopped next to a car. "There's heaps of cars here", the girl said. One of the boys looked out while the other two crouched down next to the car and used tools to break in to the car. It was a similar situation to what I saw when I came across two older men breaking into my car a few months ago.
I heard one of them say, "There's someone up there". He was probably talking about me, I thought, so I backed away from the window and pulled out my mobile to call the police.
Then I stopped. What would it achieve to call the police? The kids would definitely be gone by the time the police got there. I wouldn't be able to identify them in any confident way because our street isn't lit. All that would happen is that I'd have a conversation with a policeman about a crime I didn't really see very well, unable to identify the perpetrators.
So I put my phone away and took the lift upstairs to drop off the clothes. The crew outside continued their work as I entered the lift. By the time I came back down, only a few minutes later, the group had disappeared.
I'm still not sure whether I did the right thing. Am I too cynical of the police response? Some might argue that deciding whether a crime is worth pursuing is someone else's decision, not mine.
Awk is one of those command-line tools that is sadly underused. To help with that, I'm going to blog about any useful application of awk I come across.
Today's short one-liner uses the output of svn status to revert any changes and remove any extraneous files from a working copy. You could easily modify it to do more complex things with the files in a certain status. Here's the script:
svn status | awk '$1 ~ /\?/ { system("rm -r " $2) } $1 ~ /M/ { system("svn revert " $2) }'
The first thing to know about awk is that it automatically splits the input on whitespace, and stores the resulting tokens in $1, $2, $3, etc. The output of Subversion I was trying to process looked like this, which is prime awkage material:
$ svn status ? pom.xml.releaseBackup ? release.properties ? confluence-rpc-plugin/pom.xml.releaseBackup M confluence-rpc-plugin/pom.xml ? conf-webapp/pom.xml.releaseBackup M conf-webapp/pom.xml ? confluence/pom.xml.releaseBackup ? confluence/plugins ? confluence/temp ? confluence/null ? confluence/attachments ? confluence/bundled-plugins M confluence/pom.xml ? conf-acceptance-test/pom.xml.releaseBackup M conf-acceptance-test/pom.xml
My project included a failed run of the Maven release plugin, and I wanted to get my working copy back to a pristine checkout. The awk command does the following with each line of the input:
Hopefully it's easy to see in this short script how awk goes about processing each line of the Subversion status output and running the appropriate command.
When I write these scripts, I start out by putting 'echo' in front of all the commands I'm going to run. This lets me do a dry run first that just writes to the console all the commands which will be run. This is especially important when using commands like 'rm' automatically.
My previous articles related to scripting and Unix are: