/**
  * Decodes an audio file (mp3, flac, wav, etc. everything which can be decoded by ffmpeg) to a
  * downsampled wav file.
  *
  * @param input an audio file which will be decoded to wav
  * @param wavoutput the output wav file
  * @param samplerate the samplerate of the output wav.
  * @throws IllegalArgumentException
  * @throws InputFormatException
  * @throws EncoderException
  */
 public static void decodeAudioFile(File input, File wavoutput, int samplerate)
     throws IllegalArgumentException, InputFormatException, EncoderException {
   assert wavoutput.getName().endsWith(".wav");
   AudioAttributes audio = new AudioAttributes();
   audio.setCodec("pcm_s16le");
   audio.setChannels(Integer.valueOf(1));
   audio.setSamplingRate(new Integer(samplerate));
   EncodingAttributes attrs = new EncodingAttributes();
   attrs.setFormat("wav");
   attrs.setAudioAttributes(audio);
   Encoder encoder = new Encoder();
   encoder.encode(input, wavoutput, attrs);
 }