Blog

Android waveform visualisation

By April 24, 2015 5 Comments

Recently, we have been working on an Android project in which we needed audio data visualisation. After doing some research, I found an open source project called Ringdroid, which among many other features offered great waveform visualisation. As I didn’t want to reinvent the wheel and Ringdroid perfectly suited my needs, I decided to adapt the code to our project. However, I found it to be quite memory inefficient, especially while dealing with large audio files. I spent some time analysing and refactoring code and in the result I managed to reduce memory usage by more than 50%. The major change was to completely replace the drawing algorithm. Instead of keeping cached audio values for all zoom levels, I dynamically draw waveform using input values and a scaling factor. Moreover, internal audio representation used by Ringdroid has been cleaned. There is still room for improvement, but the I released the modified code as a new project, which is called Waveform Android. To make it more reusable, the waveform visualization is extracted to a Fragment.

You can find the code here: https://github.com/Semantive/waveform-android. I prepared an example to get you started, you just need to extend WaveformFragment and provide a path to an audio file.

Key features:

  • reusable fragment
  • memory optimized
  • waveform visualisation of audio file
  • integrated player
  • 4 zoom levels
  • easy to customize

Join the discussion 5 Comments

Leave a Reply