I'm developing an Android application in which I need to create a graph of spectrogram (which is a visual representation of the spectrum of frequencies in a sound as they vary with time). I had an audio file and use FFT to have signal in frequency domain,now I need to draw spectrogram graph. I need an API that help me to draw this chart looks like similar charts in Matlab.Any suggestion?
-
2Do you just want help with charting? Decomposing the sound file into PCM samples? Performing an FFT transform of said samples so that they can be graphed? WHAT HAVE YOU TRIED? – selbie Aug 28 '14 at 06:21
-
Yes I just want help with charting, I did the rest that was record voice to .pcm file and use FFT.Now I just want help to draw spectrogram graph – sandra Aug 28 '14 at 06:33
-
A quick search turned up jzy3d, which looks like it might have what you are looking for. – SleuthEye Aug 28 '14 at 12:49
2 Answers
Declare an empty <View>
element in your layout of appropriate size and fit for what you want to show. Given it an id of myview
.
Implement your own class that dervies from View and override onDraw(Canvas canvas)
. Let's name this class MyView. Add whatever methods to this class so it can have the data passed to it (i.e. the result of the FFT).
In your onCreate method of your Activity, call findViewById(R.id.myview).setContentView(new MyView());
Implement MyView.onDraw() such that you draw your data visualization on the canvas. Call the invalidate
method on your view class to force it redraw if the data changes.
As for what to draw, that's up to you. I imagine a bunch of rectangles or lines for each each frequency band. One color for the "real" and another for the "imaginary".

- 100,020
- 15
- 103
- 173
-
Are you sure that there is no API to use for drawing spectrogram graph in android? – sandra Aug 28 '14 at 09:36
-
I don't know of anything in the core Android SDK libraries that draws spectrograms graphs. That would be a very specialized class library for an SDK that is designed to be a platform for all apps. You may want to look for 3rd party libraries if you don't want to render it yourself. – selbie Aug 28 '14 at 22:38
If you are looking for android library that would help you to draw spectrogram, provided you have the data points after you do the FFT of the audio signal, you should look into the below libraries

- 4,723
- 2
- 24
- 35