Analyze sound waves from an MP3 file and representation

Asked

Viewed 980 times

4

Is there any way, in Java/Android, to open an MP3 or WAV file and from the same get the sound waves constantly ? according to its reproduction ? and power from that constant return make its graphic representation ?

Example 1:Vídeo do Canal Tasty

Video with the desired goal: https://www.youtube.com/watch?v=Bamvg4Icmi0

  • This is certainly possible, but it should not be an easy thing to do.

  • I’ve been looking for some library that allows me to do this, regardless of the difficulty that it may present, my project needs this functionality, an already serious name useful even without code examples

  • I think something from here will show you the way: http://stackoverflow.com/q/2416935/540552 - Don’t focus only on the accepted answer, some of the other answers were written as criticism or suggestion for improvement or alternative due to some problems in the accepted answer.

  • I have a lib on github, then if you want to take a look: https://github.com/cleidimarviana/equalizers. but the bars move not according to the sound. Basically it’s a simulation.

2 answers

4


It already has an answer and several comments, I took a quick look at the libraries that were proposed just for curiosity, but unfortunately none of them really does what you seem to need :-(

Don’t look for equalizer an equalizer has the function of attenuating or emphasizing a specific frequency or a set of them (frequency band), you are looking for a Audio spectrum Analyzer each processed audio frame is analyzed by Transform that’s the magic.

I don’t know ready-made java libraries, I just know how to do, maybe explaining you can understand the necessary steps.

  • You will need to decode your mp3 audio, this process allows you to represent digitally sampled analog signals, that is to say you will have pure audio, you will have all values of the amplitude of the signal sampled in a certain range.
  • Concurrently you analyze each piece of audio while it also plays, usually it uses pieces of size with power of two, it simplifies and gives performance gain together with the transform of Fourier, I do not want to get into the deep mathematics, roughly the Urier transform decomposes a signal into spectral components (frequencies).
  • With the frequency representation of each sample you must plot or draw the values to achieve the effect you want.

A long time ago I did this algorithm in python to test, it actually has some details about how accurate you want the effect to be, the larger the window passed to Fourier the smaller the order of resolution of the spectral components, but of course this has a computational cost and you will need to decide a window size that is the best cost benefit for your app.

The example you showed just by looking at the graph you can see that it works very well with the low frequencies, but it has almost no interaction with the treble, look at the minute 2:05, starts a voice and the spectrum analyzer has almost no changes, it tells me that the algorithm is only demonstrating lower frequency ranges...

1

There are two libraries that can do this for you: Miniequalizer and Vumeter.

They have the same effect and if you look at their source code, you’ll see that they inherit from a View, which gives you the possibility to edit and do something similar to the video.

In case, you would have to synchronize the View with his Player.

Other alternatives: Waveinapp, Horizon

  • Thanks Luc, thank you

Browser other questions tagged

You are not signed in. Login or sign up in order to post.