Permalink
Browse files

improve issue #7 by emitting a -100 volume event

  • Loading branch information...
1 parent d827c46 commit 5c2f638436373841a178ec6d7fd86dda4a8398f5 @fippo fippo committed Mar 4, 2014
Showing with 20 additions and 9 deletions.
  1. +14 −8 hark.bundle.js
  2. +6 −1 hark.js
View
@@ -1,5 +1,6 @@
-!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.hark=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
-var WildEmitter = _dereq_('wildemitter');
+(function(e){if("function"==typeof bootstrap)bootstrap("hark",e);else if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeHark=e}else"undefined"!=typeof window?window.hark=e():global.hark=e()})(function(){var define,ses,bootstrap,module,exports;
+return (function(e,t,n){function i(n,s){if(!t[n]){if(!e[n]){var o=typeof require=="function"&&require;if(!s&&o)return o(n,!0);if(r)return r(n,!0);throw new Error("Cannot find module '"+n+"'")}var u=t[n]={exports:{}};e[n][0].call(u.exports,function(t){var r=e[n][1][t];return i(r?r:t)},u,u.exports)}return t[n].exports}var r=typeof require=="function"&&require;for(var s=0;s<n.length;s++)i(n[s]);return i})({1:[function(require,module,exports){
+var WildEmitter = require('wildemitter');
function getMaxVolume (analyser, fftBins) {
var maxVolume = -Infinity;
@@ -70,14 +71,19 @@ module.exports = function(stream, options) {
};
harker.stop = function() {
- running = false;
+ running = false;
+ harker.emit('volume_change', -100, threshold);
+ if (harker.speaking) {
+ harker.speaking = false;
+ harker.emit('stopped_speaking');
+ }
};
// Poll the analyser node to determine if speaking
// and emit events if changed
var looper = function() {
setTimeout(function() {
-
+
//check if stop has been called
if(!running) {
return;
@@ -108,7 +114,7 @@ module.exports = function(stream, options) {
return harker;
}
-},{"wildemitter":2}],2:[function(_dereq_,module,exports){
+},{"wildemitter":2}],2:[function(require,module,exports){
/*
WildEmitter.js is a slim little event emitter by @henrikjoreteg largely based
on @visionmedia's Emitter from UI Kit.
@@ -245,6 +251,6 @@ WildEmitter.prototype.getWildcardCallbacks = function (eventName) {
return result;
};
-},{}]},{},[1])
-(1)
-});
+},{}]},{},[1])(1)
+});
+;
View
@@ -69,7 +69,12 @@ module.exports = function(stream, options) {
};
harker.stop = function() {
- running = false;
+ running = false;
+ harker.emit('volume_change', -100, threshold);
+ if (harker.speaking) {
+ harker.speaking = false;
+ harker.emit('stopped_speaking');
+ }
};
// Poll the analyser node to determine if speaking

0 comments on commit 5c2f638

Please sign in to comment.