• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java FastFourierTransformer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.commons.math.transform.FastFourierTransformer的典型用法代码示例。如果您正苦于以下问题:Java FastFourierTransformer类的具体用法?Java FastFourierTransformer怎么用?Java FastFourierTransformer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FastFourierTransformer类属于org.apache.commons.math.transform包,在下文中一共展示了FastFourierTransformer类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: transform

import org.apache.commons.math.transform.FastFourierTransformer; //导入依赖的package包/类
@Override
public Double[] transform(Double value) {
	window.transform(value);		
	double[] valuesArray = new double[window.size()] ;
	int i = 0;
	for (Double v: window.values()) {
		valuesArray[i++] = v;
	}
				
	Complex[] complexFFTResult = new FastFourierTransformer().transform(valuesArray);
	// only the first half of the FFT is reasonable, the other half is just a mirror of the first
	int resultLength = (complexFFTResult.length / 2) + 1;
	Double[] fftResult = new Double[resultLength];		
	for (i = 0; i < resultLength; i++) {
		fftResult[i] = complexFFTResult[i].abs()/origSize;
	}
	return fftResult;
}
 
开发者ID:markus1978,项目名称:clickwatch,代码行数:19,代码来源:MovingFFT.java


示例2: testDoubleValues

import org.apache.commons.math.transform.FastFourierTransformer; //导入依赖的package包/类
public void testDoubleValues(String title, Transformer<Double, double[]> tr) {
    FastFourierTransformer apache = new FastFourierTransformer();
    CLQueue queue = tr.getContext() == null ? null : tr.getContext().createDefaultOutOfOrderQueueIfPossible();
    for (double[] data : createTestDoubleInputs()) {
        double[] expected = complexToInterleavedDoubles(apache.transform(interleavedDoublesToComplex(data)));
        assertArrayEquals(title + " (n = " + (data.length / 2) + ")", expected, tr.transform(queue, data, false), precisionDouble);
    }
}
 
开发者ID:nativelibs4java,项目名称:JavaCL,代码行数:9,代码来源:DiscreteFourierTransformTest.java


示例3: testFloatValues

import org.apache.commons.math.transform.FastFourierTransformer; //导入依赖的package包/类
public void testFloatValues(String title, Transformer<Float, float[]> tr) {
    FastFourierTransformer apache = new FastFourierTransformer();
    CLQueue queue = tr.getContext() == null ? null : tr.getContext().createDefaultOutOfOrderQueueIfPossible();
    for (double[] data : createTestDoubleInputs()) {
        float[] dataf = toFloat(data);
        double[] expected = complexToInterleavedDoubles(apache.transform(interleavedDoublesToComplex(data)));
        assertArrayEquals(title + " (n = " + (data.length / 2) + ")", toFloat(expected), tr.transform(queue, dataf, false), precisionFloat);
    }
}
 
开发者ID:nativelibs4java,项目名称:JavaCL,代码行数:10,代码来源:DiscreteFourierTransformTest.java


示例4: MelFrequencyCC

import org.apache.commons.math.transform.FastFourierTransformer; //导入依赖的package包/类
/**
 * Default constructor. Leaves object ready for processing whole audio
 * samples with {@link #processAll(double)} or single windows with
 * {@link #processWindow(double)}. Window size must be larger than 32 and a
 * power of two.
 * 
 * @param sampleRate
 * @param windowSize
 * @param numberCoefficients
 * @param minFreq
 * @param maxFreq
 * @param numberFilters
 */
public MelFrequencyCC(int sampleRate, int windowSize,
		int numberCoefficients, int minFreq, int maxFreq, int numberFilters) {
	this.sampleRate = sampleRate;
	this.windowSize = windowSize;
	this.numberCoefficients = numberCoefficients;
	this.minFreq = minFreq;
	this.maxFreq = maxFreq;
	this.numberFilters = numberFilters;

	if (numberCoefficients != numberFilters) {
		throw new IllegalArgumentException(
				"number of mel coefficients must be equal to number of mel filters");
	}

	// derived stuff
	hopSize = windowSize / 2;
	// frequency resolution, one element of the
	// fft will correspond to this many hertz (?)
	baseFreq = sampleRate / windowSize;
	
	buffer = new double[windowSize];

	filterBank = new MelFilterBank(sampleRate, windowSize, minFreq,
			maxFreq, numberFilters);

	fft = new FastFourierTransformer();
	dct = new FastCosineTransformer();

	// experimental: use matrix for DCT operation
	dctMatrix = createDCTMatrix();
}
 
开发者ID:mobilesec,项目名称:auth-client-demo-module-voice,代码行数:45,代码来源:MelFrequencyCC.java


示例5: inverseFFT

import org.apache.commons.math.transform.FastFourierTransformer; //导入依赖的package包/类
/**
 * Calculates the inverse FFT of the frequency domain representation
 * of the signal. That is: converts the given data from frequency domain
 * to the time domain.
 * @param fft the frequency domain representation of the signal
 * (e.g. the output of the {@link FourierTransform#forwardFFT(double[])}
 * @return the time domain representation of the signal
 */
public double[] inverseFFT(Complex[] fft) {
	FastFourierTransformer transformer = new FastFourierTransformer();
	Complex[] complexSignal = transformer.inversetransform(fft);

	double[] signal = new double[complexSignal.length];
	for (int i = 0; i < complexSignal.length; i++) {
		signal[i] = complexSignal[i].getReal();
	}
	return signal;
}
 
开发者ID:BrainTech,项目名称:svarog,代码行数:19,代码来源:FourierTransform.java


示例6: init

import org.apache.commons.math.transform.FastFourierTransformer; //导入依赖的package包/类
public boolean init() {
	try {
		fft_size = getPredicateValueAsIntWithException("window-size");
		fft = new FastFourierTransformer () ;
		if (! FastFourierTransformer.isPowerOf2(fft_size)) {
			logger.error("The window size >" + fft_size + "< is not a power of 2.");
			return false;
		}
	}catch (Exception e) {
		logger.error(e.getMessage(),e);
		return false;
	}
	return true;
}
 
开发者ID:LSIR,项目名称:gsn,代码行数:15,代码来源:FFTRealOneSided.java


示例7: inverseFFT

import org.apache.commons.math.transform.FastFourierTransformer; //导入依赖的package包/类
/**
    * Calculates the inverse FFT of the frequency domain representation of the
    * signal. That is: converts the given data from frequency domain to the
    * time domain.
    * 
    * @param fft the frequency domain representation of the signal (e.g. the
    *        output of the {@link FourierTransform#forwardFFT(double[])}
    * @return the time domain representation of the signal
    */
   public double[] inverseFFT(Complex[] fft) {
FastFourierTransformer transformer = new FastFourierTransformer();
Complex[] complexSignal = transformer.inversetransform(fft);

double[] signal = new double[complexSignal.length];
for (int i = 0; i < complexSignal.length; i++) {
    signal[i] = complexSignal[i].getReal();
}
return signal;
   }
 
开发者ID:piotr-szachewicz,项目名称:iir-filter-designer,代码行数:20,代码来源:FourierTransform.java


示例8: compute

import org.apache.commons.math.transform.FastFourierTransformer; //导入依赖的package包/类
@Override
protected ImageResult compute(PreferencesWithAxes<PreferencesForSTFT> preferences, AsyncStatus status) throws Exception {
	final PreferencesForSTFT prefs = preferences.prefs;
	final ImageResult result = new ImageResult(preferences.width, preferences.height, "Averaged Short-Time Fourier Transform");
	final FastFourierTransformer fft = new FastFourierTransformer();

	double paddedLengthMin = prefs.windowLength;
	if (prefs.padToHeight) {
		paddedLengthMin = Math.max(
			paddedLengthMin,
			calculatePaddedHeight(preferences.height, preferences.yMin, preferences.yMax, signal.getSamplingFrequency())
		);
	}
	int paddedLength = 2;
	while (paddedLength < paddedLengthMin) {
		paddedLength *= 2;
	}
	WindowFunction wf = new WindowFunction(prefs.windowType, prefs.windowType.getParameterDefault());

	double[] chunk = new double[prefs.windowLength];
	double[] padded = new double[paddedLength];
	for (int ix=0; ix<preferences.width; ++ix) {
		if (status.isCancelled()) {
			return null;
		}
		status.setProgress(ix / (double) preferences.width);

		double t0 = preferences.xMin + (preferences.xMax - preferences.xMin) * ix / (preferences.width - 1);
		result.t[ix] = t0;
		int n0 = (int) Math.round(t0 * sampling);
		Arrays.fill(chunk, 0.0);
		signal.getSamples(n0 - prefs.windowLength / 2, prefs.windowLength, chunk);
		double[] windowed = wf.applyWindow(chunk);
		System.arraycopy(windowed, 0, padded, 0, prefs.windowLength);
		Complex[] spectrum = fft.transform(padded);
		for (int iy=0; iy<preferences.height; ++iy) {
			double fIdeal = preferences.yMin + (preferences.yMax - preferences.yMin) * iy / (preferences.height - 1);
			int i = (int) Math.round(spectrum.length * fIdeal / sampling);
			double fExact = i * sampling / spectrum.length;
			result.f[iy] = fExact;
			// phase difference between start and center of time window
			Complex phaser = new Complex(0, Math.PI*result.f[iy]*prefs.windowLength/sampling).exp().multiply(2.0);
			Complex value = (i >= 0 && i < paddedLength) ? spectrum[i].multiply(phaser) : Complex.ZERO;
			result.values[ix][iy] = value;
		}
	}
	return result;
}
 
开发者ID:BrainTech,项目名称:svarog,代码行数:49,代码来源:ImageRendererForSTFT.java


示例9: forwardFFT

import org.apache.commons.math.transform.FastFourierTransformer; //导入依赖的package包/类
/**
 * Calculates the FFT of the given signal.
 *
 * If a {@link WindowType} was specified while calling a constructor
 * it is applied to the signal before processing.
 *
 * If the signal's length is not a power of 2 (which is required by the
 * FFT algorithm) this function automatically pads it with zeros.
 *
 * @param signal the signal for which the FFT should be calculated
 * @return the result of the FFT
 */
public Complex[] forwardFFT(double[] signal) {
	FastFourierTransformer transformer = new FastFourierTransformer();
	double[] windowedSignal = windowFunction.applyWindow(signal);
	double[] paddedSignal = padWithZeroIfNecessary(windowedSignal);
	return transformer.transform(paddedSignal);

}
 
开发者ID:BrainTech,项目名称:svarog,代码行数:20,代码来源:FourierTransform.java


示例10: forwardFFT

import org.apache.commons.math.transform.FastFourierTransformer; //导入依赖的package包/类
/**
    * Calculates the FFT of the given signal.
    *
    * If a {@link WindowType} was specified while calling a constructor it is
    * applied to the signal before processing.
    *
    * If the signal's length is not a power of 2 (which is required by the FFT
    * algorithm) this function automatically pads it with zeros.
    *
    * @param signal the signal for which the FFT should be calculated
    * @return the result of the FFT
    */
   public Complex[] forwardFFT(double[] signal) {
FastFourierTransformer transformer = new FastFourierTransformer();
double[] windowedSignal = windowFunction.applyWindow(signal);
double[] paddedSignal = padWithZeroIfNecessary(windowedSignal);
return transformer.transform(paddedSignal);

   }
 
开发者ID:piotr-szachewicz,项目名称:iir-filter-designer,代码行数:20,代码来源:FourierTransform.java



注:本文中的org.apache.commons.math.transform.FastFourierTransformer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BaseCallback类代码示例发布时间:2022-05-22
下一篇:
Java GraphConnection类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap