summaryrefslogtreecommitdiffstats
path: root/devtools/client/webaudioeditor/test/browser_audionode-actor-get-automation-data-02.js
blob: f24fb1905327df822b9de9d69c35cfb7e914188f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

/**
 * Test AudioNode#addAutomationEvent() when automation series ends with
 * `setTargetAtTime`, which approaches its target to infinity.
 */

add_task(function* () {
  let { target, front } = yield initBackend(SIMPLE_CONTEXT_URL);
  let [_, [destNode, oscNode, gainNode]] = yield Promise.all([
    front.setup({ reload: true }),
    get3(front, "create-node")
  ]);

  yield oscNode.addAutomationEvent("frequency", "setValueAtTime", [300, 0.1]);
  yield oscNode.addAutomationEvent("frequency", "linearRampToValueAtTime", [500, 0.4]);
  yield oscNode.addAutomationEvent("frequency", "exponentialRampToValueAtTime", [200, 0.6]);
  // End with a setTargetAtTime event, as the target approaches infinity, which will
  // give us more points to render than the default 2000
  yield oscNode.addAutomationEvent("frequency", "setTargetAtTime", [1000, 2, 0.5]);

  var { events, values } = yield oscNode.getAutomationData("frequency");

  is(events.length, 4, "4 recorded events returned.");
  is(values.length, 4000, "4000 value points returned when ending with exponentiall approaching automator.");

  checkAutomationValue(values, 2.01, 215.055);
  checkAutomationValue(values, 2.1, 345.930);
  checkAutomationValue(values, 3, 891.601);
  checkAutomationValue(values, 5, 998.01);

  // Refetch the automation data to ensure it recalculates correctly (bug 1118071)
  var { events, values } = yield oscNode.getAutomationData("frequency");

  checkAutomationValue(values, 2.01, 215.055);
  checkAutomationValue(values, 2.1, 345.930);
  checkAutomationValue(values, 3, 891.601);
  checkAutomationValue(values, 5, 998.01);

  yield removeTab(target.tab);
});