< prev index next >

src/java.desktop/share/classes/com/sun/media/sound/WaveFloatFileReader.java

Print this page




  78             }
  79             if (chunk.getFormat().equals("data")) {
  80                 data_found = true;
  81                 break;
  82             }
  83         }
  84         if (!fmt_found || !data_found) {
  85             throw new UnsupportedAudioFileException();
  86         }
  87         AudioFormat audioformat = new AudioFormat(
  88                 Encoding.PCM_FLOAT, samplerate, bits, channels,
  89                 framesize, samplerate, false);
  90         return new AudioFileFormat(AudioFileFormat.Type.WAVE, audioformat,
  91                                    AudioSystem.NOT_SPECIFIED);
  92     }
  93 
  94     @Override
  95     public AudioInputStream getAudioInputStream(final InputStream stream)
  96             throws UnsupportedAudioFileException, IOException {
  97 
  98         AudioFileFormat format = getAudioFileFormat(stream);
  99         // we've got everything, the stream is supported and it is at the
 100         // beginning of the header, so find the data chunk again and return an
 101         // AudioInputStream
 102         RIFFReader riffiterator = new RIFFReader(stream);
 103         while (riffiterator.hasNextChunk()) {
 104             RIFFReader chunk = riffiterator.nextChunk();
 105             if (chunk.getFormat().equals("data")) {
 106                 return new AudioInputStream(chunk, format.getFormat(),
 107                         chunk.getSize());

 108             }
 109         }
 110         throw new UnsupportedAudioFileException();
 111     }
 112 }


  78             }
  79             if (chunk.getFormat().equals("data")) {
  80                 data_found = true;
  81                 break;
  82             }
  83         }
  84         if (!fmt_found || !data_found) {
  85             throw new UnsupportedAudioFileException();
  86         }
  87         AudioFormat audioformat = new AudioFormat(
  88                 Encoding.PCM_FLOAT, samplerate, bits, channels,
  89                 framesize, samplerate, false);
  90         return new AudioFileFormat(AudioFileFormat.Type.WAVE, audioformat,
  91                                    AudioSystem.NOT_SPECIFIED);
  92     }
  93 
  94     @Override
  95     public AudioInputStream getAudioInputStream(final InputStream stream)
  96             throws UnsupportedAudioFileException, IOException {
  97 
  98         final AudioFileFormat format = getAudioFileFormat(stream);
  99         // we've got everything, the stream is supported and it is at the
 100         // beginning of the header, so find the data chunk again and return an
 101         // AudioInputStream
 102         final RIFFReader riffiterator = new RIFFReader(stream);
 103         while (riffiterator.hasNextChunk()) {
 104             RIFFReader chunk = riffiterator.nextChunk();
 105             if (chunk.getFormat().equals("data")) {
 106                 final AudioFormat af = format.getFormat();
 107                 final long length = chunk.getSize() / af.getFrameSize();
 108                 return new AudioInputStream(chunk, af, length);
 109             }
 110         }
 111         throw new UnsupportedAudioFileException();
 112     }
 113 }
< prev index next >