/*
  Convert MP3/OGG/etc to WAV files with WebAudio.
 */

var toArrayBuffer = require('buffer-to-arraybuffer');
var toBuffer = require('arraybuffer-to-buffer');
var toWav = require('audiobuffer-to-wav');
var audioContext = new (window.AudioContext || window.webkitAudioContext)();
var getStdin = require('get-stdin').buffer;

getStdin()
  .then(function (buf) {
    var data = toArrayBuffer(buf);
    audioContext.decodeAudioData(data, function (audioBuffer) {
      var wavData = toWav(audioBuffer);
      var wavBuffer = toBuffer(wavData);
      process.stdout.write(wavBuffer, function () {
        window.close();
      });
    }, fail);
  });

function fail (err) {
  process.stderr.write(err.message + '\n');
  process.exit(1);
}

@@ -193,24 +193,69 @@
 r-to-wav');%0A
+var getStdin = require('get-stdin').buffer;%0A%0A
 var audioCon
@@ -322,52 +322,8 @@
 )();
-%0Avar getStdin = require('get-stdin').buffer;
 %0A%0Age

change order