Changeset 265152 in webkit


Ignore:
Timestamp:
Jul 31, 2020 11:47:49 AM (4 years ago)
Author:
Chris Dumez
Message:

Add constructor for WaveShaperNode
https://bugs.webkit.org/show_bug.cgi?id=214989

Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

Rebaseline WPT tests now that more checks are passing.

  • web-platform-tests/webaudio/idlharness.https.window-expected.txt:
  • web-platform-tests/webaudio/the-audio-api/the-waveshapernode-interface/ctor-waveshaper-expected.txt:
  • web-platform-tests/webaudio/the-audio-api/the-waveshapernode-interface/waveshaper-simple-expected.txt:

Source/WebCore:

Add constructor for WaveShaperNode:

No new tests, rebaselined existing tests.

  • CMakeLists.txt:
  • DerivedSources-input.xcfilelist:
  • DerivedSources-output.xcfilelist:
  • DerivedSources.make:
  • Modules/webaudio/BaseAudioContext.cpp:

(WebCore::BaseAudioContext::createWaveShaper):

  • Modules/webaudio/OverSampleType.h: Copied from Source/WebCore/Modules/webaudio/WaveShaperNode.idl.
  • Modules/webaudio/OverSampleType.idl: Copied from Source/WebCore/Modules/webaudio/WaveShaperNode.idl.
  • Modules/webaudio/WaveShaperNode.cpp:

(WebCore::WaveShaperNode::create):
(WebCore::WaveShaperNode::setCurve):
(WebCore::processorType):

  • Modules/webaudio/WaveShaperNode.h:

(WTF::LogArgument<WebCore::OverSampleType>::toString):

  • Modules/webaudio/WaveShaperNode.idl:
  • Modules/webaudio/WaveShaperOptions.h: Copied from Source/WebCore/Modules/webaudio/WaveShaperNode.idl.
  • Modules/webaudio/WaveShaperOptions.idl: Copied from Source/WebCore/Modules/webaudio/WaveShaperNode.idl.
  • Sources.txt:
  • WebCore.xcodeproj/project.pbxproj:
Location:
trunk
Files:
15 edited
4 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r265086 r265152  
     12020-07-31  Chris Dumez  <cdumez@apple.com>
     2
     3        Add constructor for WaveShaperNode
     4        https://bugs.webkit.org/show_bug.cgi?id=214989
     5
     6        Reviewed by Youenn Fablet.
     7
     8        Rebaseline WPT tests now that more checks are passing.
     9
     10        * web-platform-tests/webaudio/idlharness.https.window-expected.txt:
     11        * web-platform-tests/webaudio/the-audio-api/the-waveshapernode-interface/ctor-waveshaper-expected.txt:
     12        * web-platform-tests/webaudio/the-audio-api/the-waveshapernode-interface/waveshaper-simple-expected.txt:
     13
    1142020-07-30  Chris Dumez  <cdumez@apple.com>
    215
  • trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/idlharness.https.window-expected.txt

    r265086 r265152  
    10451045FAIL AudioNode interface: new StereoPannerNode(context) must inherit property "channelInterpretation" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: StereoPannerNode"
    10461046PASS WaveShaperNode interface: existence and properties of interface object
    1047 FAIL WaveShaperNode interface object length assert_equals: wrong value for WaveShaperNode.length expected 1 but got 0
     1047PASS WaveShaperNode interface object length
    10481048PASS WaveShaperNode interface object name
    10491049PASS WaveShaperNode interface: existence and properties of interface prototype object
     
    10521052PASS WaveShaperNode interface: attribute curve
    10531053PASS WaveShaperNode interface: attribute oversample
    1054 FAIL WaveShaperNode must be primary interface of new WaveShaperNode(context) assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new WaveShaperNode(context)')"
    1055 FAIL Stringification of new WaveShaperNode(context) assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new WaveShaperNode(context)')"
    1056 FAIL WaveShaperNode interface: new WaveShaperNode(context) must inherit property "curve" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new WaveShaperNode(context)')"
    1057 FAIL WaveShaperNode interface: new WaveShaperNode(context) must inherit property "oversample" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new WaveShaperNode(context)')"
    1058 FAIL AudioNode interface: new WaveShaperNode(context) must inherit property "connect(AudioNode, optional unsigned long, optional unsigned long)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new WaveShaperNode(context)')"
    1059 FAIL AudioNode interface: calling connect(AudioNode, optional unsigned long, optional unsigned long) on new WaveShaperNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new WaveShaperNode(context)')"
    1060 FAIL AudioNode interface: new WaveShaperNode(context) must inherit property "connect(AudioParam, optional unsigned long)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new WaveShaperNode(context)')"
    1061 FAIL AudioNode interface: calling connect(AudioParam, optional unsigned long) on new WaveShaperNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new WaveShaperNode(context)')"
    1062 FAIL AudioNode interface: new WaveShaperNode(context) must inherit property "disconnect()" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new WaveShaperNode(context)')"
    1063 FAIL AudioNode interface: new WaveShaperNode(context) must inherit property "disconnect(unsigned long)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new WaveShaperNode(context)')"
    1064 FAIL AudioNode interface: calling disconnect(unsigned long) on new WaveShaperNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new WaveShaperNode(context)')"
    1065 FAIL AudioNode interface: new WaveShaperNode(context) must inherit property "disconnect(AudioNode)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new WaveShaperNode(context)')"
    1066 FAIL AudioNode interface: calling disconnect(AudioNode) on new WaveShaperNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new WaveShaperNode(context)')"
    1067 FAIL AudioNode interface: new WaveShaperNode(context) must inherit property "disconnect(AudioNode, unsigned long)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new WaveShaperNode(context)')"
    1068 FAIL AudioNode interface: calling disconnect(AudioNode, unsigned long) on new WaveShaperNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new WaveShaperNode(context)')"
    1069 FAIL AudioNode interface: new WaveShaperNode(context) must inherit property "disconnect(AudioNode, unsigned long, unsigned long)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new WaveShaperNode(context)')"
    1070 FAIL AudioNode interface: calling disconnect(AudioNode, unsigned long, unsigned long) on new WaveShaperNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new WaveShaperNode(context)')"
    1071 FAIL AudioNode interface: new WaveShaperNode(context) must inherit property "disconnect(AudioParam)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new WaveShaperNode(context)')"
    1072 FAIL AudioNode interface: calling disconnect(AudioParam) on new WaveShaperNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new WaveShaperNode(context)')"
    1073 FAIL AudioNode interface: new WaveShaperNode(context) must inherit property "disconnect(AudioParam, unsigned long)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new WaveShaperNode(context)')"
    1074 FAIL AudioNode interface: calling disconnect(AudioParam, unsigned long) on new WaveShaperNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new WaveShaperNode(context)')"
    1075 FAIL AudioNode interface: new WaveShaperNode(context) must inherit property "context" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new WaveShaperNode(context)')"
    1076 FAIL AudioNode interface: new WaveShaperNode(context) must inherit property "numberOfInputs" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new WaveShaperNode(context)')"
    1077 FAIL AudioNode interface: new WaveShaperNode(context) must inherit property "numberOfOutputs" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new WaveShaperNode(context)')"
    1078 FAIL AudioNode interface: new WaveShaperNode(context) must inherit property "channelCount" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new WaveShaperNode(context)')"
    1079 FAIL AudioNode interface: new WaveShaperNode(context) must inherit property "channelCountMode" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new WaveShaperNode(context)')"
    1080 FAIL AudioNode interface: new WaveShaperNode(context) must inherit property "channelInterpretation" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new WaveShaperNode(context)')"
     1054PASS WaveShaperNode must be primary interface of new WaveShaperNode(context)
     1055PASS Stringification of new WaveShaperNode(context)
     1056PASS WaveShaperNode interface: new WaveShaperNode(context) must inherit property "curve" with the proper type
     1057PASS WaveShaperNode interface: new WaveShaperNode(context) must inherit property "oversample" with the proper type
     1058PASS AudioNode interface: new WaveShaperNode(context) must inherit property "connect(AudioNode, optional unsigned long, optional unsigned long)" with the proper type
     1059PASS AudioNode interface: calling connect(AudioNode, optional unsigned long, optional unsigned long) on new WaveShaperNode(context) with too few arguments must throw TypeError
     1060PASS AudioNode interface: new WaveShaperNode(context) must inherit property "connect(AudioParam, optional unsigned long)" with the proper type
     1061PASS AudioNode interface: calling connect(AudioParam, optional unsigned long) on new WaveShaperNode(context) with too few arguments must throw TypeError
     1062PASS AudioNode interface: new WaveShaperNode(context) must inherit property "disconnect()" with the proper type
     1063PASS AudioNode interface: new WaveShaperNode(context) must inherit property "disconnect(unsigned long)" with the proper type
     1064PASS AudioNode interface: calling disconnect(unsigned long) on new WaveShaperNode(context) with too few arguments must throw TypeError
     1065PASS AudioNode interface: new WaveShaperNode(context) must inherit property "disconnect(AudioNode)" with the proper type
     1066PASS AudioNode interface: calling disconnect(AudioNode) on new WaveShaperNode(context) with too few arguments must throw TypeError
     1067PASS AudioNode interface: new WaveShaperNode(context) must inherit property "disconnect(AudioNode, unsigned long)" with the proper type
     1068PASS AudioNode interface: calling disconnect(AudioNode, unsigned long) on new WaveShaperNode(context) with too few arguments must throw TypeError
     1069PASS AudioNode interface: new WaveShaperNode(context) must inherit property "disconnect(AudioNode, unsigned long, unsigned long)" with the proper type
     1070PASS AudioNode interface: calling disconnect(AudioNode, unsigned long, unsigned long) on new WaveShaperNode(context) with too few arguments must throw TypeError
     1071PASS AudioNode interface: new WaveShaperNode(context) must inherit property "disconnect(AudioParam)" with the proper type
     1072PASS AudioNode interface: calling disconnect(AudioParam) on new WaveShaperNode(context) with too few arguments must throw TypeError
     1073PASS AudioNode interface: new WaveShaperNode(context) must inherit property "disconnect(AudioParam, unsigned long)" with the proper type
     1074PASS AudioNode interface: calling disconnect(AudioParam, unsigned long) on new WaveShaperNode(context) with too few arguments must throw TypeError
     1075PASS AudioNode interface: new WaveShaperNode(context) must inherit property "context" with the proper type
     1076PASS AudioNode interface: new WaveShaperNode(context) must inherit property "numberOfInputs" with the proper type
     1077PASS AudioNode interface: new WaveShaperNode(context) must inherit property "numberOfOutputs" with the proper type
     1078PASS AudioNode interface: new WaveShaperNode(context) must inherit property "channelCount" with the proper type
     1079PASS AudioNode interface: new WaveShaperNode(context) must inherit property "channelCountMode" with the proper type
     1080PASS AudioNode interface: new WaveShaperNode(context) must inherit property "channelInterpretation" with the proper type
    10811081FAIL AudioWorklet interface: existence and properties of interface object assert_own_property: self does not have own property "AudioWorklet" expected property "AudioWorklet" missing
    10821082FAIL AudioWorklet interface object length assert_own_property: self does not have own property "AudioWorklet" expected property "AudioWorklet" missing
  • trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-waveshapernode-interface/ctor-waveshaper-expected.txt

    r262405 r265152  
    33PASS Executing "initialize"
    44PASS Executing "incorrect construction"
    5 FAIL Executing "valid default construction" promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'node.numberOfInputs')"
    6 FAIL Executing "test AudioNodeOptions" promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'node.channelCount')"
    7 FAIL Executing "valid non-default" promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'node.curve')"
     5PASS Executing "valid default construction"
     6PASS Executing "test AudioNodeOptions"
     7PASS Executing "valid non-default"
    88PASS Audit report
    99PASS > [initialize] 
     
    1111PASS < [initialize] All assertions passed. (total 1 assertions)
    1212PASS > [incorrect construction] 
    13 PASS   new WaveShaperNode() threw TypeError: "function is not a constructor (evaluating 'new window[name]()')".
    14 PASS   new WaveShaperNode(1) threw TypeError: "function is not a constructor (evaluating 'new window[name](1)')".
    15 PASS   new WaveShaperNode(context, 42) threw TypeError: "function is not a constructor (evaluating 'new window[name](context, 42)')".
     13PASS   new WaveShaperNode() threw TypeError: "Not enough arguments".
     14PASS   new WaveShaperNode(1) threw TypeError: "Argument 1 ('context') to the WaveShaperNode constructor must be an instance of BaseAudioContext".
     15PASS   new WaveShaperNode(context, 42) threw TypeError: "Type error".
    1616PASS < [incorrect construction] All assertions passed. (total 3 assertions)
    1717PASS > [valid default construction] 
    18 FAIL X node0 = new WaveShaperNode(context) incorrectly threw TypeError: "function is not a constructor (evaluating 'new window[name](context, options.constructorOptions)')". assert_true: expected true got false
    19 FAIL X node0 instanceof WaveShaperNode is not equal to true. Got false. assert_true: expected true got false
     18PASS   node0 = new WaveShaperNode(context) did not throw an exception.
     19PASS   node0 instanceof WaveShaperNode is equal to true.
     20PASS   node0.numberOfInputs is equal to 1.
     21PASS   node0.numberOfOutputs is equal to 1.
     22PASS   node0.channelCount is equal to 2.
     23PASS   node0.channelCountMode is equal to max.
     24PASS   node0.channelInterpretation is equal to speakers.
     25PASS   node0.curve is equal to null.
     26PASS   node0.oversample is equal to none.
     27PASS < [valid default construction] All assertions passed. (total 9 assertions)
    2028PASS > [test AudioNodeOptions] 
    21 FAIL X new WaveShaperNode(c, {channelCount: 17}) incorrectly threw TypeError: "function is not a constructor (evaluating 'new window[nodeName]')". assert_true: expected true got false
     29PASS   new WaveShaperNode(c, {channelCount: 17}) did not throw an exception.
     30PASS   node.channelCount is equal to 17.
     31PASS   new WaveShaperNode(c, {channelCount: 0}) threw InvalidStateError: "The object is in an invalid state.".
     32PASS   new WaveShaperNode(c, {channelCount: 99}) threw InvalidStateError: "The object is in an invalid state.".
     33PASS   new WaveShaperNode(c, {channelCountMode: "max"} did not throw an exception.
     34PASS   node.channelCountMode is equal to max.
     35PASS   new WaveShaperNode(c, {channelCountMode: "max"}) did not throw an exception.
     36PASS   node.channelCountMode after valid setter is equal to max.
     37PASS   new WaveShaperNode(c, {channelCountMode: "clamped-max"}) did not throw an exception.
     38PASS   node.channelCountMode after valid setter is equal to clamped-max.
     39PASS   new WaveShaperNode(c, {channelCountMode: "explicit"}) did not throw an exception.
     40PASS   node.channelCountMode after valid setter is equal to explicit.
     41PASS   new WaveShaperNode(c, {channelCountMode: "foobar"} threw TypeError: "Type error".
     42PASS   node.channelCountMode after invalid setter is equal to explicit.
     43PASS   new WaveShaperNode(c, {channelInterpretation: "speakers"}) did not throw an exception.
     44PASS   node.channelInterpretation is equal to speakers.
     45PASS   new WaveShaperNode(c, {channelInterpretation: "discrete"}) did not throw an exception.
     46PASS   node.channelInterpretation is equal to discrete.
     47PASS   new WaveShaperNode(c, {channelInterpretation: "foobar"}) threw TypeError: "Type error".
     48PASS   node.channelInterpretation after invalid setter is equal to discrete.
     49PASS < [test AudioNodeOptions] All assertions passed. (total 20 assertions)
    2250PASS > [valid non-default] 
    23 FAIL X node1 = new WaveShaperNode(, {"curve":{"0":1,"1":2,"2":3},"oversample":"4x"}) incorrectly threw TypeError: "function is not a constructor (evaluating 'new WaveShaperNode(context, options)')". assert_true: expected true got false
    24 FAIL # AUDIT TASK RUNNER FINISHED: 3 out of 5 tasks were failed. assert_true: expected true got false
     51PASS   node1 = new WaveShaperNode(, {"curve":{"0":1,"1":2,"2":3},"oversample":"4x"}) did not throw an exception.
     52PASS   node1.curve is identical to the array [1,2,3].
     53PASS   node1.oversample is equal to 4x.
     54PASS < [valid non-default] All assertions passed. (total 3 assertions)
     55PASS # AUDIT TASK RUNNER FINISHED: 5 tasks ran successfully.
    2556
  • trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-waveshapernode-interface/waveshaper-simple-expected.txt

    r262405 r265152  
    1414PASS   Setting curve to [-1,0.25,0.75] did not throw an exception.
    1515PASS   WaveShaper.curve is identical to the array [-1,0.25,0.75].
    16 FAIL X Setting curve back to null incorrectly threw TypeError: "The WaveShaperNode.curve attribute must be an instance of Float32Array". assert_true: expected true got false
    17 FAIL X Waveshaper.curve = null is not equal to null. Got [-1,0.25,0.75]. assert_true: expected true got false
    18 FAIL < [simple] 2 out of 12 assertions were failed. assert_true: expected true got false
    19 FAIL # AUDIT TASK RUNNER FINISHED: 1 out of 1 tasks were failed. assert_true: expected true got false
     16PASS   Setting curve back to null did not throw an exception.
     17PASS   Waveshaper.curve = null is equal to null.
     18PASS < [simple] All assertions passed. (total 12 assertions)
     19PASS # AUDIT TASK RUNNER FINISHED: 1 tasks ran successfully.
    2020
  • trunk/Source/WebCore/CMakeLists.txt

    r265066 r265152  
    483483    Modules/webaudio/OscillatorOptions.idl
    484484    Modules/webaudio/OscillatorType.idl
     485    Modules/webaudio/OverSampleType.idl
    485486    Modules/webaudio/PannerNode.idl
    486487    Modules/webaudio/PannerOptions.idl
     
    491492    Modules/webaudio/ScriptProcessorNode.idl
    492493    Modules/webaudio/WaveShaperNode.idl
     494    Modules/webaudio/WaveShaperOptions.idl
    493495    Modules/webaudio/WebKitAudioContext.idl
    494496    Modules/webaudio/WebKitAudioPannerNode.idl
  • trunk/Source/WebCore/ChangeLog

    r265150 r265152  
     12020-07-31  Chris Dumez  <cdumez@apple.com>
     2
     3        Add constructor for WaveShaperNode
     4        https://bugs.webkit.org/show_bug.cgi?id=214989
     5
     6        Reviewed by Youenn Fablet.
     7
     8        Add constructor for WaveShaperNode:
     9        - https://www.w3.org/TR/webaudio/#waveshapernode
     10
     11        No new tests, rebaselined existing tests.
     12
     13        * CMakeLists.txt:
     14        * DerivedSources-input.xcfilelist:
     15        * DerivedSources-output.xcfilelist:
     16        * DerivedSources.make:
     17        * Modules/webaudio/BaseAudioContext.cpp:
     18        (WebCore::BaseAudioContext::createWaveShaper):
     19        * Modules/webaudio/OverSampleType.h: Copied from Source/WebCore/Modules/webaudio/WaveShaperNode.idl.
     20        * Modules/webaudio/OverSampleType.idl: Copied from Source/WebCore/Modules/webaudio/WaveShaperNode.idl.
     21        * Modules/webaudio/WaveShaperNode.cpp:
     22        (WebCore::WaveShaperNode::create):
     23        (WebCore::WaveShaperNode::setCurve):
     24        (WebCore::processorType):
     25        * Modules/webaudio/WaveShaperNode.h:
     26        (WTF::LogArgument<WebCore::OverSampleType>::toString):
     27        * Modules/webaudio/WaveShaperNode.idl:
     28        * Modules/webaudio/WaveShaperOptions.h: Copied from Source/WebCore/Modules/webaudio/WaveShaperNode.idl.
     29        * Modules/webaudio/WaveShaperOptions.idl: Copied from Source/WebCore/Modules/webaudio/WaveShaperNode.idl.
     30        * Sources.txt:
     31        * WebCore.xcodeproj/project.pbxproj:
     32
    1332020-07-31  Youenn Fablet  <youenn@apple.com>
    234
  • trunk/Source/WebCore/DerivedSources-input.xcfilelist

    r265066 r265152  
    332332$(PROJECT_DIR)/Modules/webaudio/OscillatorOptions.idl
    333333$(PROJECT_DIR)/Modules/webaudio/OscillatorType.idl
     334$(PROJECT_DIR)/Modules/webaudio/OverSampleType.idl
    334335$(PROJECT_DIR)/Modules/webaudio/PannerNode.idl
    335336$(PROJECT_DIR)/Modules/webaudio/PannerOptions.idl
     
    340341$(PROJECT_DIR)/Modules/webaudio/ScriptProcessorNode.idl
    341342$(PROJECT_DIR)/Modules/webaudio/WaveShaperNode.idl
     343$(PROJECT_DIR)/Modules/webaudio/WaveShaperOptions.idl
    342344$(PROJECT_DIR)/Modules/webaudio/WebKitAudioContext.idl
    343345$(PROJECT_DIR)/Modules/webaudio/WebKitAudioPannerNode.idl
  • trunk/Source/WebCore/DerivedSources-output.xcfilelist

    r265066 r265152  
    12391239$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSOscillatorType.cpp
    12401240$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSOscillatorType.h
     1241$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSOverSampleType.cpp
     1242$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSOverSampleType.h
    12411243$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSOverconstrainedError.cpp
    12421244$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSOverconstrainedError.h
     
    19771979$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWaveShaperNode.cpp
    19781980$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWaveShaperNode.h
     1981$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWaveShaperOptions.cpp
     1982$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWaveShaperOptions.h
    19791983$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebAnimation.cpp
    19801984$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebAnimation.h
  • trunk/Source/WebCore/DerivedSources.make

    r265066 r265152  
    415415    $(WebCore)/Modules/webaudio/OscillatorOptions.idl \
    416416    $(WebCore)/Modules/webaudio/OscillatorType.idl \
     417    $(WebCore)/Modules/webaudio/OverSampleType.idl \
    417418    $(WebCore)/Modules/webaudio/PannerNode.idl \
    418419    $(WebCore)/Modules/webaudio/PannerOptions.idl \
     
    423424    $(WebCore)/Modules/webaudio/ScriptProcessorNode.idl \
    424425    $(WebCore)/Modules/webaudio/WaveShaperNode.idl \
     426    $(WebCore)/Modules/webaudio/WaveShaperOptions.idl \
    425427    $(WebCore)/Modules/webaudio/WebKitAudioContext.idl \
    426428    $(WebCore)/Modules/webaudio/WebKitAudioPannerNode.idl \
  • trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.cpp

    r265086 r265152  
    510510   
    511511    ASSERT(isMainThread());
    512     if (m_isStopScheduled)
    513         return Exception { InvalidStateError };
    514 
    515     lazyInitialize();
    516512    return WaveShaperNode::create(*this);
    517513}
  • trunk/Source/WebCore/Modules/webaudio/OverSampleType.h

    r265151 r265152  
    11/*
    2  * Copyright (C) 2011, Google Inc. All rights reserved.
     2 * Copyright (C) 2020, Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2323 */
    2424
    25 enum OverSampleType {
    26     "none",
    27     "2x",
    28     "4x"
    29 };
     25#pragma once
    3026
    31 [
    32     Conditional=WEB_AUDIO,
    33     JSGenerateToJSObject
    34 ] interface WaveShaperNode : AudioNode {
    35     attribute Float32Array curve;
    36     attribute OverSampleType oversample;
    37 };
     27namespace WebCore {
     28
     29enum class OverSampleType { None, _2x, _4x };
     30
     31}
  • trunk/Source/WebCore/Modules/webaudio/OverSampleType.idl

    r265151 r265152  
    11/*
    2  * Copyright (C) 2011, Google Inc. All rights reserved.
     2 * Copyright (C) 2020, Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2828    "4x"
    2929};
    30 
    31 [
    32     Conditional=WEB_AUDIO,
    33     JSGenerateToJSObject
    34 ] interface WaveShaperNode : AudioNode {
    35     attribute Float32Array curve;
    36     attribute OverSampleType oversample;
    37 };
  • trunk/Source/WebCore/Modules/webaudio/WaveShaperNode.cpp

    r263410 r265152  
    2929
    3030#include "AudioContext.h"
     31#include <JavaScriptCore/JSCInlines.h>
     32#include <JavaScriptCore/TypedArrayInlines.h>
    3133#include <wtf/IsoMallocInlines.h>
    3234#include <wtf/MainThread.h>
     
    3537
    3638WTF_MAKE_ISO_ALLOCATED_IMPL(WaveShaperNode);
     39
     40ExceptionOr<Ref<WaveShaperNode>> WaveShaperNode::create(BaseAudioContext& context, const WaveShaperOptions& options)
     41{
     42    if (context.isStopped())
     43        return Exception { InvalidStateError };
     44
     45    context.lazyInitialize();
     46    UNUSED_PARAM(options);
     47
     48    RefPtr<Float32Array> curve;
     49    if (options.curve) {
     50        curve = Float32Array::tryCreate(options.curve->data(), options.curve->size());
     51        if (!curve)
     52            return Exception { InvalidStateError, "Invalid curve parameter" };
     53    }
     54
     55    auto node = adoptRef(*new WaveShaperNode(context));
     56
     57    auto result = node->setChannelCount(options.channelCount.valueOr(2));
     58    if (result.hasException())
     59        return result.releaseException();
     60
     61    result = node->setChannelCountMode(options.channelCountMode.valueOr(ChannelCountMode::Max));
     62    if (result.hasException())
     63        return result.releaseException();
     64
     65    result = node->setChannelInterpretation(options.channelInterpretation.valueOr(ChannelInterpretation::Speakers));
     66    if (result.hasException())
     67        return result.releaseException();
     68
     69    if (curve) {
     70        result = node->setCurve(WTFMove(curve));
     71        if (result.hasException())
     72            return result.releaseException();
     73    }
     74
     75    node->setOversample(options.oversample);
     76
     77    return node;
     78}
    3779
    3880WaveShaperNode::WaveShaperNode(BaseAudioContext& context)
     
    4587}
    4688
    47 void WaveShaperNode::setCurve(Float32Array& curve)
     89ExceptionOr<void> WaveShaperNode::setCurve(RefPtr<Float32Array>&& curve)
    4890{
    4991    ASSERT(isMainThread());
    5092    DEBUG_LOG(LOGIDENTIFIER);
    51     waveShaperProcessor()->setCurve(&curve);
     93    if (curve && curve->length() < 2)
     94        return Exception { InvalidStateError, "Length of curve array cannot be less than 2" };
     95
     96    waveShaperProcessor()->setCurve(curve.get());
     97    return { };
    5298}
    5399
     
    57103}
    58104
    59 static inline WaveShaperProcessor::OverSampleType processorType(WaveShaperNode::OverSampleType type)
     105static inline WaveShaperProcessor::OverSampleType processorType(OverSampleType type)
    60106{
    61107    switch (type) {
    62     case WaveShaperNode::OverSampleType::None:
     108    case OverSampleType::None:
    63109        return WaveShaperProcessor::OverSampleNone;
    64     case WaveShaperNode::OverSampleType::_2x:
     110    case OverSampleType::_2x:
    65111        return WaveShaperProcessor::OverSample2x;
    66     case WaveShaperNode::OverSampleType::_4x:
     112    case OverSampleType::_4x:
    67113        return WaveShaperProcessor::OverSample4x;
    68114    }
  • trunk/Source/WebCore/Modules/webaudio/WaveShaperNode.h

    r263410 r265152  
    2525#pragma once
    2626
     27#if ENABLE(WEB_AUDIO)
     28
    2729#include "AudioBasicProcessorNode.h"
     30#include "OverSampleType.h"
     31#include "WaveShaperOptions.h"
    2832#include "WaveShaperProcessor.h"
    2933#include <wtf/Forward.h>
     
    3438    WTF_MAKE_ISO_ALLOCATED(WaveShaperNode);
    3539public:
    36     static Ref<WaveShaperNode> create(BaseAudioContext& context)
    37     {
    38         return adoptRef(*new WaveShaperNode(context));
    39     }
     40    static ExceptionOr<Ref<WaveShaperNode>> create(BaseAudioContext&, const WaveShaperOptions& = { });
    4041
    4142    // setCurve() is called on the main thread.
    42     void setCurve(Float32Array&);
     43    ExceptionOr<void> setCurve(RefPtr<Float32Array>&&);
    4344    Float32Array* curve();
    4445
    45     enum class OverSampleType { None, _2x, _4x };
    4646    void setOversample(OverSampleType);
    4747    OverSampleType oversample() const;
     
    5555};
    5656
    57 String convertEnumerationToString(WebCore::WaveShaperNode::OverSampleType); // in JSWaveShaperNode.cpp
     57String convertEnumerationToString(WebCore::OverSampleType); // in JSOverSampleType.cpp
    5858
    5959} // namespace WebCore
     
    6161namespace WTF {
    6262   
    63 template<> struct LogArgument<WebCore::WaveShaperNode::OverSampleType> {
    64     static String toString(WebCore::WaveShaperNode::OverSampleType type) { return convertEnumerationToString(type); }
     63template<> struct LogArgument<WebCore::OverSampleType> {
     64    static String toString(WebCore::OverSampleType type) { return convertEnumerationToString(type); }
    6565};
    6666   
    6767} // namespace WTF
     68
     69#endif // ENABLE(WEB_AUDIO)
  • trunk/Source/WebCore/Modules/webaudio/WaveShaperNode.idl

    r200291 r265152  
    2323 */
    2424
    25 enum OverSampleType {
    26     "none",
    27     "2x",
    28     "4x"
    29 };
    30 
    3125[
    3226    Conditional=WEB_AUDIO,
    3327    JSGenerateToJSObject
    3428] interface WaveShaperNode : AudioNode {
    35     attribute Float32Array curve;
     29    [MayThrowException, EnabledBySetting=ModernUnprefixedWebAudio] constructor(BaseAudioContext context, optional WaveShaperOptions options);
     30
     31    attribute Float32Array? curve;
    3632    attribute OverSampleType oversample;
    3733};
  • trunk/Source/WebCore/Modules/webaudio/WaveShaperOptions.h

    r265151 r265152  
    11/*
    2  * Copyright (C) 2011, Google Inc. All rights reserved.
     2 * Copyright (C) 2020, Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2323 */
    2424
    25 enum OverSampleType {
    26     "none",
    27     "2x",
    28     "4x"
     25#pragma once
     26
     27#if ENABLE(WEB_AUDIO)
     28
     29#include "AudioNodeOptions.h"
     30#include "OverSampleType.h"
     31#include <wtf/Vector.h>
     32
     33namespace WebCore {
     34
     35struct WaveShaperOptions : AudioNodeOptions {
     36    Optional<Vector<float>> curve;
     37    OverSampleType oversample { OverSampleType::None };
    2938};
    3039
    31 [
    32     Conditional=WEB_AUDIO,
    33     JSGenerateToJSObject
    34 ] interface WaveShaperNode : AudioNode {
    35     attribute Float32Array curve;
    36     attribute OverSampleType oversample;
    37 };
     40}
     41
     42#endif // ENABLE(WEB_AUDIO)
  • trunk/Source/WebCore/Modules/webaudio/WaveShaperOptions.idl

    r265151 r265152  
    11/*
    2  * Copyright (C) 2011, Google Inc. All rights reserved.
     2 * Copyright (C) 2020, Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2323 */
    2424
    25 enum OverSampleType {
    26     "none",
    27     "2x",
    28     "4x"
     25[
     26    Conditional=WEB_AUDIO
     27] dictionary WaveShaperOptions : AudioNodeOptions {
     28    sequence<float> curve;
     29    OverSampleType oversample = "none";
    2930};
    30 
    31 [
    32     Conditional=WEB_AUDIO,
    33     JSGenerateToJSObject
    34 ] interface WaveShaperNode : AudioNode {
    35     attribute Float32Array curve;
    36     attribute OverSampleType oversample;
    37 };
  • trunk/Source/WebCore/Sources.txt

    r265079 r265152  
    31353135JSOscillatorOptions.cpp
    31363136JSOscillatorType.cpp
     3137JSOverSampleType.cpp
    31373138JSOverconstrainedError.cpp
    31383139JSOverconstrainedErrorEvent.cpp
     
    34963497JSVoidCallback.cpp
    34973498JSWaveShaperNode.cpp
     3499JSWaveShaperOptions.cpp
    34983500JSWebAnimation.cpp
    34993501JSWebGL2RenderingContext.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r265095 r265152  
    24332433                831B61772499A5BF00C07C79 /* WebKitOfflineAudioContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 831B61752499A59D00C07C79 /* WebKitOfflineAudioContext.h */; };
    24342434                8321507E1F27EA1B0095B136 /* NavigatorBeacon.h in Headers */ = {isa = PBXBuildFile; fileRef = 8321507B1F27EA150095B136 /* NavigatorBeacon.h */; };
     2435                8326BF8E24D35C33001F8A85 /* OverSampleType.h in Headers */ = {isa = PBXBuildFile; fileRef = 8326BF8924D35C20001F8A85 /* OverSampleType.h */; };
     2436                8326BF8F24D35C39001F8A85 /* WaveShaperOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 8326BF8C24D35C20001F8A85 /* WaveShaperOptions.h */; };
    24352437                832B843419D8E55100B26055 /* SVGAnimateElementBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 832B843319D8E55100B26055 /* SVGAnimateElementBase.h */; };
    24362438                833B9E321F508D8500E0E428 /* JSFileSystemDirectoryEntry.h in Headers */ = {isa = PBXBuildFile; fileRef = 833B9E2F1F508D8000E0E428 /* JSFileSystemDirectoryEntry.h */; };
     
    1041610418                8321507B1F27EA150095B136 /* NavigatorBeacon.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NavigatorBeacon.h; sourceTree = "<group>"; };
    1041710419                8321507C1F27EA150095B136 /* NavigatorBeacon.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = NavigatorBeacon.idl; sourceTree = "<group>"; };
     10420                8326BF8924D35C20001F8A85 /* OverSampleType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OverSampleType.h; sourceTree = "<group>"; };
     10421                8326BF8B24D35C20001F8A85 /* OverSampleType.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = OverSampleType.idl; sourceTree = "<group>"; };
     10422                8326BF8C24D35C20001F8A85 /* WaveShaperOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WaveShaperOptions.h; sourceTree = "<group>"; };
     10423                8326BF8D24D35C21001F8A85 /* WaveShaperOptions.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WaveShaperOptions.idl; sourceTree = "<group>"; };
    1041810424                8329A4171EC25B2B008ED4BE /* DocumentAndElementEventHandlers.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DocumentAndElementEventHandlers.idl; sourceTree = "<group>"; };
    1041910425                8329DCC21C7A6AE300730B33 /* HTMLHyperlinkElementUtils.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTMLHyperlinkElementUtils.idl; sourceTree = "<group>"; };
     
    2956729573                                E755E8B424CA2796009F7C23 /* OscillatorType.h */,
    2956829574                                E755E8B624CA2796009F7C23 /* OscillatorType.idl */,
     29575                                8326BF8924D35C20001F8A85 /* OverSampleType.h */,
     29576                                8326BF8B24D35C20001F8A85 /* OverSampleType.idl */,
    2956929577                                FD315FCF12B0267500C1A359 /* PannerNode.cpp */,
    2957029578                                FD315FD012B0267500C1A359 /* PannerNode.h */,
     
    2959129599                                FD7F298D13D4C0CB00AD9535 /* WaveShaperNode.h */,
    2959229600                                FD7F298E13D4C0CB00AD9535 /* WaveShaperNode.idl */,
     29601                                8326BF8C24D35C20001F8A85 /* WaveShaperOptions.h */,
     29602                                8326BF8D24D35C21001F8A85 /* WaveShaperOptions.idl */,
    2959329603                                FD7F298F13D4C0CB00AD9535 /* WaveShaperProcessor.cpp */,
    2959429604                                FD7F299013D4C0CB00AD9535 /* WaveShaperProcessor.h */,
     
    3266232672                                1A0D57370A5C77FE007EDD4C /* OverflowEvent.h in Headers */,
    3266332673                                3774ABA50FA21EB400AD7DE9 /* OverlapTestRequestClient.h in Headers */,
     32674                                8326BF8E24D35C33001F8A85 /* OverSampleType.h in Headers */,
    3266432675                                65A21468097A329100B9050A /* Page.h in Headers */,
    3266532676                                91278D5E21DEDAD600B57184 /* PageAuditAgent.h in Headers */,
     
    3393233943                                FD7F299213D4C0CB00AD9535 /* WaveShaperDSPKernel.h in Headers */,
    3393333944                                FD7F299413D4C0CB00AD9535 /* WaveShaperNode.h in Headers */,
     33945                                8326BF8F24D35C39001F8A85 /* WaveShaperOptions.h in Headers */,
    3393433946                                FD7F299713D4C0CB00AD9535 /* WaveShaperProcessor.h in Headers */,
    3393533947                                29A812490FBB9CA900510293 /* WebAccessibilityObjectWrapperBase.h in Headers */,
     
    3505035062                                DECA803A1F9FED6A00E3B661 /* UnifiedSource249.cpp in Sources */,
    3505135063                                DECA803B1F9FED6A00E3B661 /* UnifiedSource250.cpp in Sources */,
    35052                                 CDED1C3C24CD305700934E12 /* VP9UtilitiesCocoa.mm in Sources */,
    3505335064                                DECA803C1F9FED6A00E3B661 /* UnifiedSource251.cpp in Sources */,
    3505435065                                DECA803D1F9FED6A00E3B661 /* UnifiedSource252.cpp in Sources */,
     
    3534035351                                CD8B5A42180D149A008B8E65 /* VideoTrackPrivateMediaSourceAVFObjC.mm in Sources */,
    3534135352                                26F9A83818A046AC00AEB88A /* ViewportConfiguration.cpp in Sources */,
     35353                                CDED1C3C24CD305700934E12 /* VP9UtilitiesCocoa.mm in Sources */,
    3534235354                                A14832B1187F61E100DA63A6 /* WAKAppKitStubs.m in Sources */,
    3534335355                                A14832B3187F629100DA63A6 /* WAKClipView.m in Sources */,
Note: See TracChangeset for help on using the changeset viewer.