how to get various sound waveforms in GDscript ? ....at least i got the Sin working!

urieluriel Posts: 59Member

Hi,
as i follow the exemple on the Demo projects:
https://github.com/godotengine/godot-demo-projects

so, from this demo, the sin waveform is generated and it is working fine, even if it takes some memory.

i am now looking for other types of shapes:
Square
Triangle
Random

i got this code for the sin:

var hz = 22050.0
var phase = 0.0
var pulse_hz = 440.0
var increment = (1.0 / (hz / pulse_hz)) 
...
playback.push_frame( Vector2(1.0,1.0) * sin(phase * (PI * 2.0)) ) # frames are stereo
phase = fmod((phase + increment), 1.0)
...

how can i obtain the square waveform ? i am not so much into mathematic.... :(


Tags :

Comments

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file