Post #2685456
2026-04-30 22:12 UTC
I'm having another go at my stack-based livecoding audio synthesis thingy from eons ago
i.e., this outputs two sine waves whose frequency is oscillating
: f 20 sin 1 + 0.5 * 440 * 220 + ;
: hello f sin f 2 * sin 0 out ;
I'm co-opting the (semi-)colon word from FORTH to define "players" (need to find a better name)
These players are stored in a table, and each contains a "code" list and a personal stack. When a player is updated (which is all the time for audio-rate, sometimes for control-rate, and never for constants), the code is called and whatever remains on the player's stack can be accessed by other players
Currently each of these "words" (like sin, for instance) is actually a unit-generator, which can hold arbitrary data. So this sin word holds within it a variable for the phase. I am hoping this approach will let me implement words with a lot of complex behaviour without causing too much of a performance drain?
Perhaps a straightforward FORTH would be fast enough for this sort of thing, I shall ponder on it...
P.S., sndio is great! Super easy to get sounds happening, and its one of the few libraries that "just works"
Replies (2)
-
@lobo@meemu.org 2026-04-30 22:14
@pat i've enjoyed using sndio for midi input/output in the past, but never used it for actual audio 🙈
-
@pkw@snac.d34d.net 2026-04-30 22:29
The simple but modern OpenBSD sound stuff really makes a programmer want to just play around with it.