OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview This is the low-level class that generates ChromeVox's | 6 * @fileoverview This is the low-level class that generates ChromeVox's |
7 * earcons. It's designed to be self-contained and not depend on the | 7 * earcons. It's designed to be self-contained and not depend on the |
8 * rest of the code. | 8 * rest of the code. |
9 */ | 9 */ |
10 | 10 |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 * @param {string} url The url where the sound should be fetched from. | 168 * @param {string} url The url where the sound should be fetched from. |
169 */ | 169 */ |
170 EarconEngine.prototype.loadSound = function(name, url) { | 170 EarconEngine.prototype.loadSound = function(name, url) { |
171 var request = new XMLHttpRequest(); | 171 var request = new XMLHttpRequest(); |
172 request.open('GET', url, true); | 172 request.open('GET', url, true); |
173 request.responseType = 'arraybuffer'; | 173 request.responseType = 'arraybuffer'; |
174 | 174 |
175 // Decode asynchronously. | 175 // Decode asynchronously. |
176 request.onload = (function() { | 176 request.onload = (function() { |
177 this.context_.decodeAudioData( | 177 this.context_.decodeAudioData( |
178 /** @type {ArrayBuffer} */ (request.response), | 178 /** @type {!ArrayBuffer} */ (request.response), |
179 (function(buffer) { | 179 (function(buffer) { |
180 this.buffers_[name] = buffer; | 180 this.buffers_[name] = buffer; |
181 }).bind(this)); | 181 }).bind(this)); |
182 }).bind(this); | 182 }).bind(this); |
183 request.send(); | 183 request.send(); |
184 }; | 184 }; |
185 | 185 |
186 /** | 186 /** |
187 * Return an AudioNode containing the final processing that all | 187 * Return an AudioNode containing the final processing that all |
188 * sounds go through: master volume / gain, panning, and reverb. | 188 * sounds go through: master volume / gain, panning, and reverb. |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 | 729 |
730 // Clamp. | 730 // Clamp. |
731 x = Math.min(Math.max(x, 0.0), 1.0); | 731 x = Math.min(Math.max(x, 0.0), 1.0); |
732 | 732 |
733 // Map to between the negative maximum pan x position and the positive max x | 733 // Map to between the negative maximum pan x position and the positive max x |
734 // pan position. | 734 // pan position. |
735 x = (2 * x - 1) * EarconEngine.MAX_PAN_ABS_X_POSITION; | 735 x = (2 * x - 1) * EarconEngine.MAX_PAN_ABS_X_POSITION; |
736 | 736 |
737 this.masterPan = x; | 737 this.masterPan = x; |
738 }; | 738 }; |
OLD | NEW |