Example usage for javax.sound.sampled UnsupportedAudioFileException printStackTrace

List of usage examples for javax.sound.sampled UnsupportedAudioFileException printStackTrace

Introduction

In this page you can find the example usage for javax.sound.sampled UnsupportedAudioFileException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:edu.cuny.qc.speech.AuToBI.PitchExtractor.java

public static void main(String[] args) {
    File file = new File(args[0]);
    AudioInputStream soundIn = null;
    try {/*from w ww .j a  v  a2 s .com*/
        soundIn = AudioSystem.getAudioInputStream(new BufferedInputStream(new FileInputStream(file)));
    } catch (UnsupportedAudioFileException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    WavReader reader = new WavReader();
    WavData wav;
    try {

        if (args.length > 1) {
            wav = reader.read(soundIn, Double.parseDouble(args[1]), Double.parseDouble(args[2]));
        } else {
            wav = reader.read(soundIn);
        }
        System.out.println(wav.sampleRate);
        System.out.println(wav.sampleSize);
        System.out.println(wav.getFrameSize());
        System.out.println(wav.getDuration());
        System.out.println(wav.getNumSamples());

        PitchExtractor pitchExtractor = new PitchExtractor(wav);
        PitchContour pitch = (PitchContour) pitchExtractor.soundToPitch();

        System.out.println("pitch points:" + pitch.size());

        for (int i = 0; i < pitch.size(); ++i) {
            System.out.println("point[" + i + "]: " + pitch.get(i) + " -- " + pitch.timeFromIndex(i) + ":"
                    + pitch.getStrength(i));
        }
    } catch (AuToBIException e) {
        e.printStackTrace();
    }
}

From source file:com.gameminers.mav.audio.AudioManager.java

public void playClip(String key) {
    if (!clips.containsKey(key))
        throw new RuntimeException("No clip with key '" + key + "'");
    try {/*  w ww.j a  va2  s .com*/
        sink.setAudioInputStream(AudioSystem.getAudioInputStream(new ByteArrayInputStream(clips.get(key))));
    } catch (UnsupportedAudioFileException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:SoundManagerTest.java

/**
 * Creates an AudioInputStream from a sound from an input stream
 *///  ww  w  .j  av a  2s .  c o  m
public AudioInputStream getAudioInputStream(InputStream is) {

    try {
        if (!is.markSupported()) {
            is = new BufferedInputStream(is);
        }
        // open the source stream
        AudioInputStream source = AudioSystem.getAudioInputStream(is);

        // convert to playback format
        return AudioSystem.getAudioInputStream(playbackFormat, source);
    } catch (UnsupportedAudioFileException ex) {
        ex.printStackTrace();
    } catch (IOException ex) {
        ex.printStackTrace();
    } catch (IllegalArgumentException ex) {
        ex.printStackTrace();
    }

    return null;
}

From source file:Filter3dTest.java

/**
 * Opens a sound from a file./*w  w  w  .j  a  va  2 s .c o  m*/
 */
public SimpleSoundPlayer(String filename) {
    try {
        // open the audio input stream
        AudioInputStream stream = AudioSystem.getAudioInputStream(new File(filename));

        format = stream.getFormat();

        // get the audio samples
        samples = getSamples(stream);
    } catch (UnsupportedAudioFileException ex) {
        ex.printStackTrace();
    } catch (IOException ex) {
        ex.printStackTrace();
    }
}

From source file:GUI.AllForDealFrame.java

private void btnSonOnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSonOnActionPerformed
    // TODO add your handling code here:
    Mixer.Info[] mixInfo = AudioSystem.getMixerInfo();
    mixer = AudioSystem.getMixer(mixInfo[0]);
    DataLine.Info dataLine = new DataLine.Info(Clip.class, null);
    try {//ww w .java 2 s. com
        clip = (Clip) mixer.getLine(dataLine);
    } catch (LineUnavailableException ex) {
        ex.printStackTrace();
    }
    try {
        URL soundURL = this.getClass().getResource("/images/The_Eagles-Hotel_California_acoustic_live_www.wav");
        AudioInputStream audioImput = AudioSystem.getAudioInputStream(soundURL);
        clip.open(audioImput);

    } catch (LineUnavailableException ex) {
        ex.printStackTrace();
    } catch (UnsupportedAudioFileException exp) {
        exp.printStackTrace();
    } catch (IOException io) {
        io.printStackTrace();
    }

    clip.start();
}