Package com.talixa.audio.wav

Examples of com.talixa.audio.wav.WaveFile


      @Override
      public void actionPerformed(ActionEvent e) { 
        int freq = Integer.valueOf(freqText.getText());
       
        try {
          WaveFile wave1 = SpectrumAnalyzer.readWaveFile(inputFile);   
          if (wave1 != null) {
            short[] inputData = SharedDSPFunctions.extractWaveFileData(wave1);
            String outputFile = outputFileLabel.getText();
            if (radioDown.isSelected()) {
              FrequencyTranslator.shiftDown(inputData, freq, outputFile);
View Full Code Here


           numBytesRead =  line.read(data, 0, data.length);
           // Save this chunk of data.
           out.write(data, 0, numBytesRead);
        }    
       
        WaveFile test = WaveGenerator.generateWaveFromRaw16bitPcm(out.toByteArray());
        test.outputToFile(outputFile);
     
      } catch (LineUnavailableException e) {
        e.printStackTrace();
      } catch (IOException e) {
        e.printStackTrace();
View Full Code Here

        String input2 = inputLabel2.getText();
        String output = outputFileLabel.getText();
       
        if (!input1.equals(SpecAnConstants.NO_FILE_SELECTED) && !input2.equals(SpecAnConstants.NO_FILE_SELECTED) && !output.equals(SpecAnConstants.NO_FILE_SELECTED)) {
          try {
            WaveFile wave1 = SpectrumAnalyzer.readWaveFile(input1);   
            if (wave1 != null) {                                   
              WaveFile wave2 = SpectrumAnalyzer.readWaveFile(input2)
              if (wave2 != null) {
                short[] fileData1 = SharedDSPFunctions.extractWaveFileData(wave1);
                short[] fileData2 = SharedDSPFunctions.extractWaveFileData(wave2);               
               
                MixerMode mode;
View Full Code Here

 
  private short[] data;                // pcm samples
  private int wpm;
 
  public CwDemod(String inputFile) throws IOException, RiffFormatException {
    WaveFile waveFile;
    if (gui) {
      waveFile = SpectrumAnalyzer.readWaveFile(inputFile);
    } else {
      waveFile = WaveReader.readFromFile(inputFile);
   
View Full Code Here

      System.out.print("***********************");
      System.out.print(TEST_FILES[i]);
      System.out.println("***********************");
      String inputFile = path + TEST_FILES[i];
      try {               
        WaveFile waveFile = WaveReader.readFromFile(inputFile);
        short[] data = SharedDSPFunctions.extractWaveFileData(waveFile)
        String tones = detect(data);
        System.out.println(tones);
      } catch (Exception e) {     
        e.printStackTrace();
View Full Code Here

  private static boolean gui = true
 
  private short[] data;                // pcm samples
 
  public Psk31Demod(String inputFile) throws IOException, RiffFormatException
    WaveFile waveFile;
    if (gui) {
      waveFile = SpectrumAnalyzer.readWaveFile(inputFile);
    } else {
      waveFile = WaveReader.readFromFile(inputFile);
   
View Full Code Here

      System.out.print("***********************");
      System.out.print(TEST_FILES[i]);
      System.out.println("***********************");
      String inputFile = path + TEST_FILES[i]
      try {
        WaveFile wave = WaveReader.readFromFile(inputFile);
        short[] data = SharedDSPFunctions.extractWaveFileData(wave);
        Psk31Demod demod = new Psk31Demod(data);
        String demodData = demod.demodulate(CENTER_FREQS[i])
        System.out.println(demodData);
      } catch (Exception e) {
View Full Code Here

        fos = new FileOutputStream(output);
      }
     
      Queue<Integer> bitQueue = new ArrayDeque<Integer>();
     
      WaveFile waveFile;
      if (gui) {
        waveFile = SpectrumAnalyzer.readWaveFile(inputFile);
      } else {
        waveFile = WaveReader.readFromFile(inputFile);
      }
     
      if (waveFile == null) {
        return;
      }
     
      short signedSample = (short)waveFile.getSampleAt(0)// two-byte samples             
      double previousSample = ((double) signedSample)/ ((1 << waveFile.getFormatChunk().getBitsPerSample()) / 2);
      double currentSample;
     
      int consecutiveLows = 0;    // number of waves of low frequency
      int consecutiveHighs = 0;    // number of waves of high frequency
      double currentWaveLength = 0// length of current wave
      boolean startOutput = false// true after first stop bit encountered
      int bitsSinceLastStop = 0;    // keep track of bits/frame so we don't loose sync
               
      for(int i = 1; i < waveFile.getNumberOfSamples(); ++i) {
        signedSample = (short)waveFile.getSampleAt(i*2)// two-byte samples         
        currentSample = ((double) signedSample)/ ((1 << waveFile.getFormatChunk().getBitsPerSample()) / 2);       
       
        // if we crossed from negative to positive, the magic starts!
        if ((currentSample >= 0 && previousSample < 0)) {
         
          // deviation = abs(low) + high
View Full Code Here

    JMenuItem ookMenuItem = new JMenuItem(SpecAnConstants.MENU_OOK);
    ookMenuItem.setMnemonic(KeyEvent.VK_C);
    ookMenuItem.addActionListener(new ActionListener() {     
      @Override
      public void actionPerformed(ActionEvent e) {
        WaveFile waveFile = SpectrumAnalyzer.readWaveFile(inputFile);
        short data[] = SharedDSPFunctions.extractWaveFileData(waveFile);
        CwDemod demod = new CwDemod(data);
        String morse = demod.demodulate();
        int speed = demod.getWpm();
        JOptionPane.showMessageDialog(frame, "Speed: " + speed + " WPM\n" + morse);
      }
    });
    demodMenu.add(ookMenuItem);
   
    JMenuItem dtmfMenuItem = new JMenuItem(SpecAnConstants.MENU_DTMF);
    dtmfMenuItem.setMnemonic(KeyEvent.VK_D);
    dtmfMenuItem.addActionListener(new ActionListener() {     
      @Override
      public void actionPerformed(ActionEvent e) {
        WaveFile waveFile = SpectrumAnalyzer.readWaveFile(inputFile);
        short data[] = SharedDSPFunctions.extractWaveFileData(waveFile);
        String codes = DTMFDecoder.detect(data);
        JOptionPane.showMessageDialog(frame, codes);
      }
    });
View Full Code Here

    menuBar.add(helpMenu);
    frame.setJMenuBar(menuBar);
  }
 
  public static WaveFile readWaveFile(String fileName) {
    WaveFile waveFile = null;
    try {
      waveFile = WaveReader.readFromFile(fileName)
      if (waveFile.getFormatChunk().getAudioFormat() != FormatChunk.AUDIO_FORMAT_PCM ||
        waveFile.getFormatChunk().getSampleRate() != 8000 ||
        waveFile.getFormatChunk().getBitsPerSample() != 16) {
          waveFile = null;
          JOptionPane.showMessageDialog(frame, fileName + " is not 16-bit PCM at 8kHz");
      }
     
    } catch (IOException e) {
View Full Code Here

TOP

Related Classes of com.talixa.audio.wav.WaveFile

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.