How to generate waveform from audio file?
Waveform images done the easy way
In this example we are going to use a free REST API:<?php
$url = 'http://my_server.com/song.mp3'; //you can also send m4a, flac, wav and wma
$data = json_decode(file_get_contents('http://api.rest7.com/v1/sound_waveform.php?url=' . $url));
if (@$data->success !== 1)
{
echo('Failed');
}
else
{
$image = file_get_contents($data->file);
file_put_contents('waveform.png', $image);
}
The script will generate for a 4 minute song something similar to this image:
The background is transparent and only color used is black (for the waveform).
Comments