Audio synthesis: plucked string and delay

0
0
Published 2023-06-12

I just learned about the PCM interface, so I thought I'd do a little adventure into sound synthesis.

This cart is an experiment in building up an audio system that can run dataflow graphs built up from smaller generator and effect components. Here, I've used it to generate some plucked string sounds, mix those together, and then apply some delay to the result. The audio system needs some work and probably should implement audio processors as objects instead of coroutines (as coroutines it's annoying to send control signals once a processor has been created), but it's still kinda fun.

The code has a bunch of other areas that could use cleanup too, but coroutines vs. objects is probably the one big design issue that should get sorted out.

The one big audio-system-side thing that really helped here was trying to generate at least 128 samples per frame so long as I wasn't too far ahead of the audio system's needs. This really helped smooth out maximum CPU usage, since without that tweak I was sometimes generating 256 samples and sometimes 0.

On the plucked string side, with such a low sample rate it was absolutely necessary to include the tuning allpass filter in the delay loop. I've also included decay stretching as well as decay shortening ... yes, they're sort of at odds, but mixing them gives you a range of different sounds. I haven't done any pick direction/position filtering, string stiffness, bridge effects, sympathetic vibrations, dynamics filtering so louder notes are brighter, etc. But those could all be done here if anyone were so inclined!

The cart works well on my machine, but I'm very curious about whether it will sound okay on the web. I've tried to keep the volume down, but please be careful about your levels when you hit play.


As for the "composition", I started with a standard guitar tuning, but each string loops through a sequence of interval offsets from that tuning, advancing one step each time it gets hit. Not my favorite but it sort of works, I think.

Update: I added some ways to tweak the sound (stretch and damp) as well as the speed of the balls (dt). Up and down arrows select parameters, left and right change them. It's definitely more interesting this way.... For stretch and damp - low stretch values kill high frequencies faster, whereas low damp values tend to reduce all frequencies equally.