薛之谦和李雨桐分家:getFft

来源:百度文库 编辑:九乡新闻网 时间:2024/04/29 23:23:28

public int getFft (byte[] fft)

引入自:API 级别9

Returns a frequency capture of currently playing audio content.

This method must be called when the Visualizer is enabled.

The capture is an 8-bit magnitude FFT, the frequency range covered being 0 (DC) to half of the sampling rate returned by getSamplingRate(). The capture returns the real and imaginary parts of a number of frequency points equal to half of the capture size plus one.

Note: only the real part is returned for the first point (DC) and the last point (sampling frequency / 2).

The layout in the returned byte array is as follows:

  • n is the capture size returned by getCaptureSize()
  • Rfk, Ifk are respectively the real and imaginary parts of the kth frequency component
  • If Fs is the sampling frequency retuned by getSamplingRate() the kth frequency is: (k*Fs)/(n/2)
Index

 

0

 

1

 

2

 

3

 

4

 

5

 

...

 

n - 2

 

n - 1

 

Data

 

Rf0

 

Rf(n/2)

 

Rf1

 

If1

 

Rf2

 

If2

 

...

 

Rf(n-1)/2

 

If(n-1)/2

 

 

参数
fft array of bytes where the FFT should be returned
返回值
  • SUCCESS in case of success, ERROR_NO_MEMORY, ERROR_INVALID_OPERATION or ERROR_DEAD_OBJECT in case of failure.
抛出
IllegalStateException