@@ -220,7 +220,6 @@ var notes = {
220
220
} ;
221
221
222
222
function mtof ( midi_note ) {
223
- console . log ( ) ;
224
223
return Math . pow ( 2 , ( midi_note - 69 ) / 12 ) * 440 ;
225
224
}
226
225
@@ -240,12 +239,13 @@ module.exports.envelope = function (audioParam, now, opts) {
240
239
audioParam . linearRampToValueAtTime ( 0 , now + attack + decay + release ) ;
241
240
} ;
242
241
243
- module . exports . load = function ( path , success , failure ) {
242
+ module . exports . load = function ( path , success , failure , providedContext ) {
244
243
var request = new XMLHttpRequest ( ) ;
245
- request . open ( 'GET' , path , true ) ;
246
- request . responseType = 'arraybuffer' ;
247
- request . onload = function ( ) {
248
- context . decodeAudioData ( request . response , success , failure ) ;
244
+ var audioContext = providedContext ? providedContext : context ;
245
+ request . open ( "GET" , path , true ) ;
246
+ request . responseType = "arraybuffer" ;
247
+ request . onload = function ( ) {
248
+ audioContext . decodeAudioData ( request . response , success , failure ) ;
249
249
} ;
250
250
request . onerror = failure ;
251
251
request . send ( ) ;
@@ -13122,8 +13122,7 @@ var cache = arguments[5];
13122
13122
13123
13123
var stringify = JSON . stringify ;
13124
13124
13125
- module . exports = function ( fn ) {
13126
- var keys = [ ] ;
13125
+ module . exports = function ( fn , options ) {
13127
13126
var wkey ;
13128
13127
var cacheKeys = Object . keys ( cache ) ;
13129
13128
@@ -13134,7 +13133,7 @@ module.exports = function (fn) {
13134
13133
// be an object with the default export as a property of it. To ensure
13135
13134
// the existing api and babel esmodule exports are both supported we
13136
13135
// check for both
13137
- if ( exp === fn || exp . default === fn ) {
13136
+ if ( exp === fn || exp && exp . default === fn ) {
13138
13137
wkey = key ;
13139
13138
break ;
13140
13139
}
@@ -13148,25 +13147,38 @@ module.exports = function (fn) {
13148
13147
wcache [ key ] = key ;
13149
13148
}
13150
13149
sources [ wkey ] = [
13151
- Function ( [ ' require' , ' module' , ' exports' ] , '(' + fn + ') (self)' ) ,
13150
+ 'function( require, module, exports){' + fn + '(self); }' ,
13152
13151
wcache
13153
13152
] ;
13154
13153
}
13155
13154
var skey = Math . floor ( Math . pow ( 16 , 8 ) * Math . random ( ) ) . toString ( 16 ) ;
13156
13155
13157
13156
var scache = { } ; scache [ wkey ] = wkey ;
13158
13157
sources [ skey ] = [
13159
- Function ( [ 'require' ] , (
13160
- // try to call default if defined to also support babel esmodule
13161
- // exports
13158
+ 'function(require,module,exports){' +
13159
+ // try to call default if defined to also support babel esmodule exports
13162
13160
'var f = require(' + stringify ( wkey ) + ');' +
13163
- '(f.default ? f.default : f)(self);'
13164
- ) ) ,
13161
+ '(f.default ? f.default : f)(self);' +
13162
+ '}' ,
13165
13163
scache
13166
13164
] ;
13167
13165
13166
+ var workerSources = { } ;
13167
+ resolveSources ( skey ) ;
13168
+
13169
+ function resolveSources ( key ) {
13170
+ workerSources [ key ] = true ;
13171
+
13172
+ for ( var depPath in sources [ key ] [ 1 ] ) {
13173
+ var depKey = sources [ key ] [ 1 ] [ depPath ] ;
13174
+ if ( ! workerSources [ depKey ] ) {
13175
+ resolveSources ( depKey ) ;
13176
+ }
13177
+ }
13178
+ }
13179
+
13168
13180
var src = '(' + bundleFn + ')({'
13169
- + Object . keys ( sources ) . map ( function ( key ) {
13181
+ + Object . keys ( workerSources ) . map ( function ( key ) {
13170
13182
return stringify ( key ) + ':['
13171
13183
+ sources [ key ] [ 0 ]
13172
13184
+ ',' + stringify ( sources [ key ] [ 1 ] ) + ']'
@@ -13177,10 +13189,13 @@ module.exports = function (fn) {
13177
13189
13178
13190
var URL = window . URL || window . webkitURL || window . mozURL || window . msURL ;
13179
13191
13180
- return new Worker ( URL . createObjectURL (
13181
- new Blob ( [ src ] , { type : 'text/javascript' } )
13182
- ) ) ;
13192
+ var blob = new Blob ( [ src ] , { type : 'text/javascript' } ) ;
13193
+ if ( options && options . bare ) { return blob ; }
13194
+ var workerUrl = URL . createObjectURL ( blob ) ;
13195
+ var worker = new Worker ( workerUrl ) ;
13196
+ worker . objectURL = workerUrl ;
13197
+ return worker ;
13183
13198
} ;
13184
13199
13185
13200
} , { } ] } , { } , [ 1 ] ) ( 1 )
13186
- } ) ;
13201
+ } ) ;
0 commit comments