OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 /** | 6 /** |
7 * @fileOverview This file includes legacy utility functions for the layout | 7 * @fileOverview This file includes legacy utility functions for the layout |
8 * test. | 8 * test. |
9 */ | 9 */ |
10 | 10 |
| 11 // How many frames in a WebAudio render quantum. |
| 12 let RENDER_QUANTUM_FRAMES = 128; |
11 | 13 |
12 function writeString(s, a, offset) { | 14 function writeString(s, a, offset) { |
13 for (let i = 0; i < s.length; ++i) { | 15 for (let i = 0; i < s.length; ++i) { |
14 a[offset + i] = s.charCodeAt(i); | 16 a[offset + i] = s.charCodeAt(i); |
15 } | 17 } |
16 } | 18 } |
17 | 19 |
18 function writeInt16(n, a, offset) { | 20 function writeInt16(n, a, offset) { |
19 n = Math.floor(n); | 21 n = Math.floor(n); |
20 | 22 |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 let length = Math.min(actual.length, expected.length); | 339 let length = Math.min(actual.length, expected.length); |
338 | 340 |
339 for (let k = 0; k < length; ++k) { | 341 for (let k = 0; k < length; ++k) { |
340 let diff = actual[k] - expected[k]; | 342 let diff = actual[k] - expected[k]; |
341 signalPower += expected[k] * expected[k]; | 343 signalPower += expected[k] * expected[k]; |
342 noisePower += diff * diff; | 344 noisePower += diff * diff; |
343 } | 345 } |
344 | 346 |
345 return signalPower / noisePower; | 347 return signalPower / noisePower; |
346 } | 348 } |
OLD | NEW |