.mp3 to song waveform

Locked
silverking
User
Posts: 3
Joined: Mon Oct 15, 2012 2:22 pm
Are you a spambot?: no

.mp3 to song waveform

Post by silverking » Mon Oct 15, 2012 2:33 pm

It is possible to generate song waveform from .mp3, below is sample image

Image

Thanks in advanced.

James Heinrich
getID3() v1 developer
Posts: 1457
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Re: .mp3 to song waveform

Post by James Heinrich » Mon Oct 15, 2012 2:43 pm

From uncompressed PCM data (e.g. most WAV files) it wouldn't be too difficult: once you know the bit size of each sample and the interleaving arrangement of channels just walk through the file and graph the amplitude of each sample (averaging or dropping channels as you deem easiest or most appropriate. You'd likely want some kind of temporal averaging rather than graphing each sample.

For compressed audio (mp3, etc) you'd need to decode the audio stream to PCM data before doing the above. This is likely non-trivial.

silverking
User
Posts: 3
Joined: Mon Oct 15, 2012 2:22 pm
Are you a spambot?: no

Re: .mp3 to song waveform

Post by silverking » Mon Oct 15, 2012 2:48 pm

Hi James Heinrich,

Thanks for quick reply.
It is too theoretical for me. If is possible to you or some one else to share sample code for above same.

silverking
User
Posts: 3
Joined: Mon Oct 15, 2012 2:22 pm
Are you a spambot?: no

How to convert .mp3 to .wav

Post by silverking » Mon Oct 15, 2012 3:03 pm

Need sample code to convert .mp3 file into .wav

thanks in advanced.

James Heinrich
getID3() v1 developer
Posts: 1457
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Re: .mp3 to song waveform

Post by James Heinrich » Mon Oct 15, 2012 3:23 pm

If you didn't understand what I was describing above, then most likely you'll need someone to write the code for you. getID3 doesn't have anything built-in that would do anything like that. At best you could use it to obtain the required info for a PCM file (data offset, sample size, channel arrangement). Decoding compressed audio is completely beyond the scope of getID3.

James Heinrich
getID3() v1 developer
Posts: 1457
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Re: How to convert .mp3 to .wav

Post by James Heinrich » Mon Oct 15, 2012 3:28 pm

silverking wrote:Need sample code to convert .mp3 file into .wav

Code: Select all

exec('lame --decode '.escapeshellarg($inputMP3filename).' '.escapeshellarg($outputWAVfilename));

Locked