Add _audio_process() callback, before every audio buffer refill #12151
eefano
started this conversation in
Engine Core
Replies: 1 comment
-
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm working on a "Soundchip" emulator in GDScript, using AudioStreamSynchronized with looping single-period waveforms contained in multiple AudioStreamWAVs. The music evolves dynamically, at 60hz rate, by multiplexing the waveforms and changing stream volumes and pitches accordingly (approximating adsr envelopes, glissando, vibrato, tremolo, etc).
The Problem: changing AudioStreamPlayer parameters (i.e. volume_linear) inside the _physics_process is not precise, because it seems that the change is not applied "istantaneously" on the next available sample, but only when the next internal audio buffer gets refilled.
I could change the latency (buffer size) accordingly, but in order to obtain 60hz audio refresh rate, the latency setting should be 16.666666666 and only integer values are allowed in that setting. I will never get the timing perfectly in sync.
I'm suggesting to implement an _audio_process() callback (coming from the audio thread), that fires every time the audio buffer has to be refilled, before the internal mixing phase. So that the changes applied in the audio streams can be perfectly timed, at least on the buffer size boundary.
Beta Was this translation helpful? Give feedback.
All reactions