Package edu.purdue.wind

Examples of edu.purdue.wind.Wave


  if (args.length != 2) {
      System.err.println("usage: WaveCrackDetector <file.wav> <probingFreq");
      System.exit(1);
  }

  Wave wave;
  try {
      wave = Wave.readFile(args[0]);
  } catch (IOException e) {
      throw new RuntimeException(e);
  }

  if (wave.channels() != 2) {
      System.err.println("Stereo input data required");
      System.exit(1);
  }

  int nSamples = 0;
  for (int i = 0; i < 32; i++) {
      if ((1 << i) > wave.samples()) {
    break;
      }
      nSamples = 1 << i;
  }

  double[][] data = new double[2][nSamples];
  for (short c = 0; c < 2; c++) {
      int[] samples = wave.sampleData(c);
      for (int i = 0; i < nSamples; i++) {
    data[c][i] = (double)samples[i];
      }
  }

  CrackDetector detector = new CrackDetector(wave.sampleRate(), nSamples);
  Turbine t = new Turbine();

  double probingFreq = Double.parseDouble(args[1]);
  detector.processAudio(t.blade(0), data[0], probingFreq);
  detector.processAudio(t.blade(1), data[1], probingFreq);
View Full Code Here


  if (args.length != 1) {
      System.err.println("usage: WaveParser <file.wav>");
      System.exit(1);
  }

  Wave wave;
  try {
      wave = Wave.readFile(args[0]);
  } catch (IOException e) {
      throw new RuntimeException(e);
  }

  System.out.println("Bits per sample:   " + wave.sampleBits());
  System.out.println("Sample rate (Hz):  " + wave.sampleRate());
  System.out.println("Channels:          " + wave.channels());
  System.out.println("Number of samples: " + wave.samples());
    }
View Full Code Here

  double duration = 30.0d;
  if (args.length == 3) {
      duration = Double.parseDouble(args[2]);
  }

  Wave wave = new Wave((short)1, SAMPLE_BITS, SAMPLE_RATE);
  int[][] samples = new int[1][(int)(SAMPLE_RATE * duration)];

  SineGenerator generator = new SineGenerator(SAMPLE_RATE,
                (int)SAMPLE_BITS,
                1, freq);
  generator.generate(samples);

  wave.setSampleData(samples);

  FileOutputStream fos = new FileOutputStream(file);
  wave.writeFile(fos);
  fos.close();
    }
View Full Code Here

  if (args.length != 1) {
      System.err.println("usage: PlotWave <file.wav>");
      System.exit(1);
  }

  Wave wave;
  try {
      wave = Wave.readFile(args[0]);
  } catch (IOException e) {
      throw new RuntimeException(e);
  }

  final int[] samples = wave.sampleData((short)0);
  final int nSamples = wave.samples();

  for (int i = 0; i < nSamples; i++) {
      System.out.println("" + i + " " + samples[i]);
  }
    }
View Full Code Here

    System.err.println("Invalid window function.  I know: hanning");
    System.exit(1);
      }
  }

  Wave wave;
  try {
      wave = Wave.readFile(args[0]);
  } catch (IOException e) {
      throw new RuntimeException(e);
  }

  short channel = Short.parseShort(args[1]);
  if (channel >= wave.channels()) {
      System.err.println("Cannot request channel not present in file");
      System.exit(1);
  }

  // Find the highest power of two smaller than wave.samples(),
  // the stupid way.  Assumes that there *are* samples.
  int bits = 0;
  for (bits = 0; bits < 32; bits++) {
      if (1 << (bits + 1) > wave.samples()) {
    break;
      }
  }

  int nSamples = 1 << bits;
  double[] samples = new double[nSamples];
  int data[] = wave.sampleData(channel);
  for (int i = 0; i < nSamples; i++) {
      samples[i] = (double)data[i];
  }

  FFT fft = new FFT(nSamples, window);
  fft.transform(samples);

  // Output the spectrum
  double[] magnitude = fft.magnitudes();
  final double stepHz = 2.0d * nSamples / (double)wave.sampleRate();

  for (int i = 0; i < nSamples / 2; i++) {
      System.out.println("" + (stepHz * i) + " " + magnitude[i]);
  }
    }
View Full Code Here

TOP

Related Classes of edu.purdue.wind.Wave

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.