public static void render(OutputStream os, AudioFormat format, Map<String, Object> info) throws Exception { AudioSynthesizer synth = (AudioSynthesizer) new SoftSynthesizer(); AudioInputStream stream = synth.openStream(format, info); Receiver recv = synth.getReceiver(); Soundbank defsbk = synth.getDefaultSoundbank(); if (defsbk != null) synth.unloadAllInstruments(defsbk); synth.loadAllInstruments(soundbank); double totalTime = 5; send(sequence, recv); long len = (long) (stream.getFormat().getFrameRate() * (totalTime + 4)); stream = new AudioInputStream(stream, stream.getFormat(), len); long t = System.currentTimeMillis(); AudioSystem.write(stream, AudioFileFormat.Type.WAVE, os); t = System.currentTimeMillis() - t; stream.close(); }
public static InputStream getInputStream(String filename) throws IOException { File file = new File(System.getProperty("test.src", "."), filename); FileInputStream fis = new FileInputStream(file); return new BufferedInputStream(fis); }