资源简介
语音识别中的MFCC参数提取的java源码和FFT的java源码
代码片段和文件信息
public final class FFT {
public int logm;
final int MAXLOGM = 20; /* max FFT length 2^MAXLOGM */
final double TWOPI = 6.28318530717958647692;
final double SQHALF = 0.707106781186547524401;
int brseed[] = new int[4048];
float tab[][];
public FFT(int nlength) {
double dtemp = Math.log(nlength) / Math.log(2);
if ((dtemp - (int) dtemp) != 0.0) {
throw new Error(“FFT length must be a power of 2.“);
} else {
this.logm = (int) dtemp;
}
if (logm >= 4) {
creattab(logm);
}
}
/**
* Calculates the magnitude spectrum of a real signal. The returned vector
* contains only the positive frequencies.
*/
public float[] calculateFFTMagnitude(float x[]) {
int i n;
n = 1 << this.logm;
if (x.length > n) {
throw new Error(“Tried to use a “ + n
+ “-points FFT for a vector with “ + x.length + “ samples!“);
}
rsfft(x);
float[] mag = new float[n / 2 + 1];
mag[0] = x[0]; // DC frequency must be positive always
if (n == 1) {
return mag;
}
mag[n / 2] = (float) Math.abs(x[n / 2]); // pi (meaning: fs / 2)
// System.out.println(“FFT before magnitude“);
// IO.DisplayVector(x);
for (i = 1; i < n / 2; i++) {
mag[i] = (float) Math.sqrt(x[i] * x[i] + x[n - i] * x[n - i]);
// System.out.println(mag[i] + “ “ + x[i] + “ “ + x[n-i]);
}
// IO.DisplayVector(mag);
return mag;
}
/**
* Calculates the magnitude spectrum of a real signal. The returned vector
* contains only the positive frequencies.
*/
public double[] calculateFFTMagnitude(double inputData[]) {
int i n;
n = 1 << this.logm;
if (inputData.length > n) {
throw new Error(“Tried to use a “ + n
+ “-points FFT for a vector with “ + inputData.length
+ “ samples!“);
}
// System.out.println(“magnitude test“);
// double[] dtest = DSP.DFTMagnitude(inputData);
// IO.DisplayVector(dtest);
float[] x = new float[n];
for (i = 0; i < inputData.length; i++) {
x[i] = (float) inputData[i];
}
rsfft(x);
// System.out.println(“FFT before magnitude“);
// IO.DisplayVector(x);
double[] mag = new double[n / 2 + 1];
mag[0] = x[0]; // DC frequency must be positive always
if (n == 1) {
return mag;
}
mag[n / 2] = Math.abs(x[n / 2]); // pi (meaning: fs / 2)
for (i = 1; i < n / 2; i++) {
mag[i] = Math.sqrt(x[i] * x[i] + x[n - i] * x[n - i]);
// System.out.println(mag[i] + “ “ + x[i] + “ “ + x[n-i]);
}
// IO.DisplayVector(mag);
return mag;
}
/**
* Calculates the power (magnitude squared) spectrum of a real signal. The
* returned vector contains only the positive frequencies.
*/
public double[] calculateFFTPower(double inputData[]) {
int i n;
n = 1 << this.logm;
// System.out.println(“magnitude test“);
// double[] dtest = DSP.DFTMagnitude(inputData);
// IO.DisplayVector(dtest);
float[] x = new float[n];
for (i = 0; i < inputData.length; i++) {
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 17791 2012-03-08 19:25 MFCC.java
文件 20160 2012-03-08 19:26 FFT.java
----------- --------- ---------- ----- ----
37951 2
相关资源
- MariaDB jdbc driver 1.3.0
- 微信分享给好友,自定义标题,图标
- 简易购物车javabean
- java+jsp+ajax+mysql实现在线聊天简单易懂
- java面向对象学生信息管理系统
- 100个Java swing的小程序
- Android 实现语音识别的完整代码
- 迷宫的自动搜索求解可是化
- java神州数码面试题
- 基于android MP3播放器
- JSP实现基本的注册功能
- Java 生成RSA密钥进行数据加密解密 支
-
xm
lschema-core-2.2.1.jar - java,二维码生成算法
- java简易五子棋源代码+图片素材图形界
- java画板程序支持文件打开,保存。
- 飞机大战(java项目)
- java二维数组输出下三角矩阵
- 用java写的一个图书管理系统
- JAVA实现摄像头的录像功能
- java培训课件
- mysql-connector-java-5.1.36-bin
- 骆昊JAVA面试题全集2018博客文章整理
- SGIP 彩信 java SP 接口
- java 大富翁源码、详细注释
- java300集2018.txt
- 基于java socket的简单FTP功能实现
- Java实现符号三角形问题的算法
- Java实现图的m着色问题算法
- Java串口开发用到的comm.jar,javax.comm
评论
共有 条评论