browser_audionode-actor-get-automation-data-02.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. /**
  4. * Test AudioNode#addAutomationEvent() when automation series ends with
  5. * `setTargetAtTime`, which approaches its target to infinity.
  6. */
  7. add_task(function* () {
  8. let { target, front } = yield initBackend(SIMPLE_CONTEXT_URL);
  9. let [_, [destNode, oscNode, gainNode]] = yield Promise.all([
  10. front.setup({ reload: true }),
  11. get3(front, "create-node")
  12. ]);
  13. yield oscNode.addAutomationEvent("frequency", "setValueAtTime", [300, 0.1]);
  14. yield oscNode.addAutomationEvent("frequency", "linearRampToValueAtTime", [500, 0.4]);
  15. yield oscNode.addAutomationEvent("frequency", "exponentialRampToValueAtTime", [200, 0.6]);
  16. // End with a setTargetAtTime event, as the target approaches infinity, which will
  17. // give us more points to render than the default 2000
  18. yield oscNode.addAutomationEvent("frequency", "setTargetAtTime", [1000, 2, 0.5]);
  19. var { events, values } = yield oscNode.getAutomationData("frequency");
  20. is(events.length, 4, "4 recorded events returned.");
  21. is(values.length, 4000, "4000 value points returned when ending with exponentiall approaching automator.");
  22. checkAutomationValue(values, 2.01, 215.055);
  23. checkAutomationValue(values, 2.1, 345.930);
  24. checkAutomationValue(values, 3, 891.601);
  25. checkAutomationValue(values, 5, 998.01);
  26. // Refetch the automation data to ensure it recalculates correctly (bug 1118071)
  27. var { events, values } = yield oscNode.getAutomationData("frequency");
  28. checkAutomationValue(values, 2.01, 215.055);
  29. checkAutomationValue(values, 2.1, 345.930);
  30. checkAutomationValue(values, 3, 891.601);
  31. checkAutomationValue(values, 5, 998.01);
  32. yield removeTab(target.tab);
  33. });