Closed ciarandg closed 4 years ago
Can you provides some links on the AudioStreamGenerator stuff?
Sure, basically an AudioStreamPlayer node containing an AudioStreamGenerator can pass signal values to the audio engine using push_frame(Vector2)
. Here's a very simple demo project that implements a 440Hz sin oscillator:
https://github.com/godotengine/godot-demo-projects/tree/master/audio/generator
Here's the main audio page in the docs (mostly deals with .wav and .ogg files, I haven't found it particularly useful): https://docs.godotengine.org/en/stable/tutorials/audio/index.html
AudioStreamPlayer and AudioStreamGenerator have their own pages in the API docs: https://docs.godotengine.org/en/stable/classes/class_audiostreamplayer.html https://docs.godotengine.org/en/stable/classes/class_audiostreamgenerator.html
Here's a basic sprite tween demo (sinusoidal) that fetches tween values from a C++ module: https://github.com/GodotNativeTools/GDNative-demos/tree/master/cpp/SimpleDemo
Hopefully that helps!
Edit: note that the 2D vector in push_frame(Vector2)
contains the values for a stereo signal
It seems the last way (using a C++ module) is the only reasonable way. But in this simple example it is not clear how a audio processing node could be developed. Any more info on that?
Looks like I gave you the wrong demo for C++ submodules, here's the tweening one I meant to send (made by following this tutorial https://docs.godotengine.org/en/stable/tutorials/plugins/gdnative/gdnative-cpp-example.html) https://github.com/ciarandeg/gdnative-demo. Sorry about that.
As for making an audio processing node, I think the way you'd have to do it is to attach a .gdns script to an AudioStreamPlayer node and have that script pass the Faust patch's output values to its push_frame(vec2)
function. In the tween example, gdexample.cpp directly calls the sprite's set_position(Vector2)
function, so I figure it should be possible. Maybe that's clunky, though
Just spent some time playing around with audio stuff natively in Godot and I should have realized that GDScript is way too slow to be worthwhile for this in the first place. Going to just try writing my DSP code in C# so I can run it asynchronously instead. Closing the thread, thanks for the help
If C# is fast enough, then adding a new C# backend in the compiler could be a solution. But this is obviously a much more ambitious project. But anyway I'm interested to know if your "DSP code in C#" is a viable solution.
Thanks, and thank you for helping! I'm in way over my head honestly but fingers crossed
I'm trying to figure out some way to integrate Faust with Godot for game development. Godot supports C++ modules (using GDNative), so I figure there must be some way to pass signal values from a Faust program into an AudioStreamGenerator, but I can't figure out how to package it properly to do so. Any help would be greatly appreciated.