Creating a Waveform from Microphone Input in real time

Godot Version

4.3 dev6 here.


How can I create a waveform like in the attached photo, in real time from microphone input?


I currently have microphone recording working, as per the Mic Record Demo Project. In that demo, the file is recorded, then the recording is gotten via recording = effect.get_recording() and so on. I can print the (very large) array from recording.get_data() as well as play back the recording.

However I don’t think this would work for real time waveform creation. I don’t think that get_data() can be called in the process function efficiently.

In the documentation, there is AudioEffectCapture, which has information about getting buffers and frames, but not how to use them.

I also know that I would be drawing to a TextureRect, and updating it in process, but not sure how to start drawing something like that programmaticaly.

It is my first time trying to do something not in tutorials, and any hints would be appreciated.

To slightly clarify, the picture attached is also a waveform I generated, by using a module found here: GitHub - v-pukman-gd/godot-audio-waveform-module: Custom module for Godot Engine to draw audio waveforms

The module exposes the native waveform creation class that you can see when importing audio files. Very cool btw.

However this waveform is generated from a file before being shown, not in real time.

If there was a way to use this to generate the waveform from real time mic data, that would be great, but I don’t think you can?

Another update (I am trying my best too!)

I was linked to this audio - How to get current Microphone Frequency in Godot - Game Development Stack Exchange
old thread in a stackoverflow like forum.

While close, this post seems to be talking about spectral analysis (tones, like A B C D# etc)

I am merely interested in drawing the waveform one frame at a time, which would be volume (loudness) levels?

I will continue looking for an answer, and hopefully if I ever find one (my entire game depends on this) I will of course share it here.