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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/audiobuffersource-detune-modulation.html

Issue 2581463002: Refactor WebAudio test directory (Closed)
Patch Set: Use correct path for wav result files Created 3 years, 12 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
(Empty)
1 <!DOCTYPE html>
2 <html>
3
4 <head>
5 <script src="../resources/js-test.js"></script>
6 <script src="resources/compatibility.js"></script>
7 <script src="resources/audit-util.js"></script>
8 <script src="resources/audio-testing.js"></script>
9 <script src="resources/audiobuffersource-testing.js"></script>
10 <script src="resources/buffer-loader.js"></script>
11 </head>
12
13 <body>
14 <script>
15 description('AudioBufferSourceNode: oscillator-driven detune modulation.');
16 window.jsTestIsAsync = true;
17
18 var sampleRate = 44100;
19 var duration = 0.25;
20
21 var context = new OfflineAudioContext(1, sampleRate * duration, sampleRate);
22 var referenceBuffer;
23
24 var audit = Audit.createTaskRunner();
25
26 // Task: Load the reference file asynchronously. In order to create a new
27 // reference file, use the task 'generate-reference' below.
28 audit.defineTask('load-reference', function (done) {
29 var loader = new BufferLoader(context, [
30 'audiobuffersource-detune-modulation-expected.wav'
31 ], function (bufferList) {
32 referenceBuffer = bufferList[0];
33 done();
34 });
35
36 loader.load();
37 });
38
39
40 // Task: Render the actual buffer and compare with the reference.
41 audit.defineTask('generate-verify', function (done) {
42
43 // With this setting, the detune will be changing continuously and
44 // repeatedly within the range of [-1200, 1200] around 440Hz, based on the
45 // input from the oscillator.
46 createSawtoothWithModulation(context, 'detune', 440, 1200);
47
48 context.startRendering().then(function (renderedBuffer) {
49 var actual = renderedBuffer.getChannelData(0);
50 var expected = referenceBuffer.getChannelData(0);
51
52 // Compare two buffers with arbitrary (yet reasonable) constraints.
53 // There parameters are determined by try bot experiments.
54 compareBuffersWithConstraints(actual, expected, {
55 thresholdSNR: 93.31,
56 thresholdDiffULP: 1.01,
57 thresholdDiffCount: 0,
58 bitDepth: 16
59 });
60
61 }).then(done);
62 });
63
64 // Task: Create a new reference audio file. See .runTasks() below to run
65 // this task.
66 audit.defineTask('generate-reference', function (done) {
67 if (!window.testRunner) {
68 done();
69 return;
70 }
71
72 // With this setting, the detune will be changing continuously and
73 // repeatedly within the range of [-1200, 1200] around 440Hz, based on the
74 // input from the oscillator.
75 createSawtoothWithModulation(context, 'detune', 440, 1200);
76
77 // |finishAudioTest| will automatically create a reference audio file from
78 // the OAC rendering if the reference file does not exist.
79 context.oncomplete = finishAudioTest;
80 context.startRendering();
81 testRunner.waitUntilDone();
82
83 done();
84 });
85
86 audit.defineTask('finish', function (done) {
87 finishJSTest();
88 done();
89 });
90
91 window.onload = function () {
92 audit.runTasks(
93 'load-reference',
94 'generate-verify',
95 'finish'
96 );
97 };
98
99 // Use this task to generate a new reference audio file. Make sure to
100 // comment out .runTasks() above before use this.
101 // audit.runTasks('generate-reference');
102
103 successfullyParsed = true;
104 </script>
105 </body>
106
107 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698