# Exploring Walsh Functions

J. Donald Tillman

May 2020

(Sharing with colleagues. Please don't publish it on a mailing list or forum just yet.)

Back some time ago, the use of Walsh Functions was suggested for electronic music. What are Walsh Functions? They're sort of like a Fourier Series with square waves. Walsh Functions are a set of waves, each switching between two values like a square wave, each with an increasing number state changes, with both sine and cosine alignments, and you can sum them to approximate any waveform.

The illustration on the right is from Jacoby (references) and shows sine and cosine versions of the first 8 Walsh functions. (The nomenclature is a little weird; that's a side effect of the math.)

The writings at the time were geared toward using Walsh Functions to digitally implement the classic oscillator waveforms. I don't believe such a thing was ever commercialized.

I'm not interested in digital approximations of perfectly working analog functions. But I am intrigued about the possibility of other musical applications of Walsh Functions. What is their timbre like? Can we apply them in a musically expressive way? They're certainly easy enough to generate.

Well, we have an opportunity to check them out. This is a software simulation of a potential oscillator that delivers a set of 8 Walsh functions, and lets you mix them down.

These are the first 8 sine Walsh Functions. I've labeled them "W1" through "W8". ("SAL(1)" through "SAL(8)" in the above top diagram.) I tried the cosine versions also, but found no advantage to having both.

The sliders are "attenuverter" style, both positive and negative, with the zero at the center.

Click on the keyboard to play a note, or below to stop the note.

The tones generated here are unfiltered and will be on the bright side. The intent is that these waveforms are going to be used in the context of classic Subtractive Synthesizer, like a square wave, and will got through a low pass filter. There is no filter in this demo, so the waves will be on the bright side.

The Walsh number here is roughly equivalent to the harmonic number. Walsh number N has N pulses distributed over the course of the cycle.

W1 is a 50% duty cycle square wave at the fundamental frequency. W2, W4, and W8 are square waves at one, two, and three octaves above.

That alone is interesting, as timbre design goes, as square waves are all odd harmonics, and the octave square waves are all positioned over otherwise empty space. You can balance odd and even harmonics by mixing these. You can make increasing stairstep approximations to a sawtooth wave by setting their levels to 64, 32, 16, and 8.

The remaining Walsh functions have unequal pulse widths, so each contributes more complex patterns of harmonics.

W3 is odd harmonics, primarily 3rd. If you mix in a little fundamental, you can remove some of them, leaving an interesting harmonic pattern.

W5 is similarly odd harmonics, primarily 5th, and widely spread. If you mix in some W3, the timbre changes dramatically.

W6 is alternate even harmonics: 2, 6, 10, 14, 18, 22, and so forth. If you mix in some W2 you can cancel out alternate pairs of those... leaving harmonics 6, 10, 22, 26, etc. Wild stuff.

W7 is a lot of odd harmonics, primarily the 7th. You can mix in some W5 and see interesting changes.

And you can approximate a sine wave by mixing 100% W1, -43% W3, -9% W5, and -21% W7, although it leaves behind a weird pair of 15th and 17th harmonics.

And you can set all the W sliders to the same value for a double up/down impulse. And you can invert some of them to separate the up and down parts.

The interractions are interesting. Obviously W1, W2, W4, and W8 don't interract with each other. W1, W3, W5, and W7 include a fundamental component; the others do not. W3, W5, and W7 interract a lot, with large timbral changes.

I started this with skepticism. I never found Walsh functions all that attractive. They are not organic, there is no natural process that operates like them, it's not easy to keep a mental model in your head, and some of the behavior is unexpected. And flat waveforms, like the square wave, in general, do not respond well to subtle phase or frequency modulation.

But maybe there is something here.

### Organs

There are some interesting parallels to traditional electronic organs. You can think of the Walsh coefficients as the drawbars on a Hammond organ. There are several major differences. The primary pitches are different, although it would be entirely possible to do a set of Walsh functions whose primary pitches match the Hammond drawbars. Secondly, the Hammond drawbars don't interract, while some fraction of these Walsh functions interract. And third, these drawbars are bipolar with a center zero.

Many non-Hammond electronic organs use a "top-octave generator" circuit to provide the pitches for the top octave, and use flip-flops to divide down the octaves. That leaves square waves for all the notes, so many electronic organ makes add in the octave square waves to approximate a sawtooth. That's the same as we did above, mixing W1, W2, W4, and W8 to approximate a sawtooth. So it would be easy to extend electronic organ divide technology to encompass Walsh Functions.

### Summary

So I think this is very interesting and has a lot of potential. My main concern is that the relationship between the sliders and the timbre is not very intuitive.

### References

Benjamin Jacoby, Walsh Functions: A Digital Fourier Series

Bernie Hutchins, Experimental Electronic Music Devices Employing Walsh Functions , Journal of the Audio Engineering Society, Oct 1973.

Joseph Walsh, A Closed Set of Normal Orthogonal Functions, American Journal of Mathematics, 1923