Package javazoom.jl.decoder

Examples of javazoom.jl.decoder.MP3Decoder


    public Music (OpenALAudio audio, FileHandle file) {
      super(audio, file);
      if (audio.noDevice) return;
      bitstream = new Bitstream(file.read());
      decoder = new MP3Decoder();
      try {
        Header header = bitstream.readFrame();
        if (header == null) throw new GdxRuntimeException("empty ogg");
        int channels = header.mode() == Header.SINGLE_CHANNEL ? 1 : 2;
        outputBuffer = new OutputBuffer(channels, false);
View Full Code Here


    public int read (byte[] buffer) {
      try {
        boolean setup = bitstream == null;
        if (setup) {
          bitstream = new Bitstream(file.read());
          decoder = new MP3Decoder();
        }

        int totalLength = 0;
        int minRequiredLength = buffer.length - OutputBuffer.BUFFERSIZE * 2;
        while (totalLength <= minRequiredLength) {
View Full Code Here

      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());
View Full Code Here

TOP

Related Classes of javazoom.jl.decoder.MP3Decoder

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.