FFT noise reduction problem
804900 Oct 20, 2010 10:59 AMhello, me again.
I've been looking into java examples of FFT, mainly from this post http://forums.sun.com/thread.jspa?threadID=5426904&start=0&tstart=0 and am having trouble gettin rid of the output noise (much like the author). I took the advice of the other poster in the topic and have replaced the byte [] -> short [] -> double[] with the straight byte[] -> double[] from this post http://forums.sun.com/thread.jspa?threadID=5420508&tstart=30 but that seems to return a file of noise.
i am unsure where the error occurs in the byte[]->short[] method:
I've been looking into java examples of FFT, mainly from this post http://forums.sun.com/thread.jspa?threadID=5426904&start=0&tstart=0 and am having trouble gettin rid of the output noise (much like the author). I took the advice of the other poster in the topic and have replaced the byte [] -> short [] -> double[] with the straight byte[] -> double[] from this post http://forums.sun.com/thread.jspa?threadID=5420508&tstart=30 but that seems to return a file of noise.
i am unsure where the error occurs in the byte[]->short[] method:
public ByteAndShort2(byte[] array, boolean bigEndian) {
short[] unsignedByteArray;
int[] unsignedShortArray;
int N = array.length;
isBigEndian = bigEndian;
if (N%2 != 0) {
shortArray = new short[(N+1)/2];
byteArray = new byte[N+1];
unsignedByteArray = new short[N+1];
unsignedShortArray = new int[(N+1)/2];
for (int i = 0; i < N; i++) {
unsignedByteArray[i] = (short) (array[i] + 128);
byteArray[i] = array;
}
unsignedByteArray[N] = 1;
byteArray[N] = 0;
}
else {
shortArray = new short[N/2];
byteArray = new byte[N];
unsignedByteArray = new short[N];
unsignedShortArray = new int[(N)/2];
for (int i = 0; i < N; i++) {
unsignedByteArray[i] = (short) (array[i] + 128);
byteArray[i] = array[i];
}
}
if (isBigEndian) {
for (int i = 0; i < unsignedShortArray.length; i++) {
unsignedShortArray[i] = (int) (256 * (unsignedByteArray[i*2]) + (unsignedByteArray[i*2+1]));
}
}
else {
for (int i = 0; i < shortArray.length; i++) {
unsignedShortArray[i] = (int) (256 * (unsignedByteArray[i*2+1]) + (unsignedByteArray[i*2]));
}
}
for (int i = 0; i < shortArray.length; i++) {
shortArray[i] = (short) (unsignedShortArray[i] - 128 * 257);
}
}
any insight/links/etc would be fantastic
many thanks,
Fiona