示例#1
0
 public void reset() {
   if (input == null) return;
   try {
     input.close();
   } catch (IOException ignored) {
   }
   input = null;
 }
示例#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);
    }
示例#3
0
文件: Wav.java 项目: Sasun/libgdx
 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);
   }
 }