10-12-2022, 10:39 PM
(10-12-2022, 09:54 PM)a740g Wrote:(10-12-2022, 09:04 PM)james2464 Wrote: If you were making a game and wanted to repeat this overall routine, would you just repeat the routine or try to capture it into a sound file and just use that? Hope I'm making sense. Just curious what a good strategy would be.
I think I get what you are saying. Well, there are multiple ways to do this.
You can do it with static sounds and then programmatically change the sound parameters on-the-fly like you are doing in the example. This obviously is not too flexible and does not allow you to do advanced effects. You'll be limited to position, volume, and panning effects.
You could also programmatically generate the sound waveform yourself and play it using SNDRAW. This allows you to do very advanced audio effects. However, it requires you to "run" your sound generating code that is pushing the samples to SNDRAW whenever you want to play the sound. This may be processor intensive (especially on low spec. hardware).
A third way would be to generate the waveform once and store it in a buffer and then play the buffer whenever needed. QB64-PE does not have this functionality yet. However, it is planned. See We need some kind of _NEWSND function to make sound buffers · Issue #28 · QB64-Phoenix-Edition/QB64pe (github.com)
Thanks!
That _NEWSND feature would be absolutely incredible. No pressure!