A musician’s ability to remember vast quantities of notes is one of the great wonders of the human mind. As the Aurora Orchestra prepares to play Beethoven off by heart at the Proms, neuroscientist Daniel J Levitin explains how the brain makes music happen – and why he can’t get Elvis Costello out of his head

Like many people, I often find that I have little snippets of music playing in my head when my brain is meant to be doing something else. There appears to be no rhyme or reason to what this miniature jukebox decides to play. It could be something I just heard, something I’m practising for performance, or a melodic line from Die Walküre, Pitbull or Frozen. Sometimes it’s triggered: a colleague sent me an email this morning that said “There’s no action item for you on this” and, 10 minutes later, I discovered Elvis Costello’s No Action playing in my head.

For neurobiologists, the fact that music sticks in our heads suggests an evolutionary origin. Darwin felt that both music and language evolved as part of an emotion-signalling system, initially based on imitating – and modifying – environmental and animal sounds. Studies show that the same brain regions process all these kinds of sounds, lending credence to the idea of a common evolutionary origin. My lab’s own studies show that music activates regions of the brain that are older than those that process language, suggesting music preceded language, as Darwin believed.

Despite these ancient evolutionary roots, musicians sometimes seem a breed apart. Soloists have to learn vast numbers of notes. Pianists are expected to perform concertos that might last 40 or 50 minutes; a cellist will perform Bach’s six cello suites – roughly two hours of music – from memory. And what about singers? Pity the soprano who takes on Elektra and is on stage for all but five minutes of a 100-minute opera.

I’m often asked if musicians have better memories than everyone else. The answer is yes – and no. Yes, they tend to have better auditory memories. Music unfolds over time, so a musician’s memory for auditory sequences has to be very good. But their memory for other time-bound things, such as birthdays or appointments, is not necessarily better than anyone else’s.

So how does musical memory work? There are only 12 notes in western music and their combinations create all the diversity we experience. But music is rarely just a random sequence of these 12 notes. It’s highly organised, and musical pieces have a kind of narrative arc just like novels and films. In many cases, a musician learning a new piece will observe that a particular run starts on one note and ends on another, and that the two are connected by a particular scale. In this case, the musician doesn’t need to memorise every single note: they simply memorise the first and last note of the run, and apply their knowledge of scales to connect them.

More generally, musicians use “chunking”: breaking up the music they’re learning into small pieces. We do this when we memorise a speech or poem, taking little bits at a time and then gradually stringing them together. Twelve-tone or atonal music is more difficult to memorise because, by definition, it lacks the structure of tonal music – there’s no way to predict what will come next, so every note has to be memorised by rote. It would be the equivalent to trying to memorise random words that don’t make up sentences and paragraphs (try memorising Lewis Carroll’s Jabberwocky and you’ll see for yourself).

All musical instruments, including the voice, require some movement on the part of the musician, and the brain has evolved very sophisticated mechanisms for learning motor-action sequences, the basis of tool use. When learning a piece of music, musicians learn and store in their memory a series of movements, and these are bound to their aural memory.

So musicians, as well as athletes and dancers, learn and memorise precise sequences of body movements. We might call this “muscle memory” but really the memory resides not there, but in the cortex of the brain, in specialised structures that instruct our muscles precisely how to move. With practice, our muscles become stronger and more able to follow the brain’s instructions, but the memory itself is not in them. Many musicians object to this formulation of muscle memory because it feels as though their fingers are remembering where to go, but this is simply an illusion: if their brains become damaged, their fingers don’t remember how to play.

This muscle memory mostly resides in areas of the brain that look after the movement of the different fingers, toes, hands, wrists and forearms, in regions called pre-motor cortex (the planning of the movements) and motor cortex (their execution). Listening to rhythm, melody and harmony activates different brain regions. Remembering music, such as listening in your mind’s ear to a little snippet of music that has suddenly started playing in your head, activates the same regions as listening to it.

Carlos Santana once said I play guitar with an accent

For musicians, listening to or imagining music activates the same parts of the brain that would be moving their fingers if they were actually playing. Because the components of music are distributed throughout different brain networks, stroke, lesions, tumours or other brain trauma can lead to selective loss of very specific functions. We’ve seen patients who lose their ability to process rhythm but retain everything else; or they lose their ability to process melody but retain rhythm. Brain damage is so selective it can preserve memory for all the pieces you used to know, but interfere with the ability to form new memories.

It’s common knowledge that most of the best musicians began young. During the first 10 years of life, the primary mission of the brain is to make as many new connections as possible. Starting around puberty, its primary mission shifts to prune out unneeded connections. This doesn’t mean that we can’t learn anything new, but the learning takes on a qualitatively different aspect. This is why, if we learn a second language after the age of 12 or so, it’s likely we’ll end up speaking with an accent. Although I’ve played saxophone since I was eight, I didn’t begin playing guitar until I was 18. Carlos Santana once said I play guitar with an accent.

Facebook Twitter Pinterest The Aurora Orchestra at last year’s Proms. Photograph: Sarah Lee for the Guardian

There appears to be no limit to the amount of music that we can hold in our heads at any one time. Lounge pianists can often play thousands of songs from memory, and even play songs they’ve heard but never played before. This is a feature of human memory that’s not specific to music, however. Imagine you were asked to tell a Martian absolutely everything you know: mammals give live birth; the sun rises in the east and sets in the west; Paris is the capital of France; Great Expectations was written by Charles Dickens, seven times four equals 28 … anyone with a healthy, intact memory can recall a nearly limitless range of experiences, places and facts learned.

But of all musicians, perhaps it’s conductors who appear to be capable of the most prodigious feats of memory, to conduct operas and lengthy symphonies with parts for 30, 40 or more instruments from memory. In fact, you could argue that a conductor needs to know a piece that well in order to conduct it, whether or not they look at a score. Similarly, good stage directors tend to know the parts of everyone in a play.

All conductors conduct from memory to some extent. If they’ve conducted a piece many times, they might dispense with the score in front of them because the work is in their “physical memory”. But it’s very rare indeed for conductors to memorise a score to the point that they could write down from memory every single different part.

The distinction between playing from memory (“good”) and not playing from memory (“bad”) is not as black and white as it might appear. All playing is scaffolded on some type of memory: motor memory for scales and chords learned as a student, auditory memory of the piece and other pieces it reminds us of. The real question is whether the musician refers to written music or not. In a few contexts, such as studio work or a player sitting in as a substitute in a Broadway pit orchestra, reading is necessary because there is not enough time to memorise the parts.

And, as we can see, most pop musicians and orchestral soloists perform entirely from memory, without written music in front of them. The aim is to know a piece so well that you can stop thinking about the notes, and start thinking about the emotional expression that you (and the composer) want to convey. Ultimately the goal is to have the music “stuck in your head”, and that includes an integrated, cognitive representation of the sound of the music as well as the emotions it conveys to the musician – and hopefully the audience.