Coding 2026-07-12

Tags:
By Max Woerner Chase

So. I recently took all of my projects and took them from "I've got offsite backups" to "a monorepo". Now that it's a bit easier for me to roll back bad changes, I have less (spurious?) justification for trying to work on stuff in a strict sequence. This is relevant because I'd thought that I wanted an interface to selecting pitches that had some kind of music theory behind it, but it turns out that what I really want is to have the ability to synthesize sounds that sound like something, and that means putting together more advanced synthesis.

So, additive synthesis. I want to be able to specify different overtones than pure harmonics. Let's see what I'm trying to do. Well, my target interface is a callable that takes a(n array of) number(s), and maps that input to the corresponding value(s) of the waveform. In particular, the output is assumed to be more-or-less periodic, with a period of 1. I want to take the input, apply a phase shift for each sine wave I'm going to synthesize, multiply the result by the relative frequency of the overtones, take the sine of each entry, scale by the target amplitude of the overtones, then sum to produce a 1-dimensional output array.

The only part of this I should need to think overly hard about is how to make sure all of the array dimensions and broadcasting line up properly. I believe what I want to do is broadcast a trailing newaxis onto the input, do all of the math, then sum over the trailing axis.

Okay, that took me a few minutes. It's late enough that I'd rather not test it right now, and just get to bed.

Good night.