Example #1
0
 public void reset() {
   if (input == null) return;
   try {
     input.close();
   } catch (IOException ignored) {
   }
   input = null;
 }
Example #2
0
    public Sound(OpenALAudio audio, FileHandle file) {
      super(audio);
      if (audio.noDevice) return;

      WavInputStream input = new WavInputStream(file);
      ByteArrayOutputStream output = new ByteArrayOutputStream(4096);
      try {
        byte[] buffer = new byte[2048];
        while (true) {
          int length = input.readData(buffer);
          if (length == -1) break;
          output.write(buffer, 0, length);
        }
      } catch (IOException ex) {
        throw new GdxRuntimeException("Error reading WAV file: " + file, ex);
      }
      setup(output.toByteArray(), input.channels, input.sampleRate);
    }
Example #3
0
 public int read(byte[] buffer) {
   if (input == null) {
     input = new WavInputStream(file);
     setup(input.channels, input.sampleRate);
   }
   try {
     return input.read(buffer);
   } catch (IOException ex) {
     throw new GdxRuntimeException("Error reading WAV file: " + file, ex);
   }
 }