|
|
|
|
|
by michae2
2177 days ago
|
|
I read this article for the first time a few months ago while creating a rudimentary sound engine. The article makes a lot of sense, but I struggled to map the concepts to sound generation. I initially tried to replace the render step from the article (rendering a single display frame) with rendering a single fragment of sound buffer (called a period in ALSA, the unit of transfer to the sound card). My first mistake was ignoring the interpolation part of the article. The output was very choppy whenever the sound card transfers were too coarse. And then I learned that I can ask the sound card how much sound buffer it wants, instead of always transferring a fixed amount. In other words, the rate of the main loop did not need to match the rate of transfers to the sound card. Now I've rewritten the main loop as a series of inner loops, first running a variable amount of simulation at simulation rate, then rendering a variable amount of sound buffer at output sample rate (not fragment transfer rate, like I was doing before). This seems to be working better. I still need to think about the spiral of death. Perhaps an upper limit on simulation would be enough? (Any advice welcome!) |
|