Godot is planning to add a few new audio features to its upcoming 3.2 release.
Generate Audio
The AudioStreamGenerator is a new type of AudioStream that can be put in the regular stream players. Its purpose is to allow developers to programmatically generate and push stereo audio frames via buffers. For example:
func _fill_buffer():
var increment = (1.0 / (hz / pulse_hz))
var to_fill = playback.get_frames_available()
while (to_fill > 0):
playback.push_frame( Vector2(1.0,1.0) * sin(phase * (PI * 2.0))
phase = fmod((phase + increment), 1.0)
to_fill-=1;
Spectrum Analyzer
A new spectrum analyzer effect is also being added. This allows you to retrieve frequency range magnitudes, which can then be used for visualization or other purposes. Here's a short video demonstrating the effect:
View the sample code for these features in the Godot demo repository.