Digital signal processing in a spreadsheet: an experimental toy
Two women are watching an organ grinder. The organ grinder wheezes music while a monkey in a red hat ambles from foot to foot.
One woman says, “That monkey dances badly.”
The other woman says, “It’s not that the monkey dances badly. It’s that it dances at all.”
People have abused spreadsheets since spreadsheets were invented. You can play sudoku, 2048, or Minesweeper if you take the time to get exactly the right formulas entered.
Today, we’re going to do a strange little experiment where we synthesize sounds using a spreadsheet. This spreadsheet is a toy and should not be considered for use in any sort of production situation. But it demonstrates that pretty much anyone can do digital signal processing, given a little bit of time and patience.
So here’s the spreadsheet, in Microsoft Excel format.
So what do we have here? If you click on cell B4, you’ll get an action-packed overview of how the spreadsheet works. All the first lines in the spreadsheet are prefixed by semicolons. They will be interpreted as comment lines when it comes time to convert this spreadsheet into a sound file. Cell B1 is the Sample Rate cell. You can change this if you want, but be aware that most computers look askance at odd sample rates, and if you want a really high sample rate then you may need to extend this spreadsheet downward with more of the same formula. I tried to highlight all the numbers you’d want to dork with in yellow, but please feel free to change anything you like here. Experimentation is good.
Starting with row 15, each row in the spreadsheet corresponds to a single sample of output. Line 15 contains the first sample of output. Cell A15 contains the time offset from the beginning of the first sample — we start playing that sample at time ~0.0013. Cell B15 contains the amplitude we generate at that instant. You’ll notice that it’s approximately an average of the values to the right of the semicolon for each line.
Cells 14E, 14F and 14G contain information about three virtual oscillators. You can set these oscillators’ values to anything you’d like, but I chose to synthesize two tones at 350 Hz and 440 Hz at the same time.
The real magic happens in cells 15E, 15F and 15G. Here, we take the row number and treat it as an offset in time. We then generate a sine frequency at the requisite sample rate, taking into account the frequency we’ve chosen for that specific oscillator. Don’t be scared about the SIN(2*PI()*…) business in the formula — you might remember that sin(0) = sin(2*pi) from trigonometry — but if you’re spooked by it, just know that this is the trick we use to convert a frequency in Hertz to an actual tone.
All right, at this point we’re going to save the spreadsheet as a text file. I can’t tell you exactly how to do this with your own program, but in Excel I can do “File/Save As…” and then select Text (MS-DOS) as the save option. I save the file with the file name synth.txt. In Google Sheets, I select File/Download As… and select Tab Separated Values and then I rename the output file to synth.txt. If you care to look inside this file, we’ve basically removed all the formulas and all we’re left with is the synthesized tone data.
At this point we need to convert this text file into a format we can listen to. Keep in mind that the sound synthesis is already done — we just need to convert the file into something listenable.
Now, the next tool you’re going to need is the public-domain SoX program. SoX bills itself as the “Swiss army knife of sound processing programs,” and if you’re willing to spend time learning its somewhat cryptic command line interface, it delivers fully on that promise. Now we’re going to use SoX to convert the output of that spreadsheet into listenable audio. Note that the sound synthesis is already done at this point — we just need to be able to hear the output somehow.
Download the latest version of SoX from the release page and install it. Then we’re going to run a single command. Even if you’re allergic to command lines, this one liner won’t hurt a bit, I promise:
sox -t dat synth.txt -t wav output.wav
The -t dat section tells SoX that the input file it’s reading is in DAT format, which is a SoX specific text-only interchange format. Change synth.txt to be the path and file name of the text file you exported from your spreadsheet program, if you used a different name from me. Additionally, you can change output.wav to be the name of the file you want to generate.
Once you run this command, sox will churn for an instant and create an output file at 11025 Hz. For some reason, the Windows Media Player program doesn’t want to open the WAV file that sox writes, possibly due to the odd sample rate, but Adobe Audition and Pro Tools open and play the file just fine.
So that you can hear the file in your browser, I’ve converted that file again to 44.1 kHz in WAV and MP3 format. Here’s my output:
It’s about one second of North American dial tone — two sine tones at 350 Hz and 440 Hz played in unison.
Now, if after all that, you realize that that’s a surprising amount of work just to get a moment of dial tone out of a spreadsheet… then just keep in mind one thing.
It’s not that the monkey dances badly. It’s that it dances at all.
Have fun with this spreadsheet toy, and if you manage to make anything cool with it, let us know in the comments section below!
Products

Varantic Trial
You asked, and we listened. You need to hear it for yourself on your own machine, with your own speakers, with your own sounds. Well, go for it. Try all the features of Varantic Pro, for 7 days, on us.

Varantic Studio
Varantic Studio allows batch scripting of the entire Varantic process, so that you can generate millions of high-quality sound effects from within your development pipeline.

Varantic Pro
With advanced functions such as sound length control, support for high bit rates and most file formats, and automatic batch export, Varantic Pro has all the features that a working sound designer needs.