0 votes

does anyone know how to draw a waveform like the one in the inspector when double clicking an audio file in the file system dock?

asked Aug 10, 2019 in Engine by Adam_S (1,229 points)

There doesn't seem to be any property or function to get that information... maybe you should do a feature request.

2 Answers

+1 vote
Best answer

Unfortunately, I don't have the answer to your question :-(

However, here are some clues. I need a waveform too in my project, and I'm using ffmpeg for that, with OS.execute()

OS.execute("./ffmpeg/ffmpeg.exe", ["-i", audio.ogg, "-filter_complex", "compand=gain=-6,showwavespic=s=1280x240:colors=blue,drawbox=x=(iw-w)/2:y=(ih-h)/2:w=iw:h=1:replace=1:color=blue-frames:v", "1", waveform.png, "-y"], true)
It might seem obscure, but here is the doc for that
It generates a png image that I scale afterward.Not the best solution, but it fits my needs.

If you want to know how they did it in Godot, here are useful links in the source code:

I'm not really good in audio technology, nor C++, so I have difficulties analysing that code, but you might find it intersting ;-)

answered Oct 10, 2019 by Matt_UV (274 points)
selected Jan 12 by Adam_S
0 votes

hi adam_s, did you found the way to get the waveform ?

answered Sep 27, 2019 by uriel (107 points)

Hey Uriel, unfortunately not.

What I do at the moment, is play the sample, get the bus peak volume and append it to an array.
Then I use this array with the draw_line() function to draw something like a waveform.

However, the result is not as accurate as I would like.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.