Friday, September 26, 2008

Tangled Melody: Reflections on Pachelbel’s Canon

WHAT greater bliss is there, than spending a lazy Saturday afternoon doing absolutely nothing of consequence? I had just settled down to watch the afternoon matinee on TV one such Saturday, hoping that the movie would be good. Well Vijay's films are usually good, and I looked forward to being entertained. Sipping a cup of ginger laced coffee– ahh the aroma is just heavenly – my eyes wandered to the guitar at the corner of the room. I picked it up, intending to amuse myself during those incessant commercial breaks.

It had been a long time since I played a classical piece on the guitar. One of my favourites happens to be Barrios' El Ultimo Tremolo, also known as Una limosnita por amor de Dios. So I started playing this piece, expecting to revel in its hauntingly beautiful melody and harmonic texture, but boy was I in for a big disappointment. I was unable to maintain a smooth tempo and had difficulty holding down the notes. By the time I reached the end of the first section, I was already huffing and puffing. My muscular memory had truly atrophied below the level of respectability. Here's a sample of what my hands wrought:



"I gotta do something to remedy this," I thought, "and do it soon".

So with my eyes still on the TV - it was an excellent Vijay story, by the way - I started to practice the tremolo – the art of repetitively hammering away on a particular string on the guitar until the notes almost begin to merge. I started the tremolo exercise with the C chord and let my fingers wander among the various chord shapes without consciously thinking about them. I found myself playing the following chords in sequence C, G, Am, Em, F, C, F, G. The resulting sound had an uncanny resemblance to something I'd heard before. See if you can spot it:



I played the sequence again, this time allowing my fingers greater latitude to play notes not commonly used in the triads. Here's the result:




There could be no doubt now as to what this was or was attempting to be. It was a caricature of George Winston's Variations on the Kanon. It is not that I particularly cared for the Kanon, or the Canon in D (Pachelbel's original, George Winston plays it in the key of C). In fact, whenever I get to the Kanon on my mp3 player, I quickly skip to the next track. George Winston's rendition of Vince Guaraldi's Cast your Fate to the Wind is more the kind of music I prefer.

What's surprising is that my seemingly random choice of chords could result in a sequence characteristic of Pachelbel's Canon. Does this mean that at some subliminal level I have affections for the Canon in D? I don't think I'll ever know for sure, but the experience has got me thinking about how our minds seem to prefer particular sequences of notes or chords. Such preferences surely reflect the dictates of biology as well as the influence of cultural exposure.

In my line of work I sometimes find myself resorting to computational constructs known as Finite State Machines, and it's obvious to anybody who has used them that they can be used to generate the sequential series of chords we find in music such as Pachelbel's.


So what is a Finite State Machine?
[You can safely skip the dry stuff that follows and jump straight to the conclusion by clicking here ]

A finite state machine (FSM) is an abstraction of stuff we routinely encounter in our daily lives – the behaviour of traffic lights, DVD players and coffee making machines to name a few. We all intuitively understand what they are and how they behave. With traffic light as our example, an FSM can be thought of as an object that could be in any one of a number of permissible internal states (eg. red, yellow, green). External inputs can cause the object to change its state in response. In the case of traffic light, that input comes from a timer signal. The new state that the object shifts to is specified by a transition rule, which could be in the form of a table, or a diagram like the one shown below:




The transition rule (the diagram) shows that certain events are not permitted, e.g. the transition from Red to Yellow, or from Green to Red. What we should appreciate is that once the transition rule has been laid down, and the initial state, e.g. Red, specified, the sequence of all future states that the traffic light will cycle through is completely determined. You can predict with complete certainty which state the traffic light will be in at any given time in the future.

By now you could probably tell where all this is leading: An FSM can be used to generate a sequence of chords. Let's try it for Variations on the Kanon. The diagram below shows the actual choice of chords used by the Kanon from the range available in the C major scale.


Astute readers will immediately realise we'll have a problem on our hands if we try to write down the transition rule for the chord sequence shown above. In a simple implementation of an FSM like the one used in the traffic light example, the next state is fully determined by the current state (ignore for the moment any external input signals). In the 5th measure, the transition is F -> C, whereas in the 7th measure the transition is F -> G. So here we have a situation in which the same state, F in this case, can transition to either C or G. This seems to violate our expectation of how an FSM should behave since the current state should fully determine the next. Sow do we deal with this? One way would be to use the musical measure itself as input to the FSM. Another alternative is to specify a transition rule that depends not only on the current state, but the previous state the FSM was in as well.

The real problem with using an FSM for generating chord sequences is that we are stuck with the same sequence for all of eternity, repeated ad nauseum. Used in this way the FSM is nothing but a crude memory device. What would be more useful is to have a construct that uses the Kanon as a style guide to generate novel sequences or even completely new melodies. We would like to have a construct that can 'learn' from examples fed to it to identify those musical motifs that humans find aesthetically pleasing.

Markov Chains

One mathematical construct that has the property we seek is the Markov chain. It is something we use daily, albeit unknowingly. We use it every time we make a phone call on our cell phones, surf the web over a wifi connection or google something on the internet. So how would the Markov chain help us with creating music or understanding why humans have predilection for certain musical motifs?

We can understand Markov Chains by thinking of them as extensions to FSM. In an FSM the transition rules specify unique inviolable transitions from an existing state to a future state. In our example, at the start of the Kanon, we have the transition C -> G. No other transition is specified or allowed. This is rather limiting and it is the reason why a simplistic implementation of an FSM cannot be relied upon for generating novel musical sequences. It is simply too rigid.

In a Markov chain the rules that govern transitions are modified so that they specify instead the probability that a given transition will take place. If you look at the Markov chain depicted below you'll notice that transitions from C to chords other than G are possible, but the most probable transition is C -> G. The numbers above the vertices indicate the probability of a particular transition taking place. For C -> G that probability is 0.4 (i.e. there is a 40% chance of it happening) and so it is the preferred path through sequence space.


In order to use a Markov chain to generate a sequence of chords, we will have to first seed it with values for all the transition probabilities involved. There are a number of ways of doing this. The easiest is to arbitrarily choose large probability values, e.g. 0.4 as shown in the diagram above, for transitions that we favour and one which is characteristic of the Kanon. The other option is to systematically estimate (using an appropriate algorithm) those probabilities from observation of chord sequences in music we like. A database of hit songs from any given era could be used for this purpose.

One particular approach that I'm fond of is to use evolutionary computation techniques such as genetic algorithms for estimating the parameters (i.e. the transition probabilities) of the Markov model and vice versa. These techniques rely on evaluating what is known as the 'fitness function'. For things musical, the fitness function is a measure of how aesthetically pleasing the music is to the ear. A program that uses this approach will use model parameters generated through a genetic algorithm to generate a sequence of musical notes which will then be presented to a human listener for evaluation. The decision by the human listener whether a particular motif is pleasing or otherwise will then be used to either accept or reject the model parameters, and hence the genetic sequence that gave rise to it. The process could be automated too, so that instead of relying on human intervention, popular music could be parsed appropriately to determine the fitness of novel musical motifs.

So Where’s the Beef?

That detour into a discussion of finite state machines and Markov chains might seem unnecessary to some, but I have decided to include them in this post anyway because they capture the thought processes I went through when I realised that the sequence of chords I thought I was playing purely on a whim happened to be the sequence used in Pachelbel's Canon.

Prior exposure to music, be it at home, in the elevator or at work – music is everywhere these days - had predisposed my mind to expect certain musical motifs as natural. So strong is this predisposition that we have a tendency to see patterns where there are none, or hear sounds when none have been made. The more sophisticated among songwriters understand this phenomenon and exploit it to their advantage in the songs they write and in the music they create, all for our listening pleasure.

At another level, psychoacoustics as this stuff is called, has been exploited by engineers and scientists to design audio equipment or shrink file sizes to a degree that seems too good to be true. Take the mp3 file format for example; the reason why it can be made so compact is because there is no attempt to accurately reproduce all the information contained in the original sound. Sounds determined to be below the threshold of human perception within a given auditory context are discarded or have their priority reduced when the decision is made as to which information should be retained and which can safely be thrown away.

The predispositions that our minds display are not merely limited to harmonic sequences; they shape the deep-seated expectations we harbour in our daily interactions with other people, and in those important decisions we make in our lives. Mathematical constructs such as Markov chains allow us to gain a deeper appreciation of such phenomena and thereby greatly enrich our understanding and experience of the world. If you are one of those who find the statement that intellectual understanding can only heighten the delight of sensual experience unconvincing, I'd like to end this post with a quote from that inimitable iconoclast, a physicist's physicist: Richard Feynman. Addressing his students one day in a class on introductory physics, he said:

“A poet once said "The whole universe is in a glass of wine." We will probably never know in what sense he meant that, for poets do not write to be understood. But it is true that if we look at a glass closely enough we see the entire universe. There are the things of physics: the twisting liquid which evaporates depending on the wind and weather, the reflections in the glass, and our imaginations adds the atoms. The glass is a distillation of the Earth's rocks, and in its composition we see the secret of the universe's age, and the evolution of the stars. What strange array of chemicals are there in the wine? How did they come to be? There are the ferments, the enzymes, the substrates, and the products. There in wine is found the great generalization: all life is fermentation. Nobody can discover the chemistry of wine without discovering, as did Louis Pasteur, the cause of much disease. How vivid is the claret, pressing its existence into the consciousness that watches it! If our small minds, for some convenience, divide this glass of wine, this universe, into parts — physics, biology, geology, astronomy, psychology, and so on — remember that Nature does not know it! So let us put it all back together, not forgetting ultimately what it is for. Let it give us one more final pleasure: drink it and forget it all!”

Wednesday, September 10, 2008

Malacca Delectable

YOU can see it in their smile, taste it in the air and savour it in their fare, of sugar and spice and all things nice, an exquisite blend of all that is wonderful about the Asia I like. I’m talking about Malacca. The original hub of the solar system (much to the chagrin I would expect of Boston Brahmins!) or if that sounds a tad inflated, at least of 15th century global trade routes.

Successive world empires have left their traces here, in the language you hear spoken on the street, in the architectural mélange of buildings, genes and places of worship, and ultimately for this foodie, in the prized Peranakan cuisine. It is about the latter that I wish to write about in this post.

Peranakan (or Baba Nyonya) cooking was first brought to my attention when a friend of mine took pity on my culinary skills, with its tendency to render all food cuit à l'anglaise, and showed me how to prepare some simple dishes (she is of Chinese, Indian and Malay extraction). One incredible recipe of hers which has gotten me out of more tough situations than I can remember, is the Ayam Masak Merah Ala Baba Nyonya (chicken cooked in spicy red sauce). It can be prepared in a jiffy, uses a minimal of pots and pans, and for someone who used to live on a student’s budget, was and still is eminently affordable.

So what this post comes down to is this, to show you how to prepare this amazingly simple dish. The recipe that I’m going to describe has evolved over time and I have taken the liberty of using ingredients such as cashews which were not present in the original as well as ditching some that only connoisseurs of exotic food may miss. So the authenticity to Baba Nyonya cooking is debatable. But what matters most is the taste, right?

First, let’s begin with the list of ingredients you will need (Box 1). Notice that they are all commonplace items which you will be able to find in the Tescos and Wall-Marts of the world. I happen to think that this availability factor is one of the main attractions of this recipe. So no matter where you are, be it Wasilla or Valhalla you will still be able to prepare and enjoy this dish with your friends and family.

BOX 1: LIST OF INGREDIENTS


  • 4 skinless chicken breast fillets (approx 600g)
  • 5 shallots
  • 3 large ripe tomatoes
  • 3 medium sized red onions
  • 1 large fresh chilli
  • 1 tablespoon thick soy sauce
  • 1 tablespoon sugar
  • A handful of cashews


  • 1 teaspoon of chilli powder (for marinating)
  • 1 teaspoon of turmeric powder
  • Chopped coriander, aka cilantro (optional)
  • A squeeze of lemon juice (optional)
  • Cooking oil
  • Salt


OK now’s time to get all hands on. Cut the chicken breast fillets into smaller pieces, but be careful not to make them too small otherwise you’ll end up with chicken broth instead of an exotic dish from the Far East. Lightly marinade the pieces with some paste made up of turmeric, chilli powder, salt and water. Cover the pieces and leave them aside while you prepare the other ingredients.

Blend the onions and fresh chilli into a paste using a food processor. Leave it for later. Cut the shallots crosswise and separate them into rings. The shallots will be used for garnishing the dish when we’re done cooking.

Fire up the wok and add a sufficient amount of cooking oil to make frying comfortable. Add cashews to the oil when it’s sufficiently hot, and fry until they are slightly brown. You have to be careful here. It’s easy to overdo the frying and end up with burned cashews! So remove the cashews at the slightest hint of browning. Once done, place the fried cashews aside to drain the excess oil.

Now fry the shallots in the same wok and put them aside after you're done. Do not discard the oil in the wok just yet. Use it to fry the marinated chicken pieces. Fry the chicken pieces until they are about half done. Remove and let drain.

There should still be some oil left in the wok. So add the onion/chilli paste, followed by a tablespoon of sugar (to give that exotic taste!). Fry the paste until it turns golden brown and you start getting a whiff of that gorgeous aroma. Put in the chopped tomatoes and continue frying until the tomatoes begin to melt. Add a tablespoon of thick soy sauce to give the paste that exotic Far East look. Then add the fried chicken pieces, making sure that they are completely coated by the paste and tomatoes. Stir fry for a minute or so before adding a cup of water. Bring the concoction to boil, cover and allow to simmer under low fire for about 10 minutes.

Add salt to taste and optionally, a squeeze of lemon juice if you would like that extra tang. Fried cashews are added next and the contents of the wok transferred to a serving bowl. Garnish with fried shallots and coriander leaves. Ta-da! And you’re done!

This dish is best served with steaming fragrant rice.

What if you want to skip the rice?

Here’s a variation on the recipe that I find myself using quite often. If you would like to serve the dish with spaghetti instead of rice, ditch the chilli and shallot, instead add a small amount of cumin to the wok prior to the onion paste. When you're almost done cooking and the chicken has become tender, add some bell red pepper that has been sliced into long thin strips (if you put in the pepper too early it will become unacceptably soft).


What if you are vegetarian?

You can replace the chicken with Quorn. In fact this is what I do when I invite vegetarians over for dinner. If you haven’t heard of Quorn, look it up on Wikipedia or visit http://www.quorn.com. I have visited the factory where they make the stuff and I have this to say: it is the cleanest food production facility I have seen. No, I don’t work there in case you’re wondering!


Dealing with the chilli

Not everyone likes the bite chilli leaves in their mouth. After a great deal of experimentation I have discovered the perfect antidote for this, it’s Haagen-Dazs’ pineapple coconut ice cream, although frozen yoghurt will do in a cinch.


You are now all set for a wonderful evening

If you have called your friends over for an evening of fireside discussion don’t forget that pecan pie or gourmet roasted coffee. I find them to be absolutely indispensable for a summer’s evening of entertaining, light-hearted and occasionally weighty discussion. I usually tend to end such gatherings by taking my friends outside to enjoy the cool breeze on an otherwise warm summer’s night and introduce those who are unfamiliar with the night-time sky, to the Summer Triangle, which is made up of the stars Vega, Deneb and Altair. A marvellous sight if you happen to live away from the city and a perfect way to end a summer’s evening.

Music Videos

place music videos here

Previous Posts

list of previous posts here