Note that there are some explanatory texts on larger screens.

plurals
  1. POBad Spectrum from Android's FFT-Output (Visualiser)?
    primarykey
    data
    text
    <p>I have some Kind of Question about FFT (Actually I believe it's more about Androids FFT-Output from Visualizer.getFFT()).</p> <p>I have created a Music-Player with own Library function for Android including lot's of Stuff (like genres, dynamic playlists and visualisations). Currently I have some trouble with the Visualisations I create when it comes to render a Spectrum of the current AudioStream.</p> <p>I already read the following Questions (and Answers) to get an Idea of Androids FFT:</p> <p><a href="https://stackoverflow.com/questions/4779287/what-kind-of-output-should-i-see-from-getfft">What kind of output should I see from getFft?</a></p> <p><a href="https://stackoverflow.com/questions/4720512/android-2-3-visualizer-trouble-understanding-getfft">Android 2.3 Visualizer - Trouble understanding getFft()</a></p> <p>Now to my Problem: The Spectrum I get from getFFTs coefficients seems to be somewhat "odd". I notice that the spectrum I render seems to display a lot of "noise" when playing a song so I tried using some test-sounds. One of them is a simple 8khz sound which should result in only one peak in the graph. Unfortunately the result looks like the following:</p> <p><a href="http://img4.imageshack.us/img4/4181/spectrum8khz.png" rel="nofollow noreferrer">http://img4.imageshack.us/img4/4181/spectrum8khz.png</a></p> <p>The noise appearing at the bottom is flickering all over the width of the graph. The high bars stay in position only flickering slightly in magnitude.</p> <p>When I use a test-sound moving slowly from 1kHz to 20kHz it looks like the following (at about 2-3kHz):</p> <p><a href="http://img846.imageshack.us/img846/7373/spectrum3khz1khz20khz.png" rel="nofollow noreferrer">http://img846.imageshack.us/img846/7373/spectrum3khz1khz20khz.png</a></p> <p>The peaks move from left to right and each one is a little faster so over time the distance between the peaks grows. What is not visible is that the peaks come back and go from right to left once they leave the screen on the right (but with smaller magnitude). Also all the peaks join to one big peak at a little more than 0.5 of the screen.</p> <p>Here is the code I use to retrieve the Data:</p> <pre><code>for (int i = 1; i &lt; n / 2; i++) { byte rfk = mRawSpecData[2*i]; byte ifk = mRawSpecData[2*i+1]; float magnitude = (float)Math.sqrt(rfk * rfk + ifk * ifk); mFormattedSpecData[i-1] = magnitude / 128f; } </code></pre> <p>In the code above I mRawSpecData is the result of the Visualisers getFFT() function. The length of the captured Data is 1024. Currently the slope starts at 1 because mRawSpecData[ 0 ] contains the DC and mRawSpecData[ 1 ] contains n/2.</p> <p>To solve my problem I also tried to fiddle around with DC and phase of the frequency-bin. Thought maybe I had to apply some computation on the magnitudes to "clean" the graph. But I didn't succeed (Maybe because I didn't get what is goind on with DC/phase at all!).</p> <p>I spent two weeks searching google at the evenings and trying different computations but nothing really helped.</p> <p>So what is the deal? Am I doing something wrong or leaving something out? After that another question which bothers me is how to scale the magnitudes correctly. My goal is to get values between 0f and 1f.</p> <p>Thanks a lot</p> <p>rampage</p> <p>P.S.: Screenshots where taken via eclipse from a phone running Android 2.3.</p> <p>P.P.S.: I also checked the sounds with various other players (like winamp) and there i see the correct behaviour of the spectrum.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload