micro:bit plays Bach

I dedicate this post to one of my favorite composers, Johann Sebastian Bach. I was walking through Paris years ago when I approached a cathedral where someone had played this piece. It is the fugue of the Bach Toccata, BWV 565. At first, I thought that a virtuos organist must be at work here. Only when I got closer did I realize that the music came from a harmonica player!

I found the scores here and tried to reproduce the melody as well as possible on the micro:bit with a single voice. I provide them for download, in case it disappears or the link breaks down.

Since the piece is rather long and I didn’t find a suitable location to stop early, the piece stops rather abruptly. But it is enough to get a first impression.

And maybe it will tempt you to learn to play the piece yourself or at least to listen to a professional recording of a musician playing the piece on a real instrument.

The following python script elicits the beginning of the fugue part from the micro:bit.

The micro:bit v2 playing Bach Fugue, BWV 565

If you don’t own a micro:bit, you can either buy one here or copy/paste the source code into this online emulator and let it run there to listen to the music. 🙂

from microbit import *
import music


while True:
    if button_a.was_pressed() or button_b.was_pressed():
        display.scroll("J.S.Bach, Fugue in D Minor, BWV 565", wait=False, loop=True, delay=60)
        # BACH TOCCATA FUGE: http://www.musanim.com/pdf/bwv565-a4.pdf
        # tune = ["C4:4", "C#4:4", "E4:4", "Eb4:4" ]
        tune = ["A4:2", "G4:2", "A4:2", "F4:2", "A4:2", "E4:2", "A4:2", 
                "D4:2", "A4:2", "C#4:2", "A4:2", "D4:2", "A4:2", "E4:2", "A4:2", "F4:2", "A4:2",
                "A3:2", "A4:2", "B3:2", "A4:2", "C#4:2", "A4:2", "D4:2", "A4:2",
                "C#4:2", "A4:2", "D4:2", "A4:2", "E4:2", "A4:2", "F4:2", "D5:2",
                "C5:2", "D5:2", "Bb4:2", "D5:2", "A4:2", "D5:2", "G4:2", "D5:2", 
                "F#4:2", "D5:2", "G4:2", "D5:2", "A4:2", "D5:2", "Bb4:2", "D5:2",  
                "D4:2", "D5:2", "E4:2", "D5:2", "F#4:2", "D5:2", "G4:2", "D5:2", 
                "F#4:2", "D5:2", "G4:2", "D5:2", "A4:2", "D5:2",
                "Bb4:2", "G4:2", "D5:2", "G4:2", "Bb4:2", "G4:2", "D5:2", "G4:2",
                "Eb5:2", "Eb4:2", "G4:2", "Eb4:2", "Eb5:2", "Eb4:2", "G4:2", "Eb4:2", 
                "C5:2", "F4:2", "A4:2", "F4:2", "C5:2", "F4:2", "A4:2", "F4:2", 
                "D5:2", "D4:2", "F4:2", "D4:2", "D5:2", "D4:2", "F4:2", "D4:2", 
                "Bb4:2", "E4:2", "G4:2", "E4:2", "Bb4:2", "E4:2", "G4:2", "E4:2", 
                "C#5:2", "C#4:2", "E4:2", "C#4:2", "C#5:2", "C#4:2", "E4:2", "C#4:2", 
                "A4:2", "D4:2", "F4:2", "D4:2", "A4:2", "D4:2", "F4:2", "D4:2", 
                "G4:2", "Bb3:2", "C#4:2", "Bb3:2", "G4:2", "Bb3:2", "C#4:2", "Bb3:2", 
                "F4:2", "A3:2", "D4:2", "A3:2", "F4:2", "A3:2", "D4:2", "A3:2", # LINIE 1 SEITE 6 FERTIG
                "E4:2", "G3:2", "Bb3:2", "G3:2", "E4:2", "G3:2", "Bb3:2", "G3:2", 
                "A3:2", "A5:2", "G5:2", "A5:2", "F5:2", "A5:2", "E5:2", "A5:2",
                "D5:2", "A5:2", "C#5:2", "A5:2", "D5:2", "A5:2", "E5:2", "A5:2",
                "F5:2", "A5:2", "A4:2", "A5:2", "B4:2", "A5:2", "C#5:2", "A5:2", 
                "D5:2", "A5:2", "C#5:2", "A5:2", "D5:2", "A5:2", "E5:2", "A5:2", 
                "F5:2", "A5:2", "E5:2", "A5:2", "D5:2", "A5:2", "C5:2", "A5:2", # LINIE 2 SEITE 6 FERTIG
                "Bb4:2", "A5:2", "C5:2", "A5:2", "D5:2", "G5:2", "Bb4:2", "G5:2", 
                "E5:2", "G5:2", "D5:2", "G5:2", "C5:2", "G5:2", "Bb4:2", "G5:2", 
                "A4:2", "G5:2", "Bb4:2", "G5:2", "C5:2", "F5:2", "A4:2", "F5:2",
                "D5:2", "F5:2", "C5:2", "F5:2", "Bb4:2", "F5:2", "A4:2", "F5:2",
                "G4:2", "F5:2", "A4:2", "F5:2", "Bb4:2", "E5:2", "G4:2", "E5:2",
                "C#5:2", "E5:2", "Bb4:2", "E5:2", "A4:2", "E5:2", "G4:2", "E5:2", # LINIE 3 SEITE 6 FERTIG
                "F4:2", "E5:2", "G4:2", "E5:2", "A4:2", "D5:2", "F4:2", "D5:2", # <- SEITE 7 LINIE 1       
                "E4:2", "E5:2", "E4:2", "E5:2", "F4:2", "D5:2",  "F4:2", "D5:2", # S7 L1 T1 ENDE   
                "Bb4:2", "C#5:2", "Bb4:2", "C#5:2", "A4:2", "D5:2", "F4:2", "D5:2",
                "E4:2", "E5:2", "E4:2", "E5:2", "G4:2", "D5:2", "G4:2", "D5:2", # S7 L1 T2 ENDE
                "E4:2", "D5:2", "C#5:2", "D5:2", "B4:2", "D5:2", "C#5:2", "B4:2",
                "C#5:2", "A4:2", "G4:2", "A4:2", "E4:2", "G4:2", "F4:2", "E4:2", # S7 L1 ENDE
                "F4:2", "D5:2", "C#5:2", "D5:2", "F5:2", "D5:2", "C#5:2", "B4:2", 
                "A3:2", "A4:2", "G4:2", "A4:2", "C#4:2", "G4:2", "F4:2", "E4:2", # S7 L2 T1 ENDE
                "F4:8", "E4:2", "A3:2", "G3:2", "A3:2", "F#3:2", "D4:2", "C#4:2", 
                "D4:2", "G3:2", "F4:2", "Eb4:2", "D4:2", "C#4:2", "E4:2", "A3:2", 
                "C#4:2", "D3:2", "Eb4:2", "D4:2", "C4:2", "B3:2", "D4:2", "G3:2",
                "B3:2", "C3:2", "D4:2", "C4:2", "Bb3:2"]