Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Sampling rate and frequency of music file (MP3) in android?

I am developing audio player in android. So i want to add the details of the playing song i.e. Artist Name, Duration, Bit rate and sampling frequency. I can get Artist Name and duration of a music file by using MediaStore.Audio.Media library. But i am unable to get Bit rate and sampling frequency of the same file. So how can i get the same?

As i know, it can be done by using native library. But don't know how? So anyone can help me on this?

like image 321
Sandy Avatar asked Feb 28 '11 09:02

Sandy


People also ask

What is the frequency of an MP3 file?

A sample rate of 44.1 kHz is commonly used for music reproduction, because this is also used for CD audio, the main source used for creating MP3 files.

How many kHz is MP3?

44.1 kHz for audio CDs and typically the de facto standard for downloaded music, including popular formats like MP3, AAC, WMA, WAV, and others. 48 and 96 kHz is used for high-definition equipment and professional audio.

What is audio sample rate in Android?

Android (usually) has a fixed native sample rate of either 44100 or 48000Hz.


1 Answers

You can approximate it by dividing the file size by the length of the audio in seconds, for instance, from a random AAC encoded M4A in my library:

File Size: 10.3MB (87013064 bits)
Length: 5:16 (316 Seconds)
Which gives: 87013064 bits / 316 seconds = 273426.147 bits/sec or ~273kbps
Actual Bitrate: 259kbps

Since most audio files have a known set of valid bitrate levels, you can use that to step the bit rate to the appropriate level for display.

like image 77
jakebasile Avatar answered Oct 11 '22 09:10

jakebasile