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

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

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

Powered by Google App Engine
This is Rietveld 408576698