0 votes

Hi,
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?

in Engine by (1,451 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

Hi!
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 ;-)

by (275 points)
selected by
0 votes

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

by (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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.