Package javazoom.jl.decoder

Examples of javazoom.jl.decoder.Bitstream


    public Sound (OpenALAudio audio, FileHandle file) {
      super(audio);
      if (audio.noDevice) return;
      ByteArrayOutputStream output = new ByteArrayOutputStream(4096);

      Bitstream bitstream = new Bitstream(file.read());
      MP3Decoder decoder = new MP3Decoder();

      try {
        OutputBuffer outputBuffer = null;
        int sampleRate = -1, channels = -1;
        while (true) {
          Header header = bitstream.readFrame();
          if (header == null) break;
          if (outputBuffer == null) {
            channels = header.mode() == Header.SINGLE_CHANNEL ? 1 : 2;
            outputBuffer = new OutputBuffer(channels, false);
            decoder.setOutputBuffer(outputBuffer);
            sampleRate = header.getSampleRate();
          }
          try {
            decoder.decodeFrame(header, bitstream);
          } catch (Exception ignored) {
            // JLayer's decoder throws ArrayIndexOutOfBoundsException sometimes!?
          }
          bitstream.closeFrame();
          output.write(outputBuffer.getBuffer(), 0, outputBuffer.reset());
        }
        bitstream.close();
        setup(output.toByteArray(), channels, sampleRate);
      } catch (Throwable ex) {
        throw new GdxRuntimeException("Error reading audio data.", ex);
      }
    }
View Full Code Here


    this(stream, null)
  }
 
  public Player(InputStream stream, AudioDevice device) throws JavaLayerException
  {
    bitstream = new Bitstream(stream);   
    decoder = new Decoder();
       
    if (device!=null)
    {   
      audio = device;
View Full Code Here

    this(stream, null);
  }

  public AdvancedPlayer(InputStream stream, AudioDevice device) throws JavaLayerException
  {
    bitstream = new Bitstream(stream);
    if (device!=null) audio = device;
    else audio = FactoryRegistry.systemRegistry().createAudioDevice();
    audio.open(decoder = new Decoder());
  }
View Full Code Here

TOP

Related Classes of javazoom.jl.decoder.Bitstream

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.