Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visualization of MP3 - PHP

Tags:

php

api

mp3

I'm trying to build an mp3 player for my site using JavaScript (and any plugins/frameworks(jQuery)/libraries that are relevant) & html5. So I built the player (more accurately, I implemented jPlayer), and now I want to make a visualizer.

Ok maybe it's not a visualizer (all the names for ways to visualize sound always confused me), I guess what I want is something like this (Update: I just found out this is called a waveform):

wavelenghth
(source: anthonymattox.com)

Or just something that graphs the amplitude (loudness) of an MP3.

I've been told I can't do that with javascript.

So does anyone know how to do it with php?

More accurately, does anyone know how to graph the loudness/amplitude of an MP3 using PHP? I know that once I get the loudness I can make a graph using GD or the Google graphs image API.

Any API's, ideas, frameworks will all be much appreciated!

like image 875
Tomas Reimers Avatar asked Nov 04 '22 18:11

Tomas Reimers


1 Answers

Are you adverse to using PHP to call out to command line tools on the system? If not, then I would suggest using mpg123 to convert the mp3 temporarily to .wav, and then a utility called wav2png.py to generate the waveform as a .png image.

This is going to be slow, memory-hungry, and disk-hungry, since it requires conversion to .wav first.

exec("mpg123 -w outfile.wav infile.mp3");

// Not sure of the syntax for wav2png...
exec("wav2png.py outfile.wav");

Disclaimer: I have no experience with wave2png.py, and am merely aware of its existence.

like image 113
Michael Berkowski Avatar answered Nov 15 '22 05:11

Michael Berkowski