本文整理汇总了Java中org.hermit.dsp.FFTTransformer类的典型用法代码示例。如果您正苦于以下问题:Java FFTTransformer类的具体用法?Java FFTTransformer怎么用?Java FFTTransformer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FFTTransformer类属于org.hermit.dsp包,在下文中一共展示了FFTTransformer类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runFftTest
import org.hermit.dsp.FFTTransformer; //导入依赖的package包/类
private static void runFftTest(String name, double max, int rate, float freq,
int buflen, FFTTransformer fft, float[] out)
{
// Test on a buffer of all zeroes.
short[] buf = makeSine(max, rate, freq, buflen);
fft.setInput(buf, 0, out.length * 2);
fft.transform();
fft.getResults(out);
float minv = Float.MAX_VALUE;
float maxv = Float.MIN_VALUE;
for (int i = 0; i < out.length; ++i) {
if (out[i] < minv)
minv = out[i];
if (out[i] > maxv)
maxv = out[i];
}
System.out.format("%[email protected] %5dHz %5d/s: MIN %10.5f MAX %10.5f\n", name, (int) freq, rate, minv, maxv);
}
示例2: runFftAll
import org.hermit.dsp.FFTTransformer; //导入依赖的package包/类
private static void runFftAll(int rate, float freq, int fftBlock) {
int buflen = (int) (rate * 1f);
FFTTransformer fft = new FFTTransformer(fftBlock);
float[] out = new float[fftBlock / 2];
// Test on a buffer of all zeroes.
runFftTest("Zero", 0f, rate, freq, buflen, fft, out);
// A truly miniscule signal; every 40th sample is 1, all others
// are zero.
runFftTest("Tiny", 0.5f, rate, freq, buflen, fft, out);
// A very small signal; 5 1s, 15 0s, 5 -1s, 15 0s.
runFftTest("Small", 0.55f, rate, freq, buflen, fft, out);
// Minimum "real" signal, oscillating between 1 and -1.
runFftTest("Min", 1, rate, freq, buflen, fft, out);
// A full-range sine wave, from -32768 to 32767.
runFftTest("Full", 32768, rate, freq, buflen, fft, out);
// Maximum saturated signal.
runFftTest("Sat", 10000000, rate, freq, buflen, fft, out);
}
示例3: AudioAnalyser
import org.hermit.dsp.FFTTransformer; //导入依赖的package包/类
/**
* Create a WindMeter instance.
*
* @param parent Parent surface.
*/
public AudioAnalyser(SurfaceRunner parent) {
super(parent);
parentSurface = parent;
audioReader = new AudioReader();
spectrumAnalyser = new FFTTransformer(inputBlockSize, windowFunction);
// Allocate the spectrum data.
spectrumData = new float[inputBlockSize / 2];
spectrumHist = new float[inputBlockSize / 2][historyLen];
spectrumIndex = 0;
biasRange = new float[2];
}
示例4: setBlockSize
import org.hermit.dsp.FFTTransformer; //导入依赖的package包/类
/**
* Set the input block size for this instrument.
*
* @param size The desired block size, in samples. Typical
* values would be 256, 512, or 1024. Larger block
* sizes will mean more work to analyse the spectrum.
*/
public void setBlockSize(int size) {
inputBlockSize = size;
spectrumAnalyser = new FFTTransformer(inputBlockSize, windowFunction);
// Allocate the spectrum data.
spectrumData = new float[inputBlockSize / 2];
spectrumHist = new float[inputBlockSize / 2][historyLen];
}