diff --git a/PanoptoPlus/dev/manifest.json b/PanoptoPlus/dev/manifest.json index 9860a8f..2f2706b 100644 --- a/PanoptoPlus/dev/manifest.json +++ b/PanoptoPlus/dev/manifest.json @@ -1,6 +1,6 @@ { "name": "Panopto Plus", - "version": "1.3.7", + "version": "1.3.8", "description": "Improve your webcasting experience!", "manifest_version": 2, "permissions": ["tabs", "storage"], @@ -49,6 +49,7 @@ "panopto/js/ui/silence-cue-manager.js", "panopto/js/ui/speed-slider.js", "panopto/js/ui/volume-booster.js", + "panopto/js/ui/white-noise-reducer.js", "panopto/js/ui/sidebar.js", "panopto/js/ui/settings-page.js", "panopto/js/ui/transcript-display.js", diff --git a/PanoptoPlus/dev/panopto/js/core/settings.js b/PanoptoPlus/dev/panopto/js/core/settings.js index 1612604..49b37e5 100644 --- a/PanoptoPlus/dev/panopto/js/core/settings.js +++ b/PanoptoPlus/dev/panopto/js/core/settings.js @@ -29,8 +29,8 @@ let Settings = (() => { {"name":"settings_subtitles","value":1}, {"name":"settings_machinetranscript","value":1}, {"name":"settings_silencetrimming","value":1}, - {"name":"settings_silencethreshold","value":1.89}, - {"name":"settings_staticnoisedetection","value":1} + {"name":"settings_silencethreshold","value":2.66}, + {"name":"settings_staticnoisedetection","value":0} ]; data.push({name: "time", value: new Date().getTime()}); return data; diff --git a/PanoptoPlus/dev/panopto/js/init.js b/PanoptoPlus/dev/panopto/js/init.js index a338429..10a6bdb 100644 --- a/PanoptoPlus/dev/panopto/js/init.js +++ b/PanoptoPlus/dev/panopto/js/init.js @@ -30,7 +30,8 @@ tsTracker: new TSTracker(settings), carouselManager: new CarouselManager(settings), //loggerDisabler: new LoggerDisabler(settings),//disabled - delayDisabler: new DelayDisabler(settings) + delayDisabler: new DelayDisabler(settings), + whiteNoiseReducer: new WhiteNoiseReducer(settings), }; //Initialize initial settings diff --git a/PanoptoPlus/dev/panopto/js/jsmpeg/vad-processor.js b/PanoptoPlus/dev/panopto/js/jsmpeg/vad-processor.js index 91e6b07..7913aff 100644 --- a/PanoptoPlus/dev/panopto/js/jsmpeg/vad-processor.js +++ b/PanoptoPlus/dev/panopto/js/jsmpeg/vad-processor.js @@ -78,6 +78,26 @@ VADProcessor = (() => { if (!referenceLineFeatures && options.useFixedNoiseSample !== 0) { switch (options.useFixedNoiseSample) { //in case we want to extend it to more options + /* + default: referenceLineFeatures = [ + [ + {lowerBound: 4.888785711454075, upperBound: 6.783195750496256}, + {lowerBound: 2.1059212543708576, upperBound: 6.2027694188546185}, + {lowerBound: 2.731769271190809, upperBound: 7.5631685867822185}, + {lowerBound: 3.3279498376197383, upperBound: 12.767826545633696}, + {lowerBound: 15.056480962156463, upperBound: 60.7670527762376}, + ], + [ + {lowerBound: 4.888785711454075, upperBound: 6.783195750496256}, + {lowerBound: 2.1059212543708576, upperBound: 6.2027694188546185}, + {lowerBound: 2.731769271190809, upperBound: 7.5631685867822185}, + {lowerBound: 3.3279498376197383, upperBound: 12.767826545633696}, + {lowerBound: 15.056480962156463, upperBound: 60.7670527762376} + ] + ]; + break;*/ + //*/ + default: referenceLineFeatures = [ [ {lowerBound: 5.222302787585955, upperBound: 8.18209849619599}, @@ -95,6 +115,7 @@ VADProcessor = (() => { ] ]; break; + } } diff --git a/PanoptoPlus/dev/panopto/js/ui/white-noise-reducer.js b/PanoptoPlus/dev/panopto/js/ui/white-noise-reducer.js new file mode 100644 index 0000000..9804d43 --- /dev/null +++ b/PanoptoPlus/dev/panopto/js/ui/white-noise-reducer.js @@ -0,0 +1,73 @@ +/** + * WhiteNoiseReducer reduces white noise. + */ +let WhiteNoiseReducer = (() => { + let audioContexts = []; + + class WhiteNoiseReducer { + /** + * Initializes White Noise Reducer upon videos loaded. + * @param {Object} settings settings object + */ + constructor(settings) { + VideosLoadedEvent.subscribe(() => { + this.setup(); + }); + } + + /** + * Setup the audiocontexts, called by the constructor. + */ + setup() { + let doms = document.getElementsByTagName("video"); + for (let i = 0; i < doms.length; i++) + audioContexts.push(this.prepareAudioContext(doms[i])); + } + + /** + * Modifications to the noise https://stackoverflow.com/questions/16949768/how-can-i-reduce-the-noise-of-a-microphone-input-with-the-web-audio-api + * @param {DOM} mediaElem MediaElement (video) which will have its audio modified + * @returns Object containing the compressor and filter + */ + prepareAudioContext(mediaElem) { + var context = new(window.AudioContext || window.webkitAudioContext), + result = { + context: context, + source: context.createMediaElementSource(mediaElem), + compressor: context.createDynamicsCompressor(), + filter: context.createBiquadFilter(), + media: mediaElem + }; + //Setup Compressor + result.compressor.threshold.value = -50; + result.compressor.knee.value = 40; + result.compressor.ratio.value = 12; + //https://github.com/GoogleChromeLabs/web-audio-samples/wiki/DynamicsCompressor.reduction + /* + if (typeof result.compressor.reduction === 'number' + || typeof result.compressor.reduction === 'float') { + result.compressor.reduction = -20; + } else { + result.compressor.reduction.value = -20; + }*/ + result.compressor.attack.value = 0; + result.compressor.release.value = 0.25; + + //Setup Filter + //result.filter.Q.value = 8.30; + result.filter.Q.value = 1.80; + result.filter.frequency.value = 355;//355; + result.filter.gain.value = 25; + result.filter.type = 'bandpass'; + result.filter.connect(result.compressor); + + //Link the pieces together + result.source.connect(result.filter); + result.compressor.connect(context.destination); + //result.filter.connect(context.destination); + + return result; + } + } + return WhiteNoiseReducer; +})(); \ No newline at end of file