当前位置: 首页>>代码示例>>Java>>正文


Java FFT类代码示例

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


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

示例1: getMagnitudes

import com.sun.media.sound.FFT; //导入依赖的package包/类
/**
 * Get the frequency intensities
 * 
 * @param amplitudes
 *            amplitudes of the signal
 * @return intensities of each frequency unit: mag[frequency_unit]=intensity
 */
public double[] getMagnitudes(double[] amplitudes) {

    int sampleSize = amplitudes.length;

    // call the fft and transform the complex numbers
    FFT fft = new FFT(sampleSize / 2, -1);
    fft.transform(amplitudes);
    // end call the fft and transform the complex numbers

    // even indexes (0,2,4,6,...) are real parts
    // odd indexes (1,3,5,7,...) are img parts
    int indexSize = sampleSize / 2;

    // FFT produces a transformed pair of arrays where the first half of the
    // values represent positive frequency components and the second half
    // represents negative frequency components.
    // we omit the negative ones
    int positiveSize = indexSize / 2;

    double[] mag = new double[positiveSize];
    for (int i = 0; i < indexSize; i += 2) {
        mag[i / 2] = Math.sqrt(amplitudes[i] * amplitudes[i] + amplitudes[i + 1] * amplitudes[i + 1]);
    }

    return mag;
}
 
开发者ID:deeplearning4j,项目名称:DataVec,代码行数:34,代码来源:FastFourierTransform.java

示例2: getMagnitudes

import com.sun.media.sound.FFT; //导入依赖的package包/类
/**
 * Get the frequency intensities
 * 
 * @param amplitudes
 *            amplitudes of the signal
 * @return intensities of each frequency unit: mag[frequency_unit]=intensity
 */
public double[] getMagnitudes(double[] amplitudes) {

	int sampleSize = amplitudes.length;

	// call the fft and transform the complex numbers
	FFT fft = new FFT(sampleSize / 2, -1);
	fft.transform(amplitudes);
	// end call the fft and transform the complex numbers

	double[] complexNumbers = amplitudes;

	// even indexes (0,2,4,6,...) are real parts
	// odd indexes (1,3,5,7,...) are img parts
	int indexSize = sampleSize / 2;

	// FFT produces a transformed pair of arrays where the first half of the
	// values represent positive frequency components and the second half
	// represents negative frequency components.
	// we omit the negative ones
	int positiveSize = indexSize / 2;

	double[] mag = new double[positiveSize];
	for (int i = 0; i < indexSize; i += 2) {
		mag[i / 2] = Math.sqrt(complexNumbers[i] * complexNumbers[i] + complexNumbers[i + 1] * complexNumbers[i + 1]);
	}

	return mag;
}
 
开发者ID:jpatanooga,项目名称:Canova,代码行数:36,代码来源:FastFourierTransform.java


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