OLD | NEW |
1 var defaultSampleRate = 44100.0; | 1 var defaultSampleRate = 44100.0; |
2 var lengthInSeconds = 1; | 2 var lengthInSeconds = 1; |
3 | 3 |
4 var context = 0; | 4 var context = 0; |
5 var bufferLoader = 0; | 5 var bufferLoader = 0; |
6 | 6 |
7 // Run test by loading the file specified by |url|. An optional sample rate can
be given to | 7 // Run test by loading the file specified by |url|. An optional sample rate can |
8 // select a context with a different sample rate. The default value is |default
SampleRate|. | 8 // be given to select a context with a different sample rate. The default value |
9 function runDecodingTest(url, optionalSampleRate) | 9 // is |defaultSampleRate|. |
10 { | 10 function runDecodingTest(url, optionalSampleRate) { |
11 if (!window.testRunner) | 11 if (!window.testRunner) |
12 return; | 12 return; |
13 | 13 |
14 var sampleRate = (typeof optionalSampleRate === "undefined") ? defaultSample
Rate : optionalSampleRate; | 14 let sampleRate = (typeof optionalSampleRate === 'undefined') ? |
| 15 defaultSampleRate : |
| 16 optionalSampleRate; |
15 | 17 |
16 // Create offline audio context. | 18 // Create offline audio context. |
17 context = new OfflineAudioContext(1, sampleRate * lengthInSeconds, sampleRat
e); | 19 context = |
18 | 20 new OfflineAudioContext(1, sampleRate * lengthInSeconds, sampleRate); |
19 bufferLoader = new BufferLoader( | 21 |
20 context, | 22 bufferLoader = new BufferLoader(context, [url], finishedLoading); |
21 [ url ], | 23 |
22 finishedLoading | 24 bufferLoader.load(); |
23 ); | 25 testRunner.waitUntilDone(); |
24 | |
25 bufferLoader.load(); | |
26 testRunner.waitUntilDone(); | |
27 } | 26 } |
28 | 27 |
29 function finishedLoading(bufferList) | 28 function finishedLoading(bufferList) { |
30 { | 29 testRunner.setAudioData(createAudioData(bufferList[0])); |
31 testRunner.setAudioData(createAudioData(bufferList[0])); | 30 testRunner.notifyDone(); |
32 testRunner.notifyDone(); | |
33 } | 31 } |
34 | |
OLD | NEW |