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

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

Issue 2223613002: WaveShaperNode should copy its curve. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add tests for setting attributes and verifying them. Created 4 years, 4 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 <head>
4 <title>Test WaveShaper Copies Curve Data</title>
5 <script src="../resources/testharness.js"></script>
6 <script src="../resources/testharnessreport.js"></script>
7 <script src="resources/compatibility.js"></script>
hongchan 2016/08/11 18:48:58 Let's remove this. We don't need this any more.
Raymond Toy 2016/08/11 20:11:47 Done.
8 <script src="resources/audio-testing.js"></script>
9 </head>
10
11 <body>
12 <script>
13 var sampleRate = 16000;
14 var renderFrames = 1024;
15
16 var audit = Audit.createTaskRunner();
17
18 audit.defineTask("test copying", function (done) {
19 // Two-channel context; channel 0 contains the test data and channel 1
20 // contains the expected result. Channel 1 has the normal WaveShaper
21 // output and channel 0 has the WaveShaper output with a modified curve.
22 var context = new OfflineAudioContext(2, renderFrames, sampleRate);
23
24 // Just use a default oscillator as the source. Doesn't really matter
25 // what we use.
26 var src = context.createOscillator();
27 src.type = "sawtooth";
28
29 // Create the wave shapers: ws0 is the test shaper, and ws1 is the
30 // reference wave shaper.
31 var ws0 = context.createWaveShaper();
32 var ws1 = context.createWaveShaper();
33
34 // Wave shaper curves. Doesn't really matter what we use as long as it
35 // modifies the input in some way. Thus, keep it simple and just invert
36 // the input.
37 var desiredCurve = [1, 0, -1];
38 var curve0 = Float32Array.from(desiredCurve);
39 var curve1 = Float32Array.from(desiredCurve);
40
41 ws0.curve = curve0;
42 ws1.curve = curve1;
43
44 var merger = context.createChannelMerger(2);
45
46 // Connect the graph
47 src.connect(ws0);
48 src.connect(ws1);
49
50 ws0.connect(merger, 0, 0);
51 ws1.connect(merger, 0, 1);
52
53 merger.connect(context.destination);
54
55 // Let the context run for a bit and then modify the curve for ws0.
56 // Doesn't really matter what we modify the curve to as long as it's
57 // different.
58 context.suspend(256 / context.sampleRate)
59 .then(function () {
60 curve0[0] = -0.5;
61 curve0[1] = 0.125;
62 curve0[2] = 0.75;
63 })
64 .then(context.resume.bind(context));
65
66 // Let's go!
hongchan 2016/08/11 18:48:58 Seems unnecessary, but I'll leave it up to you.
Raymond Toy 2016/08/11 20:11:47 Done.
67 src.start();
68
69 context.startRendering().then(function (renderedBuffer) {
70 var actual = renderedBuffer.getChannelData(0);
71 var expected = renderedBuffer.getChannelData(1);
72
73 // Modifying the wave shaper curve should not modify the output so the
74 // outputs from the two wave shaper nodes should be exactly identical.
75 var success = Should("WaveShaper with modified curve", actual)
76 .beEqualToArray(expected);
77
78 if (success) {
79 test(function () {
80 assert_true(true);
81 }, "Output correctly did not change with modified WaveShaper curve." );
82 } else {
83 test(function () {
84 assert_true(false);
85 }, "Output incorrectly changed due to modified WaveShaper curve.");
86 }
87 }).then(done);
88 });
89
90 audit.runTasks();
91 </script>
92 </body>
93 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698