Package javax.sound.sampled

Examples of javax.sound.sampled.AudioFormat


        AudioInputStream stream = null;

        stream = AudioSystem.getAudioInputStream(new File(filename));
        //System.out.println(stream.getFormat());
       
        AudioFormat baseFormat = stream.getFormat();
        AudioFormat decodedFormat =
            new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,
                            baseFormat.getSampleRate(),
                            16,
                            baseFormat.getChannels(),
                            baseFormat.getChannels() * 2,
                            baseFormat.getSampleRate(),
                            bigEndian);
        stream = AudioSystem.getAudioInputStream(decodedFormat, stream);
        //System.out.println(stream.getFormat());

        // convert to stereo PCM before converting to mono -
        // without this line the conversion process will crap out
        // on stereo MP3s.  But the conversion from mono to stereo
        // is unsupported for some reason...
        if(stream.getFormat().getChannels() >= 2)
            //stream = AudioSystem.getAudioInputStream(MEAPUtil.stereo, stream);
            stream = AudioSystem.getAudioInputStream(
                new AudioFormat(format.getSampleRate(), bitsPerSamp, 2,
                                signed, bigEndian),
                stream);
       
        stream = AudioSystem.getAudioInputStream(format, stream);

View Full Code Here


    public FeatFile processAudioFile(String fn) throws IOException, UnsupportedAudioFileException
    {
        // Create Extractor
        //ais = openInputStream(fn);
        // downsample to 8kHz
        ais = openInputStream(fn, new AudioFormat(DpweOnsetDetector.sr,
                                                  bitsPerSamp, 1, signed,
                                                  bigEndian));

        long frameLength = ais.getFrameLength();
        // the mp3/flac decoders don't like to tell us the frame
View Full Code Here

    {
        AudioInputStream ais = MEAPUtil.openInputStream(srcFile, format);

        // this format had better match the output file format or we
        // have problems
        AudioFormat fmt = ais.getFormat();
       
        int frameSize = fmt.getFrameSize();
        float frameRate = fmt.getFrameRate();
       
        int startByte = (int)(startTime*frameRate*frameSize);
        int byteLen = (int)(length*frameRate*frameSize);
       
        byte[] bytes = new byte[byteLen];
View Full Code Here

            if(!ch.srcFile.equals(lastAudioFile))
            {
                AudioInputStream ais = openInputStream(ch.srcFile);

                // resample to feSamplingRate
                AudioFormat fmt = new AudioFormat(feSamplingRate,
                                                  format.getSampleSizeInBits(),
                                                  format.getChannels(),
                                                  MEAPUtil.signed,
                                                  format.isBigEndian());
                ais = AudioSystem.getAudioInputStream(format, ais);
View Full Code Here

    double localFirstEventTime = fCTD.startTime;

    AudioReader reader = null;

    // don't need hirez data for display...
    AudioFormat format = new AudioFormat(8000, 16, 1, MEAPUtil.signed,
        MEAPUtil.bigEndian);

    try
    {
      //reader = new AudioReader(fCTD.srcFile, format);
            reader = AudioReaderFactory.getAudioReader(fCTD.srcFile, format);
    }
    catch (IOException e1)
    {
      e1.printStackTrace();
      return;
    }
    catch (UnsupportedAudioFileException e1)
    {
      e1.printStackTrace();
      return;
    }

    int frameSize = format.getFrameSize();
    double frameRate = (double) format.getFrameRate();

    long fileFrameLength = reader.getFrameLength();
    double fileTimeLength = ((double) fileFrameLength / frameRate);//  / frameSize;

    int framesPerPixel = (int) Math.ceil((double) fileFrameLength
View Full Code Here

    // don't need hirez data for display...
    //AudioFormat format = new AudioFormat(8000, 8, 1, MEAPUtil.signed,
    //    MEAPUtil.bigEndian);
   
    //don't need hirez data for waveform display...
      AudioFormat format = new AudioFormat(8000, 16, 1, MEAPUtil.signed,
                                             MEAPUtil.bigEndian);
   
        AudioReader reader = null;
    try
    {
            //reader = new AudioReader(fCTD.srcFile, format);
            reader = AudioReaderFactory.getAudioReader(fCTD.srcFile, format);
    }
    catch (IOException e1)
    {
      e1.printStackTrace();
      return;
    }
    catch (UnsupportedAudioFileException e1)
    {
      e1.printStackTrace();
      return;
    }
   
    //double startTime = fC.startTime;   
   
        int frameSize = format.getFrameSize();
        double frameRate = (double)format.getFrameRate();
       
    long fileFrameLength = reader.getFrameLength();
    double fileTimeLength = ((double)fileFrameLength / frameRate);// / frameSize;
   
    int framesPerPixel = (int) Math.ceil((double)fileFrameLength/(double)w);
View Full Code Here

        ais = AudioSystem.getAudioInputStream(PlayWavAction.class.getResource(this.wavFile));
      } catch(Exception e){
        ais = AudioSystem.getAudioInputStream(new File(PlayWavAction.class.getResource(this.wavFile).getFile()));
      }

      AudioFormat format = ais.getFormat();
      DataLine.Info info = new DataLine.Info(Clip.class, format);

      Clip clip = (Clip) AudioSystem.getLine(info);
      clip.open(ais);
      clip.start();
View Full Code Here

            new_channel_samples = new double[1][samples.length];
            for (int i = 0; i < samples.length; i++)
                new_channel_samples[0][i] = samples[i];
        }

        AudioFormat new_audio_format = null;
        if (audio_format != null) {
            new_audio_format = new AudioFormat(audio_format.getEncoding(),
                    audio_format.getSampleRate(),
                    audio_format.getSampleSizeInBits(),
                    audio_format.getChannels(),
                    audio_format.getFrameSize(),
                    audio_format.getFrameRate(),
View Full Code Here

     * during conversion.
     */
    public AudioInputStream getAudioInputStreamMixedDown()
            throws Exception {
        // Specify that only one channel is used
        AudioFormat mixed_down_audio_format = new AudioFormat(audio_format.getSampleRate(),
                audio_format.getSampleSizeInBits(),
                1,
                true,
                audio_format.isBigEndian());

View Full Code Here

     * ranges or if error occurs during conversion.
     */
    public AudioInputStream getAudioInputStreamMixedDown(int start_sample, int end_sample)
            throws Exception {
        // Specify that only one channel is used
        AudioFormat mixed_down_audio_format = new AudioFormat(audio_format.getSampleRate(),
                audio_format.getSampleSizeInBits(),
                1,
                true,
                audio_format.isBigEndian());

View Full Code Here

TOP

Related Classes of javax.sound.sampled.AudioFormat

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.