Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.lang.Math;
- import java.util.ArrayList;
- import java.util.Scanner;
- import static java.lang.Math.log;
- public class WavClass {
- public static double lg(double x) {
- return Math.log(x)/Math.log(2.0);
- }
- public static void main(String []args){
- int N=0;
- FFT fft;
- double[] window;
- double[] re;
- double[] im;
- try {
- String path = new String();
- Scanner in = new Scanner(System.in);
- System.out.println("Input wav file path ");
- path = in.nextLine();
- File f = new File(path);
- WavFile wf = WavFile.openWavFile(f);
- int numChannels = wf.getNumChannels();
- N = 1024*numChannels;
- fft = new FFT(N);
- int counter = 0;
- window = fft.getWindow();
- int[] buffer = new int[N];
- ArrayList<Double> a = new ArrayList<>();
- int framesRead;
- do{
- framesRead = wf.readFrames(buffer, 1024);
- for(int j=0;j<N;j++)
- a.add(Math.abs((double) buffer[j]));
- }
- while (framesRead != 0);
- System.out.print("aSize= "+a.size());
- re = new double[a.size()];
- im = new double[1];
- System.out.print("Comleted");
- System.exit(0);
- fft.fft(re,im);
- System.out.println("After FFT: ");
- for(int i=0; i<a.size(); i++) {
- System.out.println("real: "+re[i]);
- }
- }
- catch (Exception e){
- System.out.println("Some shit happened..." + e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement