SuperCollider Difference Tone Finder

Posted on Posted in Music, Tutorials

Something that I need quite often is to find the difference tone between various pitches. For those unfamiliar with difference tones, it is a physical acoustic phenomenon where when any two frequencies are played simultaneously, you hear the difference between them (the higher minus the lower). If you’ve been around a pair of high instruments playing together you may have noticed a third, lower tone sounding below them. Or if you’ve heard power chords on a distorted electric guitar you actually hear a note an octave below the lowest note.

I’ve been working a lot with harmonies based on a set of just intonation ratios and amplifying their difference tone. When only dealing with two pitches at a time, it’s easy enough to just subtract them but once you have three or more, you must subtract every pair and find the lowest to know what the “primary” difference tone is. I’ve done this by hand before and it can be quite time consuming so I finally got around to making a little tool in SuperCollider to do it for me. It’s really simple: it loops through an array of ratios or frequencies, adds the difference of every pair to a list, sorts that list, and returns the lowest (first in the sorted list) difference tone. Here’s an exammple:

JustIntonationTools.differenceToneRatio([1,6/5,8/5,9/5]).asRational;

will return 8/5, which is the lowest ratio of all the difference tones in that set. Maybe someone out there will find a use for this in their work but it’s something I need constantly. The JustIntonationTools class currently only has this one method but I’m sure I’ll be adding more over time. It can be found on my github if you’d like to play with it. I should point out that it requires the TuningLib quark created by Charles Hutchins as he has a great method to adjust ratios to be within an octave.