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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/WaveShaper/waveshaper-copy-curve.html

Issue 2895963003: Apply layout-test-tidy to LayoutTests/webaudio (Closed)
Patch Set: Created 3 years, 7 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 WaveShaper Copies Curve Data</title> 4 <title>
5 Test WaveShaper Copies Curve Data
6 </title>
5 <script src="../../resources/testharness.js"></script> 7 <script src="../../resources/testharness.js"></script>
6 <script src="../../resources/testharnessreport.js"></script> 8 <script src="../../resources/testharnessreport.js"></script>
7 <script src="../resources/audit-util.js"></script> 9 <script src="../resources/audit-util.js"></script>
8 <script src="../resources/audit.js"></script> 10 <script src="../resources/audit.js"></script>
9 </head> 11 </head>
10
11 <body> 12 <body>
12 <script> 13 <script id="layout-test-code">
13 // Sample rate and number of frames are fairly arbitrary. We need to 14 // Sample rate and number of frames are fairly arbitrary. We need to
14 // render, however, at least 384 frames. 1024 is a nice small value. 15 // render, however, at least 384 frames. 1024 is a nice small value.
15 var sampleRate = 16000; 16 let sampleRate = 16000;
16 var renderFrames = 1024; 17 let renderFrames = 1024;
17 18
18 var audit = Audit.createTaskRunner(); 19 let audit = Audit.createTaskRunner();
19 20
20 audit.define("test copying", (task, should) => { 21 audit.define('test copying', (task, should) => {
21 // Two-channel context; channel 0 contains the test data and channel 1 22 // Two-channel context; channel 0 contains the test data and channel 1
22 // contains the expected result. Channel 1 has the normal WaveShaper 23 // contains the expected result. Channel 1 has the normal WaveShaper
23 // output and channel 0 has the WaveShaper output with a modified curve. 24 // output and channel 0 has the WaveShaper output with a modified curve.
24 var context = new OfflineAudioContext(2, renderFrames, sampleRate); 25 let context = new OfflineAudioContext(2, renderFrames, sampleRate);
25 26
26 // Just use a default oscillator as the source. Doesn't really matter 27 // Just use a default oscillator as the source. Doesn't really matter
27 // what we use. 28 // what we use.
28 var src = context.createOscillator(); 29 let src = context.createOscillator();
29 src.type = "sawtooth"; 30 src.type = 'sawtooth';
30 31
31 // Create the wave shapers: ws0 is the test shaper, and ws1 is the 32 // Create the wave shapers: ws0 is the test shaper, and ws1 is the
32 // reference wave shaper. 33 // reference wave shaper.
33 var ws0 = context.createWaveShaper(); 34 let ws0 = context.createWaveShaper();
34 var ws1 = context.createWaveShaper(); 35 let ws1 = context.createWaveShaper();
35 36
36 // Wave shaper curves. Doesn't really matter what we use as long as it 37 // Wave shaper curves. Doesn't really matter what we use as long as it
37 // modifies the input in some way. Thus, keep it simple and just invert 38 // modifies the input in some way. Thus, keep it simple and just invert
38 // the input. 39 // the input.
39 var desiredCurve = [1, 0, -1]; 40 let desiredCurve = [1, 0, -1];
40 var curve0 = Float32Array.from(desiredCurve); 41 let curve0 = Float32Array.from(desiredCurve);
41 var curve1 = Float32Array.from(desiredCurve); 42 let curve1 = Float32Array.from(desiredCurve);
42 43
43 ws0.curve = curve0; 44 ws0.curve = curve0;
44 ws1.curve = curve1; 45 ws1.curve = curve1;
45 46
46 var merger = context.createChannelMerger(2); 47 let merger = context.createChannelMerger(2);
47 48
48 // Connect the graph 49 // Connect the graph
49 src.connect(ws0); 50 src.connect(ws0);
50 src.connect(ws1); 51 src.connect(ws1);
51 52
52 ws0.connect(merger, 0, 0); 53 ws0.connect(merger, 0, 0);
53 ws1.connect(merger, 0, 1); 54 ws1.connect(merger, 0, 1);
54 55
55 merger.connect(context.destination); 56 merger.connect(context.destination);
56 57
57 // Let the context run for a bit and then modify the curve for ws0. 58 // Let the context run for a bit and then modify the curve for ws0.
58 // Doesn't really matter what we modify the curve to as long as it's 59 // Doesn't really matter what we modify the curve to as long as it's
59 // different. 60 // different.
60 context.suspend(256 / context.sampleRate) 61 context.suspend(256 / context.sampleRate)
61 .then(function () { 62 .then(function() {
62 curve0[0] = -0.5; 63 curve0[0] = -0.5;
63 curve0[1] = 0.125; 64 curve0[1] = 0.125;
64 curve0[2] = 0.75; 65 curve0[2] = 0.75;
65 }) 66 })
66 .then(context.resume.bind(context)); 67 .then(context.resume.bind(context));
67 68
68 src.start(); 69 src.start();
69 70
70 context.startRendering().then(function (renderedBuffer) { 71 context.startRendering()
71 var actual = renderedBuffer.getChannelData(0); 72 .then(function(renderedBuffer) {
72 var expected = renderedBuffer.getChannelData(1); 73 let actual = renderedBuffer.getChannelData(0);
74 let expected = renderedBuffer.getChannelData(1);
73 75
74 // Modifying the wave shaper curve should not modify the output so the 76 // Modifying the wave shaper curve should not modify the output so
75 // outputs from the two wave shaper nodes should be exactly identical. 77 // the outputs from the two wave shaper nodes should be exactly
76 should(actual, "WaveShaper with modified curve") 78 // identical.
77 .beEqualToArray(expected); 79 should(actual, 'WaveShaper with modified curve')
80 .beEqualToArray(expected);
78 81
79 }).then(() => task.done()); 82 })
83 .then(() => task.done());
80 }); 84 });
81 85
82 audit.run(); 86 audit.run();
83 </script> 87 </script>
84 </body> 88 </body>
85 </html> 89 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698