Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
350 views
in Technique[技术] by (71.8m points)

signal processing - Android 2.3 Visualizer - Trouble understanding getFft()

First time here so sorry in advance for any butchered formatting.

So I am completely new to DSP so I have only a very general understanding of the Fourier Transform. I am trying to build a visualizer app for Android SDK 9, which includes a Visualizer class in android.media.audiofx.Visualizer http://developer.android.com/reference/android/media/audiofx/Visualizer.html

The javadoc for the method getFft(), which is what I am using states:

"Returns a frequency capture of currently playing audio content. The capture is a 8-bit magnitude FFT. Note that the size of the FFT is half of the specified capture size but both sides of the spectrum are returned yielding in a number of bytes equal to the capture size."

First of all, what does "both sides of the spectrum" mean? How does this output differ from a standard FFT?

Here is some sample output of the byte array, getFft() was given 124 points to keep it simple and I grabbed the first 31 bins. Here are the magnitudes of the first 31 bins:

{123, -2, -23, -3, 6, -16, 15, -10, -8, -12, 9, -9, 17, -6, -18, -22, -8, 4, -5, -2, 10, -3, -11, 3, -4, -11, -8, 15, 16, 11, -12, 12}

Any help or explanation would be greatly appreciated!

Edit: So after staring at a bunch of graphs it looks like part of my problem is Google does not specify what unit is being used. Almost all other measurements are done in mHz, would it be fair to assume that the FTT output is also in mHz? Is there a place where I can see the source code of the Visualizer class so maybe I can figure out what the hell is actually going on under the hood?

I went ahead and grabbed all of the output of getFft()

93, -2, -28, -16, -21, 19, 44, -16, 3, 16, -9, -4, 0, -2, 21, 16, -3, 1, 2, 4, -3, 5, 5, 10, 6, 4, -9, 7, -2, -1, 2, 11, -1, 5, -8, -2, -1, 4, -5, 5, 1, 3, -6, -1, -5, 0, 0, 0, -3, 5, -4, -6, -2, -2, -1, 2, -3, 0, 1, -3, -4, -3, 1, 1, 0, -2, -1, -1, 0, -5, 0, 4, -1, 1, 1, -1, 1, -1, -3, 2, 1, 2, -2, 1, 0, -1, -2, 2, -3, 4, -2, -2, 0, 1, -4, 0, -4, 2, -1, 0, -3, -1, -1, -1, -5, 2, -2, -2, 0, -3, -2, 1, -5, -2, 0, 0, 0, -2, -2, -1, -1, -1, -2, 0, 3, -3, -1, 0

So if I understand this correctly, my output here should be from -N to 0 to N. -N to 0 should look just like 0 to N. But when I look at these amplitudes, I don't see any mirrored data. Google seems to indicate that the output should be from 0 to N just on both sides of the spectrum. So I should be able to take the data from (output.length-1)/2 to output.length-1. The negative amplitudes are moving faster than the sample rate and the positive amplitudes are moving slower than the sample rate. Did I understand this correctly?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In case it helps anyone, I've created a Visualizer which takes the output from the MediaPlayer and displays a visualization. It works with both normal waveform and FFT data:

https://github.com/felixpalmer/android-visualizer

It includes code for converting the output of getFft() into something visually meaningful.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...