Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the amplitude data from an MP3 file?

Im trying to use html5 and javascript to get the amplitude (and other components) of an mp3. Any libraries that would help?

like image 914
user1011332 Avatar asked Sep 12 '12 02:09

user1011332


People also ask

How many bytes is a MP3?

One megabyte is about 1 million bytes (or about 1000 kilobytes). An MP3 audio file of a few minutes or a 10 million pixel image from a digital camera would typically take up few megabytes. The rule of thumb for MP3 audio is that 1 minute of audio takes up about 1 megabyte.

How is music quality retained in MP3?

The goal of using MP3 is to compress a CD-quality song by a factor of 10 to 14 without noticeably affecting the CD-quality sound. With MP3, a 32-megabyte song on a CD compresses down to about 3 MB. This lets you download a song much more quickly, and store hundreds of songs on your computer's hard disk.

What is MP3 data?

MP3 (MPEG-1 Audio Layer-3) is a standard technology and format for compressing a sound sequence into a very small file (about one-twelfth the size of the original file) while preserving the original level of sound quality when it is played. MP3 files (identified with the file name suffix of ".

How to decode MP3 files?

MP3 is encoded wave (+ tags and other stuff). All you need to do is decode it using MP3 decoder. Decoder will give you whole audio data you need for further processing. How to decode mp3? I am shocked there are so few available tools for Python.

How can I do frequency analysis of audio data?

I want to do frequency analysis of audio data, basically trying to figure out what the notes are in a song algorithmically. The standard approach is to decode the MP3 into PCM data and run it through an FFT. However, notes below around middle C require too much precision for an FFT to work well.

How do I convert MP3 to PCM?

The standard approach is to decode the MP3 into PCM data and run it through an FFT. However, notes below around middle C require too much precision for an FFT to work well.

How does the MP3 encoder work?

The MP3 encoder works on batches of 576 time-domain samples and converts them to 576 frequency-domain samples. That means that you get a frequency resolution of f sample 576, whatever your sampling rate is.


1 Answers

First you need to divide the problem to real-time playback and non-linear amplitude, etc. access.

For real-time playback you can use Web Audio API

https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html

Example for beats

https://beatdetektor.svn.sourceforge.net/svnroot/beatdetektor/trunk/core/js/beatdetektor.js

For non-linear, non-real-time access, there are two ways

If you allow server-side processing you can write your proxy sending the data to Echo Nest servers and retrieve information via Echo Next Remix API

Extracting beats out of MP3 music with Python

If you want to avoid server-side processing at all you need to decode the MP3 in pure Javascript to get the access to the raw audio data in non-real-time fashion

https://github.com/devongovett/mp3.js

Then you need to apply the necessary filters on the raw audio data to extract the information you need on it. This is a problem of signal processing and not directly connected to Javascript programming. If you specify more carefully what kind of data you are after people might help you with related Javascript libraries, like ones for fast fourier transform.

like image 199
Mikko Ohtamaa Avatar answered Oct 31 '22 16:10

Mikko Ohtamaa