static void setUp() throws Exception {
    testarray = new float[1024];
    for (int i = 0; i < 1024; i++) {
      double ii = i / 1024.0;
      ii = ii * ii;
      testarray[i] = (float) Math.sin(10 * ii * 2 * Math.PI);
      testarray[i] += (float) Math.sin(1.731 + 2 * ii * 2 * Math.PI);
      testarray[i] += (float) Math.sin(0.231 + 6.3 * ii * 2 * Math.PI);
      testarray[i] *= 0.3;
    }
    test_byte_array = new byte[testarray.length * 2];
    AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array);
    buffer = new ModelByteBuffer(test_byte_array);

    byte[] test_byte_array2 = new byte[testarray.length * 3];
    buffer24 = new ModelByteBuffer(test_byte_array2);
    test_byte_array_8ext = new byte[testarray.length];
    byte[] test_byte_array_8_16 = new byte[testarray.length * 2];
    AudioFloatConverter.getConverter(format24).toByteArray(testarray, test_byte_array2);
    int ix = 0;
    int x = 0;
    for (int i = 0; i < test_byte_array_8ext.length; i++) {
      test_byte_array_8ext[i] = test_byte_array2[ix++];
      test_byte_array_8_16[x++] = test_byte_array2[ix++];
      test_byte_array_8_16[x++] = test_byte_array2[ix++];
    }
    buffer16_8 = new ModelByteBuffer(test_byte_array_8_16);
    buffer8 = new ModelByteBuffer(test_byte_array_8ext);

    AudioInputStream ais = new AudioInputStream(buffer.getInputStream(), format, testarray.length);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    AudioSystem.write(ais, AudioFileFormat.Type.WAVE, baos);
    buffer_wave = new ModelByteBuffer(baos.toByteArray());
  }
  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();
  }