Midi2WavRenderer.midi2wav(new ByteArrayInputStream(midi), fos);
IOUtils.write(midi, fos);
}
logger.info("midi2wav conversion took: " + (System.currentTimeMillis() - start) + " millis");
start = System.currentTimeMillis();
EncodingAttributes attrs = new EncodingAttributes();
attrs.setFormat("mp3");
AudioAttributes audio = new AudioAttributes();
// audio.setBitRate(36000);
// audio.setSamplingRate(20000);
attrs.setAudioAttributes(audio);
attrs.setThreads(1);
File mp3 = File.createTempFile("gen", ".mp3");
encoder.encode(wav, mp3, attrs);
logger.info("wav2mp3 conversion took: " + (System.currentTimeMillis() - start) + " millis");
wav.delete(); //cleanup the big wav file
byte[] mp3Bytes = FileUtils.readFileToByteArray(mp3);