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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-detune-modulated-impulse.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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-detune-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/audit.js"></script>
9 </head> 9 </head>
10 10
11 <body> 11 <body>
12 <script> 12 <script>
13 13
14 var sampleRate = 44100; 14 var sampleRate = 44100;
15 15
16 // To get an observable change on detune modulation, the minimum 16 // To get an observable change on detune modulation, the minimum
17 // rendering length should greater than the rendering quantum. 17 // rendering length should greater than the rendering quantum.
18 var renderLength = 256; 18 var renderLength = 256;
19 var half = renderLength / 2; 19 var half = renderLength / 2;
20 20
21 // With the detune of 0, the duration of impulse buffer should be 4 21 // With the detune of 0, the duration of impulse buffer should be 4
22 // samples (which means the interval between impulses is 4). Increasing 22 // samples (which means the interval between impulses is 4). Increasing
23 // detune to 1200 (1 octave) decrease the interval to 2 samples. 23 // detune to 1200 (1 octave) decrease the interval to 2 samples.
24 var impulseLength = 4; 24 var impulseLength = 4;
25 25
26 var context = new OfflineAudioContext(1, renderLength, sampleRate); 26 var context = new OfflineAudioContext(1, renderLength, sampleRate);
27 var impulseBuffer, dcOffsetBuffer; 27 var impulseBuffer, dcOffsetBuffer;
28 28
29 var audit = Audit.createTaskRunner(); 29 var audit = Audit.createTaskRunner();
30 30
31 31
32 // Task: build an impulse and DC-offset buffers for testing. 32 // Task: build an impulse and DC-offset buffers for testing.
33 audit.defineTask('build-buffers', function (done) { 33 audit.define('build-buffers', (task, should) => {
34 // 4-sample impulse sample. 34 should(() => {
35 impulseBuffer = createImpulseBuffer(context, impulseLength); 35 // 4-sample impulse sample.
36 impulseBuffer = createImpulseBuffer(context, impulseLength);
36 37
37 // Create a DC offset buffer with 2 values [0, 1200] for modulating 38 // Create a DC offset buffer with 2 values [0, 1200] for modulating
38 // detune. The first half of buffer is 0 and the rest is 1200. 39 // detune. The first half of buffer is 0 and the rest is 1200.
39 dcOffsetBuffer = context.createBuffer(1, renderLength, sampleRate); 40 dcOffsetBuffer = context.createBuffer(1, renderLength,
40 var dcOffsetArray = dcOffsetBuffer.getChannelData(0); 41 sampleRate);
41 for (i = 0; i < dcOffsetArray.length; i++) { 42 var dcOffsetArray = dcOffsetBuffer.getChannelData(0);
43 for (i = 0; i < dcOffsetArray.length; i++) {
42 44
43 // Note that these values will be added to the detune AudioParam 45 // Note that these values will be added to the detune AudioParam
44 // value. For example, 1 DC offset value will result detune of 1200. 46 // value. For example, 1 DC offset value will result detune of 1200.
45 dcOffsetArray[i] = i < half ? 0 : 1200; 47 dcOffsetArray[i] = i < half ? 0 : 1200;
46 } 48 }
49 }, "Creation of impulse buffers")
50 .notThrow();
47 51
48 done(); 52 task.done();
49 }); 53 });
50 54
51 55
52 // Task: Render the actual buffer and compare with the reference. 56 // Task: Render the actual buffer and compare with the reference.
53 audit.defineTask('synthesize-verify', function (done) { 57 audit.define('synthesize-verify', (task, should) => {
54 var impulse = context.createBufferSource(); 58 var impulse = context.createBufferSource();
55 var dcOffset = context.createBufferSource(); 59 var dcOffset = context.createBufferSource();
56 60
57 impulse.buffer = impulseBuffer; 61 impulse.buffer = impulseBuffer;
58 dcOffset.buffer = dcOffsetBuffer; 62 dcOffset.buffer = dcOffsetBuffer;
59 impulse.loop = true; 63 impulse.loop = true;
60 64
61 impulse.connect(context.destination); 65 impulse.connect(context.destination);
62 dcOffset.connect(impulse.detune); 66 dcOffset.connect(impulse.detune);
63 67
(...skipping 12 matching lines...) Expand all
76 nextImpulseIndex += (i < half) ? impulseLength : impulseLength / 2; 80 nextImpulseIndex += (i < half) ? impulseLength : impulseLength / 2;
77 } else if (data[i] !== 0) { 81 } else if (data[i] !== 0) {
78 // If a value is neither 0 or 1, break the loop and fail the test. 82 // If a value is neither 0 or 1, break the loop and fail the test.
79 passed = false; 83 passed = false;
80 break; 84 break;
81 } 85 }
82 86
83 i++; 87 i++;
84 } 88 }
85 89
86 Should('Increasing detune', passed) 90 should(passed, 'Increasing detune')
87 .summarize( 91 .message(
88 'to 1200 decreased the interval between impulses to half', 92 'to 1200 decreased the interval between impulses to half',
89 'produced the incorrect result' + 'at the index ' + i); 93 'produced the incorrect result' + 'at the index ' + i);
90 }).then(done); 94 }).then(() => task.done());
91 }); 95 });
92 96
93 audit.defineTask('finish', function (done) { 97 audit.run();
94 done();
95 });
96
97 audit.runTasks(
98 'build-buffers',
99 'synthesize-verify',
100 'finish'
101 );
102
103 successfullyParsed = true;
104 </script> 98 </script>
105 </body> 99 </body>
106 100
107 </html> 101 </html>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-detune-modulation.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698