@@ -126,7 +126,7 @@ for (var i = 0; i < 100; i++) {
126
126
window . requestAnimationFrame ( draw ) ;
127
127
} ) ( ) ;
128
128
129
- } , { "../hark.js" :2 , "attachmediastream" :5 , "bows" :4 , "getusermedia" :3 } ] , 3 :[ function ( require , module , exports ) {
129
+ } , { "../hark.js" :2 , "attachmediastream" :5 , "bows" :3 , "getusermedia" :4 } ] , 4 :[ function ( require , module , exports ) {
130
130
// getUserMedia helper by @HenrikJoreteg
131
131
var func = ( navigator . getUserMedia ||
132
132
navigator . webkitGetUserMedia ||
@@ -273,14 +273,16 @@ module.exports = function(stream, options) {
273
273
harker . setInterval = function ( i ) {
274
274
interval = i ;
275
275
} ;
276
-
276
+
277
277
harker . stop = function ( ) {
278
278
running = false ;
279
279
harker . emit ( 'volume_change' , - 100 , threshold ) ;
280
280
if ( harker . speaking ) {
281
281
harker . speaking = false ;
282
282
harker . emit ( 'stopped_speaking' ) ;
283
283
}
284
+ analyser . disconnect ( ) ;
285
+ sourceNode . disconnect ( ) ;
284
286
} ;
285
287
harker . speakingHistory = [ ] ;
286
288
for ( var i = 0 ; i < history ; i ++ ) {
@@ -291,12 +293,12 @@ module.exports = function(stream, options) {
291
293
// and emit events if changed
292
294
var looper = function ( ) {
293
295
setTimeout ( function ( ) {
294
-
296
+
295
297
//check if stop has been called
296
298
if ( ! running ) {
297
299
return ;
298
300
}
299
-
301
+
300
302
var currentVolume = getMaxVolume ( analyser , fftBins ) ;
301
303
302
304
harker . emit ( 'volume_change' , currentVolume , threshold ) ;
@@ -333,147 +335,161 @@ module.exports = function(stream, options) {
333
335
}
334
336
335
337
} , { "wildemitter" :6 } ] , 6 :[ function ( require , module , exports ) {
336
- /*
337
- WildEmitter.js is a slim little event emitter by @henrikjoreteg largely based
338
- on @visionmedia's Emitter from UI Kit.
339
-
340
- Why? I wanted it standalone.
341
-
342
- I also wanted support for wildcard emitters like this:
343
-
344
- emitter.on('*', function (eventName, other, event, payloads) {
345
-
346
- });
347
-
348
- emitter.on('somenamespace*', function (eventName, payloads) {
349
-
350
- });
351
-
352
- Please note that callbacks triggered by wildcard registered events also get
353
- the event name as the first argument.
354
- */
355
- module . exports = WildEmitter ;
356
-
357
- function WildEmitter ( ) {
358
- this . callbacks = { } ;
359
- }
360
-
361
- // Listen on the given `event` with `fn`. Store a group name if present.
362
- WildEmitter . prototype . on = function ( event , groupName , fn ) {
363
- var hasGroup = ( arguments . length === 3 ) ,
364
- group = hasGroup ? arguments [ 1 ] : undefined ,
365
- func = hasGroup ? arguments [ 2 ] : arguments [ 1 ] ;
366
- func . _groupName = group ;
367
- ( this . callbacks [ event ] = this . callbacks [ event ] || [ ] ) . push ( func ) ;
368
- return this ;
369
- } ;
370
-
371
- // Adds an `event` listener that will be invoked a single
372
- // time then automatically removed.
373
- WildEmitter . prototype . once = function ( event , groupName , fn ) {
374
- var self = this ,
375
- hasGroup = ( arguments . length === 3 ) ,
376
- group = hasGroup ? arguments [ 1 ] : undefined ,
377
- func = hasGroup ? arguments [ 2 ] : arguments [ 1 ] ;
378
- function on ( ) {
379
- self . off ( event , on ) ;
380
- func . apply ( this , arguments ) ;
381
- }
382
- this . on ( event , group , on ) ;
383
- return this ;
384
- } ;
385
-
386
- // Unbinds an entire group
387
- WildEmitter . prototype . releaseGroup = function ( groupName ) {
388
- var item , i , len , handlers ;
389
- for ( item in this . callbacks ) {
390
- handlers = this . callbacks [ item ] ;
391
- for ( i = 0 , len = handlers . length ; i < len ; i ++ ) {
392
- if ( handlers [ i ] . _groupName === groupName ) {
393
- //console.log('removing');
394
- // remove it and shorten the array we're looping through
395
- handlers . splice ( i , 1 ) ;
396
- i -- ;
397
- len -- ;
398
- }
399
- }
400
- }
401
- return this ;
402
- } ;
403
-
404
- // Remove the given callback for `event` or all
405
- // registered callbacks.
406
- WildEmitter . prototype . off = function ( event , fn ) {
407
- var callbacks = this . callbacks [ event ] ,
408
- i ;
409
-
410
- if ( ! callbacks ) return this ;
411
-
412
- // remove all handlers
413
- if ( arguments . length === 1 ) {
414
- delete this . callbacks [ event ] ;
415
- return this ;
416
- }
417
-
418
- // remove specific handler
419
- i = callbacks . indexOf ( fn ) ;
420
- callbacks . splice ( i , 1 ) ;
421
- return this ;
422
- } ;
423
-
424
- /// Emit `event` with the given args.
425
- // also calls any `*` handlers
426
- WildEmitter . prototype . emit = function ( event ) {
427
- var args = [ ] . slice . call ( arguments , 1 ) ,
428
- callbacks = this . callbacks [ event ] ,
429
- specialCallbacks = this . getWildcardCallbacks ( event ) ,
430
- i ,
431
- len ,
432
- item ,
433
- listeners ;
434
-
435
- if ( callbacks ) {
436
- listeners = callbacks . slice ( ) ;
437
- for ( i = 0 , len = listeners . length ; i < len ; ++ i ) {
438
- if ( listeners [ i ] ) {
439
- listeners [ i ] . apply ( this , args ) ;
440
- } else {
441
- break ;
442
- }
443
- }
444
- }
445
-
446
- if ( specialCallbacks ) {
447
- len = specialCallbacks . length ;
448
- listeners = specialCallbacks . slice ( ) ;
449
- for ( i = 0 , len = listeners . length ; i < len ; ++ i ) {
450
- if ( listeners [ i ] ) {
451
- listeners [ i ] . apply ( this , [ event ] . concat ( args ) ) ;
452
- } else {
453
- break ;
454
- }
455
- }
456
- }
457
-
458
- return this ;
459
- } ;
460
-
461
- // Helper for for finding special wildcard event handlers that match the event
462
- WildEmitter . prototype . getWildcardCallbacks = function ( eventName ) {
463
- var item ,
464
- split ,
465
- result = [ ] ;
466
-
467
- for ( item in this . callbacks ) {
468
- split = item . split ( '*' ) ;
469
- if ( item === '*' || ( split . length === 2 && eventName . slice ( 0 , split [ 0 ] . length ) === split [ 0 ] ) ) {
470
- result = result . concat ( this . callbacks [ item ] ) ;
471
- }
472
- }
473
- return result ;
474
- } ;
475
-
476
- } , { } ] , 4 :[ function ( require , module , exports ) {
338
+ /*
339
+ WildEmitter.js is a slim little event emitter by @henrikjoreteg largely based
340
+ on @visionmedia's Emitter from UI Kit.
341
+
342
+ Why? I wanted it standalone.
343
+
344
+ I also wanted support for wildcard emitters like this:
345
+
346
+ emitter.on('*', function (eventName, other, event, payloads) {
347
+
348
+ });
349
+
350
+ emitter.on('somenamespace*', function (eventName, payloads) {
351
+
352
+ });
353
+
354
+ Please note that callbacks triggered by wildcard registered events also get
355
+ the event name as the first argument.
356
+ */
357
+
358
+ module . exports = WildEmitter ;
359
+
360
+ function WildEmitter ( ) { }
361
+
362
+ WildEmitter . mixin = function ( constructor ) {
363
+ var prototype = constructor . prototype || constructor ;
364
+
365
+ prototype . isWildEmitter = true ;
366
+
367
+ // Listen on the given `event` with `fn`. Store a group name if present.
368
+ prototype . on = function ( event , groupName , fn ) {
369
+ this . callbacks = this . callbacks || { } ;
370
+ var hasGroup = ( arguments . length === 3 ) ,
371
+ group = hasGroup ? arguments [ 1 ] : undefined ,
372
+ func = hasGroup ? arguments [ 2 ] : arguments [ 1 ] ;
373
+ func . _groupName = group ;
374
+ ( this . callbacks [ event ] = this . callbacks [ event ] || [ ] ) . push ( func ) ;
375
+ return this ;
376
+ } ;
377
+
378
+ // Adds an `event` listener that will be invoked a single
379
+ // time then automatically removed.
380
+ prototype . once = function ( event , groupName , fn ) {
381
+ var self = this ,
382
+ hasGroup = ( arguments . length === 3 ) ,
383
+ group = hasGroup ? arguments [ 1 ] : undefined ,
384
+ func = hasGroup ? arguments [ 2 ] : arguments [ 1 ] ;
385
+ function on ( ) {
386
+ self . off ( event , on ) ;
387
+ func . apply ( this , arguments ) ;
388
+ }
389
+ this . on ( event , group , on ) ;
390
+ return this ;
391
+ } ;
392
+
393
+ // Unbinds an entire group
394
+ prototype . releaseGroup = function ( groupName ) {
395
+ this . callbacks = this . callbacks || { } ;
396
+ var item , i , len , handlers ;
397
+ for ( item in this . callbacks ) {
398
+ handlers = this . callbacks [ item ] ;
399
+ for ( i = 0 , len = handlers . length ; i < len ; i ++ ) {
400
+ if ( handlers [ i ] . _groupName === groupName ) {
401
+ //console.log('removing');
402
+ // remove it and shorten the array we're looping through
403
+ handlers . splice ( i , 1 ) ;
404
+ i -- ;
405
+ len -- ;
406
+ }
407
+ }
408
+ }
409
+ return this ;
410
+ } ;
411
+
412
+ // Remove the given callback for `event` or all
413
+ // registered callbacks.
414
+ prototype . off = function ( event , fn ) {
415
+ this . callbacks = this . callbacks || { } ;
416
+ var callbacks = this . callbacks [ event ] ,
417
+ i ;
418
+
419
+ if ( ! callbacks ) return this ;
420
+
421
+ // remove all handlers
422
+ if ( arguments . length === 1 ) {
423
+ delete this . callbacks [ event ] ;
424
+ return this ;
425
+ }
426
+
427
+ // remove specific handler
428
+ i = callbacks . indexOf ( fn ) ;
429
+ callbacks . splice ( i , 1 ) ;
430
+ if ( callbacks . length === 0 ) {
431
+ delete this . callbacks [ event ] ;
432
+ }
433
+ return this ;
434
+ } ;
435
+
436
+ /// Emit `event` with the given args.
437
+ // also calls any `*` handlers
438
+ prototype . emit = function ( event ) {
439
+ this . callbacks = this . callbacks || { } ;
440
+ var args = [ ] . slice . call ( arguments , 1 ) ,
441
+ callbacks = this . callbacks [ event ] ,
442
+ specialCallbacks = this . getWildcardCallbacks ( event ) ,
443
+ i ,
444
+ len ,
445
+ item ,
446
+ listeners ;
447
+
448
+ if ( callbacks ) {
449
+ listeners = callbacks . slice ( ) ;
450
+ for ( i = 0 , len = listeners . length ; i < len ; ++ i ) {
451
+ if ( ! listeners [ i ] ) {
452
+ break ;
453
+ }
454
+ listeners [ i ] . apply ( this , args ) ;
455
+ }
456
+ }
457
+
458
+ if ( specialCallbacks ) {
459
+ len = specialCallbacks . length ;
460
+ listeners = specialCallbacks . slice ( ) ;
461
+ for ( i = 0 , len = listeners . length ; i < len ; ++ i ) {
462
+ if ( ! listeners [ i ] ) {
463
+ break ;
464
+ }
465
+ listeners [ i ] . apply ( this , [ event ] . concat ( args ) ) ;
466
+ }
467
+ }
468
+
469
+ return this ;
470
+ } ;
471
+
472
+ // Helper for for finding special wildcard event handlers that match the event
473
+ prototype . getWildcardCallbacks = function ( eventName ) {
474
+ this . callbacks = this . callbacks || { } ;
475
+ var item ,
476
+ split ,
477
+ result = [ ] ;
478
+
479
+ for ( item in this . callbacks ) {
480
+ split = item . split ( '*' ) ;
481
+ if ( item === '*' || ( split . length === 2 && eventName . slice ( 0 , split [ 0 ] . length ) === split [ 0 ] ) ) {
482
+ result = result . concat ( this . callbacks [ item ] ) ;
483
+ }
484
+ }
485
+ return result ;
486
+ } ;
487
+
488
+ } ;
489
+
490
+ WildEmitter . mixin ( WildEmitter ) ;
491
+
492
+ } , { } ] , 3 :[ function ( require , module , exports ) {
477
493
( function ( window ) {
478
494
var logger = require ( 'andlog' ) ,
479
495
goldenRatio = 0.618033988749895 ,
@@ -521,7 +537,8 @@ WildEmitter.prototype.getWildcardCallbacks = function (eventName) {
521
537
return ;
522
538
}
523
539
524
- if ( ls && ls . debug && window . console ) {
540
+ var andlogKey = ls . andlogKey || 'debug'
541
+ if ( ls && ls [ andlogKey ] && window . console ) {
525
542
out = window . console ;
526
543
} else {
527
544
var methods = "assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn" . split ( "," ) ,
0 commit comments