This doesn't give quite the right result, but the code below prints the audio waveform of a AudioStreamOGGVorbis
file:
extends Node2D
export (AudioStreamOGGVorbis) var audio_stream;
func _ready():
update();
func _draw():
for i in range(0, len(audio_stream.data)):
var horizontal_offset = Vector2(i * 0.05, 0);
draw_line(Vector2.ZERO + horizontal_offset, Vector2(0, -audio_stream.data[i] / audio_stream.get_length()) + horizontal_offset, Color.green, 0.01);
With some edits, you might be able to get it drawing correctly and like the audio preview in the Godot editor. The code above doesn't give the same result, though I'm wondering if the issue is post-processing and/or positioning.
Maybe with something like the code above and the C++ code, you can generate audio waveforms like those seen in the Godot editor. It might be something worth messing around with if you want to go the GDScript route.