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

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

Issue 2550223002: Support basic stereo pan positioning for earcons (Closed)
Patch Set: 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
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..8d00b9683e6e9d7761e82f04f53fbc78da310c5d 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_X_POSITION = 2;
dmazzoni 2016/12/05 20:07:45 I'd call it something like ABS_POSITION or MAGNITU
David Tseng 2016/12/08 19:05:37 Sure; done.
+
+/**
* Fetches a sound asynchronously and loads its data into an AudioBuffer.
*
* @param {string} name The name of the sound to load.
@@ -208,10 +213,11 @@ EarconEngine.prototype.createCommonFilters = function(properties) {
if (properties.pan !== undefined) {
pan = properties.pan;
}
+
if (pan != 0) {
var panNode = this.context_.createPanner();
- panNode.setPosition(pan, 0, -1);
- panNode.setOrientation(0, 0, 1);
+ panNode.setPosition(pan, 0, 0);
+ panNode.setOrientation(0, -1, 0);
dmazzoni 2016/12/05 20:07:45 Are you sure this is right? Did the original orien
David Tseng 2016/12/08 19:05:37 I was fiddling with the audio listener earlier. Re
last.connect(panNode);
last = panNode;
}
@@ -713,3 +719,23 @@ 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 left = (rect.left + rect.width / 2) / container.width;
dmazzoni 2016/12/05 20:07:45 Maybe just x? It's really the midpoint of the rect
David Tseng 2016/12/08 19:05:37 Done.
+
+ // Clamp.
+ left = left > 1.0 ? 1.0 : left;
dmazzoni 2016/12/05 20:07:45 x = Math.max(Math.min(x, 1.0), 0.0) or something l
David Tseng 2016/12/08 19:05:37 Done.
+ left = left < 0 ? 0 : left;
+
+ // Map to between the negative maximum pan x position and the positive max x
+ // pan position.
+ left = left * 2 * EarconEngine.MAX_PAN_X_POSITION -
dmazzoni 2016/12/05 20:07:45 x = (2 * x - 1) * EarconEngine.MAX_PAN_X_POSITION
David Tseng 2016/12/08 19:05:37 Done.
+ EarconEngine.MAX_PAN_X_POSITION;
+
+ this.masterPan = left;
+};

Powered by Google App Engine
This is Rietveld 408576698