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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-playbackrate.html

Issue 2783553002: Convert AudioBufferSource tests to new Audit (Closed)
Patch Set: Indent neatly. Created 3 years, 8 months 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 unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>AudioBufferSourceNode - playbackRate test</title> 4 <title>AudioBufferSourceNode - playbackRate test</title>
5 <script src="../../resources/testharness.js"></script> 5 <script src="../../resources/testharness.js"></script>
6 <script src="../../resources/testharnessreport.js"></script> 6 <script src="../../resources/testharnessreport.js"></script>
7 <script src="../resources/audit-util.js"></script> 7 <script src="../resources/audit-util.js"></script>
8 <script src="../resources/audio-testing.js"></script> 8 <script src="../resources/audit.js"></script>
9 </head> 9 </head>
10 <body> 10 <body>
11 <script> 11 <script>
12 let audit = Audit.createTaskRunner(); 12 let audit = Audit.createTaskRunner();
13 13
14 // Any sample rate mutiple of 128 is valid for this test, but here it uses 14 // Any sample rate mutiple of 128 is valid for this test, but here it uses
15 // 48000Hz because it is a commonly used number that happens to be multiple 15 // 48000Hz because it is a commonly used number that happens to be multiple
16 // of 128. 16 // of 128.
17 let sampleRate = 48000; 17 let sampleRate = 48000;
18 18
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 actualSrc.start(noteStart); 85 actualSrc.start(noteStart);
86 actualSrc.stop(noteStart + noteDuration); 86 actualSrc.stop(noteStart + noteDuration);
87 expectedSrc.start(noteStart); 87 expectedSrc.start(noteStart);
88 expectedSrc.stop(noteStart + noteDuration); 88 expectedSrc.stop(noteStart + noteDuration);
89 } 89 }
90 90
91 91
92 // Test if AudioBufferSourceNode.playbackRate can playback at different rates 92 // Test if AudioBufferSourceNode.playbackRate can playback at different rates
93 // properly. 93 // properly.
94 audit.defineTask("playbackrate-test", function (taskDone) { 94 audit.define("playbackrate-test", (task, should) => {
95 let context = new OfflineAudioContext(2, totalDuration * 95 let context = new OfflineAudioContext(2, totalDuration *
96 sampleRate, 96 sampleRate,
97 sampleRate); 97 sampleRate);
98 fundamentalBuffer = createSineWaveBuffer(context, 98 fundamentalBuffer = createSineWaveBuffer(context,
99 pitchToFrequency(fundamentalPitch), totalDuration); 99 pitchToFrequency(fundamentalPitch), totalDuration);
100 100
101 // Schedule tests up to 60 pitches above from the fundamental pitch. 101 // Schedule tests up to 60 pitches above from the fundamental pitch.
102 for (let iteration = 0; iteration < numberOfPitches; iteration++) 102 for (let iteration = 0; iteration < numberOfPitches; iteration++)
103 runUnitTest(context, noteDuration * iteration, fundamentalPitch + 103 runUnitTest(context, noteDuration * iteration, fundamentalPitch +
104 iteration); 104 iteration);
105 105
106 // Once the rendering is complete, split the buffer into 5 octaves. Then 106 // Once the rendering is complete, split the buffer into 5 octaves. Then
107 // perform the SNR and the maximum difference ULP check for each octave 107 // perform the SNR and the maximum difference ULP check for each octave
108 // with different constraints. 108 // with different constraints.
109 context.startRendering() 109 context.startRendering()
110 .then(function (renderedBuffer) { 110 .then(function (renderedBuffer) {
111 let actual = renderedBuffer.getChannelData(0); 111 let actual = renderedBuffer.getChannelData(0);
112 let expected = renderedBuffer.getChannelData(1); 112 let expected = renderedBuffer.getChannelData(1);
113 let octaveLength = Math.floor(noteDuration * 12 * sampleRate); 113 let octaveLength = Math.floor(noteDuration * 12 * sampleRate);
114 114
115 for (let i = 0; i < numberOfPitches / 12; i++) { 115 for (let i = 0; i < numberOfPitches / 12; i++) {
116 let start = i * octaveLength; 116 let start = i * octaveLength;
117 let end = (i + 1) * octaveLength; 117 let end = (i + 1) * octaveLength;
118 let octaveActual = actual.subarray(start, end); 118 let octaveActual = actual.subarray(start, end);
119 let octaveExpected = expected.subarray(start, end); 119 let octaveExpected = expected.subarray(start, end);
120 120
121 compareBuffersWithConstraints(octaveActual, octaveExpected, 121 compareBuffersWithConstraints(should, octaveActual, octaveExpected,
122 { 122 {
123 prefix: i, 123 prefix: i,
124 thresholdSNR: testConstraints[i].thresholdSNR, 124 thresholdSNR: testConstraints[i].thresholdSNR,
125 thresholdDiffULP: testConstraints[i].thresholdDiffULP 125 thresholdDiffULP: testConstraints[i].thresholdDiffULP
126 }); 126 });
127 } 127 }
128 128
129 }) 129 })
130 .then(taskDone); 130 .then(() => task.done());
131 }); 131 });
132 132
133 audit.runTasks(); 133 audit.run();
134 </script> 134 </script>
135 </body> 135 </body>
136 </html> 136 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698