summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorCheng-Yi Chiang <cychiang@chromium.org>2014-04-23 13:46:22 +0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-04-23 20:51:34 +0000
commit80a94bfb0e0f0cfb438b614074af3f43372d6a85 (patch)
treec743130ab4f307092bb4bb2af23719c0422023bf /scripts
parentcce7eaa7ff4822dbab77a50e1598ffe7f86a3aaf (diff)
downloadadhd-80a94bfb0e0f0cfb438b614074af3f43372d6a85.tar.gz
script: Fix audio-tuning frontend for web audio element name
webkitAudioContext is renamed to AudioContext. webkitOfflineAudioContext is renamed to OfflineAudioContext. createGainNode in AudioConext is renamed to createGain. This CL fixes those element names so the site can work with both old and new version. Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org> BUG=chromium:365989 TEST=run audio-tuning site on ubuntu desktop and chromeos Change-Id: Icd18cac04e7db9549c5d307e21bfde8ab764bcfe Reviewed-on: https://chromium-review.googlesource.com/196469 Reviewed-by: Chih-Chung Chang <chihchung@chromium.org> Reviewed-by: Hsinyu Chao <hychao@chromium.org> Commit-Queue: Cheng-Yi Chiang <cychiang@chromium.org> Tested-by: Cheng-Yi Chiang <cychiang@chromium.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/audio_tuning/frontend/audio.js26
1 files changed, 22 insertions, 4 deletions
diff --git a/scripts/audio_tuning/frontend/audio.js b/scripts/audio_tuning/frontend/audio.js
index 5316c45c..08a2091d 100644
--- a/scripts/audio_tuning/frontend/audio.js
+++ b/scripts/audio_tuning/frontend/audio.js
@@ -118,8 +118,21 @@ var analyzer_right; /* The FFT analyzer for right channel */
* This value is stored in drc.emphasis_disabled in the config. */
var browser_emphasis_disabled_detection_result;
+/* The supported audio element names are different on browsers with different
+ * versions.*/
+function fix_audio_elements() {
+ try {
+ window.AudioContext = window.AudioContext || window.webkitAudioContext;
+ window.OfflineAudioContext = (window.OfflineAudioContext ||
+ window.webkitOfflineAudioContext);
+ }
+ catch(e) {
+ alert('Web Audio API is not supported in this browser');
+ }
+}
+
function init_audio() {
- audioContext = new webkitAudioContext();
+ audioContext = new AudioContext();
nyquist = audioContext.sampleRate / 2;
}
@@ -599,9 +612,8 @@ function get_emphasis_disabled() {
}
function runTest() {
-
- context = new webkitOfflineAudioContext(1, sampleRate * lengthInSeconds,
- sampleRate);
+ context = new OfflineAudioContext(1, sampleRate * lengthInSeconds,
+ sampleRate);
// Connect an oscillator to a gain node to the compressor. The
// oscillator frequency is set to a high value for the (original)
// emphasis to kick in. The gain is a little extra boost to get the
@@ -627,6 +639,11 @@ function get_emphasis_disabled() {
/* Returns one DRC filter */
function drc() {
var comp = audioContext.createDynamicsCompressor();
+
+ /* The supported method names are different on browsers with different
+ * versions.*/
+ audioContext.createGainNode = (audioContext.createGainNode ||
+ audioContext.createGain);
var boost = audioContext.createGainNode();
comp.threshold.value = INIT_DRC_THRESHOLD;
comp.knee.value = INIT_DRC_KNEE;
@@ -1419,6 +1436,7 @@ function global_section(parent) {
}
window.onload = function() {
+ fix_audio_elements();
/* Detects if emphasis is disabled and sets
* browser_emphasis_disabled_detection_result. */
get_emphasis_disabled();