function decodeAndRender(samples) {
  samples.forEach(function(sample) {
//    var sample_data_i16 = audiobuffer_to_i16(sample);
    var sample_ptr = op1web_sample_load_buffer(new Uint8Array(sample));
    console.log(op1web_sample_get_rate(sample_ptr));

    rv = op1web_drum_add_sample(drum_ctx, sample_ptr);
    if (rv != 0) {
      console.log("Could not add sample to context");
    }
  });

  var result = op1web_drum_write_buffer(drum_ctx);

  var blob = new Blob([result]);
  var url = window.URL.createObjectURL(blob);

  var a = document.createElement("a");
  a.href = url;
  a.download = "drum.aif";
  a.style.display = "none";
  document.body.appendChild(a);

  a.click();
}
/**
 * samples is an array of files that libsndfile can decode
 */
samples is an array of files that libsndfile can decode
samples is an array of files that libsndfile can decode
function decodeAndRender(samples) {
  samples.forEach(function(sample) {
    var sample_ptr = op1web_sample_load_buffer(new Uint8Array(sample));
    console.log(op1web_sample_get_rate(sample_ptr));
    rv = op1web_drum_add_sample(drum_ctx, sample_ptr);
    if (rv != 0) {
      console.log("Could not add sample to context");
    }
  });
  var result = op1web_drum_write_buffer(drum_ctx);
  var blob = new Blob([result]);
  var url = window.URL.createObjectURL(blob);
  var a = document.createElement("a");
  a.href = url;
  a.download = "drum.aif";
  a.style.display = "none";
  document.body.appendChild(a);
  a.click();
}
function decodeAndRender ( samples ) { samples . forEach ( function ( sample ) { var sample_ptr = op1web_sample_load_buffer ( new Uint8Array ( sample ) ) ; console . log ( op1web_sample_get_rate ( sample_ptr ) ) ; rv = op1web_drum_add_sample ( drum_ctx , sample_ptr ) ; if ( rv != 0 ) { console . log ( "Could not add sample to context" ) ; } } ) ; var result = op1web_drum_write_buffer ( drum_ctx ) ; var blob = new Blob ( [ result ] ) ; var url = window . URL . createObjectURL ( blob ) ; var a = document . createElement ( "a" ) ; a . href = url ; a . download = "drum.aif" ; a . style . display = "none" ; document . body . appendChild ( a ) ; a . click ( ) ; }
samples is an array of files that libsndfile can decode
samples is an array of files that libsndfile can decode
//    var sample_data_i16 = audiobuffer_to_i16(sample);