teaching machines

Modeling a Coin Pickup Sound

Years ago I ran across sfxr, a little tool for generating sound effects. Seven classes of sounds can be generated: coin pickups, shots, explosions, powerups, hits, jumps, and blips. The author, DrPetter, made the tool to support folks like me who don’t have the time, skill, or team to make sounds for their games. But I hardly cared about the effects themselves. I instantly became interested in learning how to write something like sfxr.

Thus began my pursuit of understanding digital audio. I started programmatically synthesizing my own sounds using sine waves. I read countless books on computer sound, but things always seemed to get wild after chapter 1. I had students in my introductory programming courses learn about arrays and binary files by piecing together their sampled waves into musical sequences and exporting them to WAV files. I had students in a third-year programming languages course build a Java GUI and C++ backend for controlling the harmonic profile of the sounds they generated. I spent two summers working with high schoolers using Pure Data and Arduino to build custom musical instruments. I designed a programming language for learning musical theory.

None of that led me understand how to model the coin pickup sound that so eluded me. DrPetter had left something of a trail to describe the models used for a few of the classes of effects in sfxr, but it was too vague for me to do much with.

Then spring 2020 happened. First, a student asked me if I’d partner with him on an independent study on digital sound. I happily agreed and started building something like sfxr as we learned together. Second, a global pandemic hit, which upended my focus completely. Because our world has stopped, I’ve been able to spend the last few days getting my software into a workable state.

Once I got it working, I played around with the frequency and amplitude envelopes that DrPetter describes in the tutorial. But nothing I made sounded like a coin pickup. So, I went to YouTube and found this video:

A coin sound is just a B in the fifth octave followed by an E in the sixth octave. I could do that. And I did! Here’s me composing the sound effect in Earpiece:

B5 has frequency 987.77, and E6 has frequency 1318.51. As demonstrated on the piano, we roll quickly from the B to the E.

We need a bit of amplitude at the start because the sound needs to intrude on us, not creep in. The amplitude peaks as we roll onto the E and then fades out.

I plan to share other classes of sounds as I learn their mathematical makeup. I’ve also made Earpiece publicly available, but I don’t expect anyone but me to use it. If you figure out how to use it, you are amazing.

Making blips on the computer might seem trivial as the world falls apart. But these coins might have more value than our own pretty soon.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *