Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2533)

Unified Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/earcon_engine.js

Issue 2550223002: Support basic stereo pan positioning for earcons (Closed)
Patch Set: Fix test. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/chromevox/cvox2/background/next_earcons.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/earcon_engine.js
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/earcon_engine.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/earcon_engine.js
index 10ab4d749687511e677466f85b149b9e039d72f5..2b595fb6d35792de366368fa07f8f42cea08d3ab 100644
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/earcon_engine.js
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/earcon_engine.js
@@ -157,6 +157,11 @@ EarconEngine.HALF_STEP = Math.pow(2.0, 1.0 / 12.0);
EarconEngine.BASE_URL = chrome.extension.getURL('cvox2/background/earcons/');
/**
+ * The maximum value to pass to PannerNode.setPosition.
+ */
+EarconEngine.MAX_PAN_ABS_X_POSITION = 4;
+
+/**
* Fetches a sound asynchronously and loads its data into an AudioBuffer.
*
* @param {string} name The name of the sound to load.
@@ -210,7 +215,7 @@ EarconEngine.prototype.createCommonFilters = function(properties) {
}
if (pan != 0) {
var panNode = this.context_.createPanner();
- panNode.setPosition(pan, 0, -1);
+ panNode.setPosition(pan, 0, 0);
panNode.setOrientation(0, 0, 1);
last.connect(panNode);
last = panNode;
@@ -713,3 +718,21 @@ EarconEngine.prototype.cancelProgress = function() {
window.clearInterval(this.progressIntervalID_);
this.progressIntervalID_ = null;
};
+
+/**
+ * @param {chrome.automation.Rect} rect
+ * @param {chrome.automation.Rect} container
+ */
+EarconEngine.prototype.setPositionForRect = function(rect, container) {
+ // The horizontal position computed as a percentage relative to its container.
+ var x = (rect.left + rect.width / 2) / container.width;
+
+ // Clamp.
+ x = Math.min(Math.max(x, 0.0), 1.0);
+
+ // Map to between the negative maximum pan x position and the positive max x
+ // pan position.
+ x = (2 * x - 1) * EarconEngine.MAX_PAN_ABS_X_POSITION;
+
+ this.masterPan = x;
+};
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/chromevox/cvox2/background/next_earcons.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698