Skip to content

Commit

Permalink
can pass filename to Sampler.download()
Browse files Browse the repository at this point in the history
  • Loading branch information
charlieroberts committed Sep 27, 2016
1 parent 96081b1 commit 1f63241
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
10 changes: 8 additions & 2 deletions build/gibberish.js
Original file line number Diff line number Diff line change
Expand Up @@ -5552,7 +5552,7 @@ param **buffer** Object. The decoded sampler buffers from the audio file
Download the sampler buffer as a .wav file. In conjunction with the record method, this enables the Sampler
to record and downlaod Gibberish sessions.
**/
download : function() { // thanks to Palle and Gunnar for updates!
download : function( filename ) { // thanks to Palle and Gunnar for updates!
var blob = this.encodeWAV();
var audioBlob = new Blob( [ blob ] );

Expand All @@ -5569,7 +5569,13 @@ to record and downlaod Gibberish sessions.

var link = window.document.createElement('a');
link.href = url;
link.download = 'output.wav';
if( typeof filename === 'undefined' ) {
filename = 'gibber_output.wav'
}else if( filename.indexOf('.wav') === -1 ) {
filename += '.wav'
}

link.download = filename || 'output.wav';

var click = new MouseEvent('click', {
'view': window,
Expand Down
Loading

0 comments on commit 1f63241

Please sign in to comment.