Question

I'm currently developing an android app and need to be able to render a Waveform of an audio file. I already read about the Visualizer class, but I think that class is designed to do realtime calculation. What I want to do is go trough an audio file and generate for example an .PNG that contains a waveform of the whole audio file.

Basically something like soundcloud does: http://www.djban.com.br/wp-content/uploads/soundcloud-waveform.png

Are there any libraries that can do this? Or can you tell me how I can get an array of amplitudes of an audio file?

Was it helpful?

Solution

I don't know of any library but it should be easy to get it working.

First, in order to get the Amplitude of the wave form, you will need the audio in PCM format. Assuming that you need the waveform for arbitrary audio files (mp3 in particular), you will need to find a way to convert between formats. A quick google search gives this result. NOTE: if you just need to do it for audio coming from the microphone, you can avoid the conversion since it delivers audio data in the PCM format.

After getting the samples, you will need to draw their amplitudes somehow. You have several options, but I would give the Canvas a try. You can draw lines (or general shapes) there and then export it to a file or draw it on the screen.

Another option to draw is OpenGL. This is more complicated if you haven't use it before, but it will be probably faster.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top