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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/Oscillator/start-sampling.html

Issue 2727663003: Move task.describe to audit.define arg (Closed)
Patch Set: Fix up expected results 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
OLDNEW
1 <!doctype html> 1 <!doctype html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Test Sampling of Oscillator Start Times</title> 4 <title>Test Sampling of Oscillator Start Times</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/audit.js"></script> 8 <script src="../resources/audit.js"></script>
9 </head> 9 </head>
10 10
11 <body> 11 <body>
12 <script> 12 <script>
13 // Experimentation indicates that this sample rate with a 440 Hz 13 // Experimentation indicates that this sample rate with a 440 Hz
14 // oscillator makes for a large difference in the difference signal if the 14 // oscillator makes for a large difference in the difference signal if the
15 // oscillator start isn't sampled correctly. 15 // oscillator start isn't sampled correctly.
16 let defaultSampleRate = 24000; 16 let defaultSampleRate = 24000;
17 let renderDuration = 1; 17 let renderDuration = 1;
18 let renderFrames = renderDuration * defaultSampleRate; 18 let renderFrames = renderDuration * defaultSampleRate;
19 19
20 let audit = Audit.createTaskRunner(); 20 let audit = Audit.createTaskRunner();
21 21
22 audit.define("basic test small", function (task, should) { 22 audit.define(
23 task.describe("Start oscillator slightly past a sample frame") 23 {
24 testStartSampling(should, 1.25, { 24 label: 'basic test small',
25 error: 1.0842e-4, 25 description: 'Start oscillator slightly past a sample frame'
26 snrThreshold: 84.054 26 },
27 }) 27 function(task, should) {
28 .then(task.done.bind(task)); 28 testStartSampling(should, 1.25, {
29 }); 29 error: 1.0842e-4,
30 snrThreshold: 84.054
31 }).then(task.done.bind(task));
32 });
30 33
31 audit.define("basic test big", function (task, should) { 34 audit.define(
32 task.describe("Start oscillator slightly before a sample frame") 35 {
33 testStartSampling(should, 1.75, { 36 label: 'basic test big',
34 error: 1.0839e-4, 37 description: 'Start oscillator slightly before a sample frame'
35 snrThreshold: 84.056 38 },
36 }) 39 function(task, should) {
37 .then(task.done.bind(task)); 40 testStartSampling(should, 1.75, {
38 }); 41 error: 1.0839e-4,
42 snrThreshold: 84.056
43 }).then(task.done.bind(task));
44 });
39 45
40 audit.define("diff big offset", function (task, should) { 46 audit.define(
41 task.describe( 47 {
42 "Test sampling with start offset greater than 1/2 sampling frame" 48 label: 'diff big offset',
43 ); 49 description:
44 // With a sample rate of 24000 Hz, and an oscillator frequency of 440 Hz 50 'Test sampling with start offset greater than 1/2 sampling frame '
45 // (the default), a quarter wave delay is 13.636363... frames. This 51 },
46 // tests the case where the starting time is more than 1/2 frame from 52 function(task, should) {
47 // the preceding sampling frame. This tests one path of the internal 53 // With a sample rate of 24000 Hz, and an oscillator frequency of
48 // implementation. 54 // 440 Hz (the default), a quarter wave delay is 13.636363...
49 testStartWithGain(should, defaultSampleRate, { 55 // frames. This tests the case where the starting time is more than
50 error: 4.1724e-7, 56 // 1/2 frame from the preceding sampling frame. This tests one path
51 snrThreshold: 137.536 57 // of the internal implementation.
52 }) 58 testStartWithGain(should, defaultSampleRate, {
53 .then(task.done.bind(task)); 59 error: 4.1724e-7,
54 }); 60 snrThreshold: 137.536
61 }).then(task.done.bind(task));
62 });
55 63
56 audit.define("diff small offset", function (task, should) { 64 audit.define(
57 task.describe( 65 {
58 "Test sampling with start offset less than 1/2 sampling frame"); 66 label: 'diff small offset',
59 // With a sample rate of 48000 Hz, and an oscillator frequency of 440 Hz 67 description:
60 // (the default), a quarter wave delay is 27.2727... frames. This tests 68 'Test sampling with start offset less than 1/2 sampling frame'
61 // the case where the starting time is less than 1/2 frame from the 69 },
62 // preceding sampling frame. This tests one path of the internal 70 function(task, should) {
63 // implementation. 71 // With a sample rate of 48000 Hz, and an oscillator frequency of
64 testStartWithGain(should, 48000, { 72 // 440 Hz (the default), a quarter wave delay is 27.2727... frames.
65 error: 4.1724e-7, 73 // This tests the case where the starting time is less than 1/2
66 snrThreshold: 137.536 74 // frame from the preceding sampling frame. This tests one path of
67 }) 75 // the internal implementation.
68 .then(task.done.bind(task)); 76 testStartWithGain(should, 48000, {
69 }); 77 error: 4.1724e-7,
78 snrThreshold: 137.536
79 }).then(task.done.bind(task));
80 });
70 81
71 function testStartSampling(should, startFrame, thresholds) { 82 function testStartSampling(should, startFrame, thresholds) {
72 // Start the oscillator in the middle of a sample frame and compare 83 // Start the oscillator in the middle of a sample frame and compare
73 // against the theoretical result. 84 // against the theoretical result.
74 let context = new OfflineAudioContext(1, renderFrames, 85 let context = new OfflineAudioContext(1, renderFrames,
75 defaultSampleRate); 86 defaultSampleRate);
76 let osc = context.createOscillator(); 87 let osc = context.createOscillator();
77 osc.connect(context.destination); 88 osc.connect(context.destination);
78 osc.start(startFrame / context.sampleRate); 89 osc.start(startFrame / context.sampleRate);
79 90
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 }); 175 });
165 should(snr, "SNR (dB)") 176 should(snr, "SNR (dB)")
166 .beGreaterThanOrEqualTo(thresholds.snrThreshold); 177 .beGreaterThanOrEqualTo(thresholds.snrThreshold);
167 }); 178 });
168 } 179 }
169 180
170 audit.run(); 181 audit.run();
171 </script> 182 </script>
172 </body> 183 </body>
173 </html> 184 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698