Example #1
0
 protected int read(byte[] buffer) {
   if (input == null) {
     input = new OggInputStream(file.read());
     setup(input.getChannels(), input.getSampleRate());
   }
   return input.read(buffer);
 }
Example #2
0
    public Sound(OpenALAudio audio, FileHandle file) {
      super(audio);

      OggInputStream input = new OggInputStream(file.read());
      ByteArrayOutputStream output = new ByteArrayOutputStream(4096);
      byte[] buffer = new byte[2048];
      while (!input.atEnd()) {
        int length = input.read(buffer);
        if (length == -1) break;
        output.write(buffer, 0, length);
      }
      setup(output.toByteArray(), input.getChannels(), input.getSampleRate());
    }