Synthesizing simple chords with sox

SoX can do almost anything with audio files — including synthesize audio from scratch. Unfortunately, SoX’s syntax is more than a bit hard to follow, and the manual page isn’t the most clear. But there is one example in the manual that gives a glimpse of what SoX can do:

play -n synth pl G2 pl B2 pl D3 pl G3 pl D4 pl G4 \ 
     delay 0 .05 .1 .15 .2 .25 remix - fade 0 4 .1 norm -1

While it plays a nice chord, it’s not obvious how to make audio files from this process. I have a project coming up that needs a few simple guitar chords, and with much trial and error I got SoX to spit out audio files. Here’s what I keyed into the shell:

cat guitar.txt | while read chord foo first third fifth
  echo "$chord" :
  sox -n \ 
    -r 16000 -b 16 "chord-${chord}.wav" \
    synth pl "$first" pl "$third" pl "$fifth" \
    delay 0 .05 .1 \ 
    remix - \ 
    fade 0 1 .095 \ 
    norm -1

with these lines in the file “guitar.txt”

G   :  G2  B2  D3
C   :  C3  E3  G4
D   :  D3  F#4 A3
F   :  F3  A3  C4
A   :  A3  C#4 E4
E   :  E2  G#3 B3
Em  :  E2  G3  B3

How the SoX command line breaks down:

    • -n —use no input file: SoX is going to generate the audio itself
    • -r 16000 -b 16 “chord-${chord}.wav” — with a sample rate of 16 kHz and 16-bits per sample, write to the output file “chord-….wav”
    • synth pl “$first” pl “$third” pl “$fifth” —synthesize three plucked tones read from the file
    • delay 0 .05 .1 —delay the second tone 0.05 s after the first and likewise the third after the second. This simulates the striking of guitar strings very slightly apart.
    • remix – —mix the tones in an internal pipe to the output
    • fade 0 1 .095 —fade the audio smoothly down to nothing in 1 s
    • norm -1 —normalize the volume to -1 dB.

The chords don’t sound great: they’re played on only three strings, so they sound very sparse. As my application will be playing these through a tiny MEMS speaker, I don’t think anyone will notice.

Update: well, now I know how to do it, why not do all 36 autoharp strings and make the “magic ensues” sound of just about every TV show of my childhood?

Glissando up:

sox -n -r 48000 -b 16 autoharp-up.wav synth pl "F2" pl "G2" pl "C3" pl "D3" pl "E3" pl "F3" pl "F#3" pl "G3" pl "A3" pl "A#3" pl "B3" pl "C4" pl "C#4" pl "D4" pl "D#4" pl "E4" pl "F4" pl "F#4" pl "G4" pl "G#4" pl "A4" pl "A#4" pl "B4" pl "C5" pl "C#5" pl "D5" pl "D#5" pl "E5" pl "F5" pl "F#5" pl "G5" pl "G#5" pl "A5" pl "A#5" pl "B5" pl "C6" delay 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 0.95 1 1.05 1.1 1.15 1.2 1.25 1.3 1.35 1.4 1.45 1.5 1.55 1.6 1.65 1.7 1.75 remix - fade 0 6 .1 norm -1

Glissando down:

sox -n -r 48000 -b 16 autoharp-down.wav synth pl "C6" pl "B5" pl "A#5" pl "A5" pl "G#5" pl "G5" pl "F#5" pl "F5" pl "E5" pl "D#5" pl "D5" pl "C#5" pl "C5" pl "B4" pl "A#4" pl "A4" pl "G#4" pl "G4" pl "F#4" pl "F4" pl "E4" pl "D#4" pl "D4" pl "C#4" pl "C4" pl "B3" pl "A#3" pl "A3" pl "G3" pl "F#3" pl "F3" pl "E3" pl "D3" pl "C3" pl "G2" pl "F2" delay 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 0.95 1 1.05 1.1 1.15 1.2 1.25 1.3 1.35 1.4 1.45 1.5 1.55 1.6 1.65 1.7 1.75 remix - fade 0 6 .1 norm -1

Could maybe use some reverb in there for the ultimate nostalgic effect.


The Yonge & St Clair Autoharp Guy

This guy sets up on the SE corner of Yonge & St Clair most afternoons, and plays endless variations on the above recording. He’s playing an autoharp with the chord bars removed, and run through a homebrew battery-powered amplifier with much reverb and distortion. A bunch of the burbly noises are 8kbit/s voice recorder artifacts from my phone.

Although the themes seem repetitive, I don’t think they repeat exactly every time. He seems to be in a happy place playing them.

Linda Parker Hamilton — The Northern Nightingale: A Canadian Whistler

She whistles, plays autoharp, and lives locally: Linda Parker Hamilton — The Northern Nightingale.

Bob Briehl, the autoharp man in Canada

After ferrying Catherine around for another exciting adventure in LibraryQuest, we took my autoharps to Appalachian Instruments in Oakville for a repair. I have half expecting Bob to declare at least one of them a junker, but apparently they’re more than salvageable. Indeed, the older Type A is apparently a rather nice 1950s wood-bar black felt Silvertone, and the Type B, despite the warped top, is a good little player except for a couple of weak springs. Bob’s busy repairing and generally refurbing them, and we should get them back in a week or two. Should we form an autoharp folk duo?

Bob’s the local luminary of the autoharp, and has many models and spares in stock. It’s best to leave a message on the store’s phone, as he’s not always there. He also teaches, and does house calls.

Appalachian Instruments
117 Westside Drive, Oakville ON L6K 1P2
171 Solingate Drive Oakville ON L6L 3S8
(905) 845-0638

Update: Bob advised of a change of address.

oliver postgate’s world

Sad to hear that Oliver Postgate passed away. Bagpuss was my series; it started just as I started school, and I caught the first episodes. I spent the whole evening learning the theme on the mandolin, and watched a couple of episodes, half-teary. Was it really nearly 35 years ago?

The music and sounds are what stuck with me. I didn’t know it at the time – but did as soon as I picked one up – that the Bagpuss waking up magic sound is a slow upwards glissando on an autoharp. Similarly, the falling asleep sound is an autoharp strummed slowly downwards. Gabriel’s instrument confused me for years – I now see it has a 5 string banjo neck, but no fifth string (like someone else I could name). To add further confusion, it’s really a mandolin that’s Gabriel’s sound.

the joy of craigslist

  • 2 hours
  • 23km driven
  • $3 parking
  • $8 sandwich dinner
  • $3 coffee

… all wasted waiting for a silly wee lassie who’d agreed to meet to sell an autoharp, then sold it out from under me.

Real smooth move, Stefanie.


Pleasantly surprised that a local store – Scarboro Music, at Vic Park and Kingston has autoharp strings.

It also has a very fine old Dobson banjo for $1500.

autoharp frenzy

autoharp chord bars

I got an autoharp on eBay a couple of weeks back. It was cheap, but fairly beat up. 32 of the 36 1970s-vintage strings were intact, if very tarnished. I spent more on new strings and a tuning wrench at Elderly last weekend. After spending a few evenings cleaning (you don’t want to know what I found in it), replacing strings (fiddly) and tuning (slow), I can now make 1970s sounds. Fun!

(and yes, before you ask, it does appear to have two B♭7 keys.)