Expose attack, release as DynamicsCompressorNode's attributes.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Mar 2012 06:56:11 +0000 (06:56 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Mar 2012 06:56:11 +0000 (06:56 +0000)
https://bugs.webkit.org/show_bug.cgi?id=81221

Patch by Gao Chun <chun.gao@intel.com> on 2012-03-15
Reviewed by Chris Rogers.

Source/WebCore:

Test: webaudio/dynamicscompressor-basic.html

* platform/audio/DynamicsCompressor.h:
(DynamicsCompressor):
* webaudio/DynamicsCompressorNode.cpp:
(WebCore::DynamicsCompressorNode::DynamicsCompressorNode):
(WebCore::DynamicsCompressorNode::process):
* webaudio/DynamicsCompressorNode.h:
(WebCore::DynamicsCompressorNode::attack):
(WebCore::DynamicsCompressorNode::release):
(DynamicsCompressorNode):
* webaudio/DynamicsCompressorNode.idl:

LayoutTests:

* webaudio/dynamicscompressor-basic-expected.txt:
* webaudio/dynamicscompressor-basic.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@110951 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/webaudio/dynamicscompressor-basic-expected.txt
LayoutTests/webaudio/dynamicscompressor-basic.html
Source/WebCore/ChangeLog
Source/WebCore/platform/audio/DynamicsCompressor.h
Source/WebCore/webaudio/DynamicsCompressorNode.cpp
Source/WebCore/webaudio/DynamicsCompressorNode.h
Source/WebCore/webaudio/DynamicsCompressorNode.idl

index eb10afbc75572b7c2a289bf78bc0347f005e8636..4eed89ebd63952f00a35f7542e5549b9385719e9 100644 (file)
@@ -1,3 +1,13 @@
+2012-03-15  Gao Chun  <chun.gao@intel.com>
+
+        Expose attack, release as DynamicsCompressorNode's attributes.
+        https://bugs.webkit.org/show_bug.cgi?id=81221
+
+        Reviewed by Chris Rogers.
+
+        * webaudio/dynamicscompressor-basic-expected.txt:
+        * webaudio/dynamicscompressor-basic.html:
+
 2012-03-15  Hans Wennborg  <hans@chromium.org>
 
         Speech JavaScript API: SpeechRecognition, Controller and Client
index dd3999149392c77a6df0dcbce6e7f3efb3c87a6c..09c30e6bacda999d3568ee5a844741bffd16d14b 100644 (file)
@@ -5,6 +5,8 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 PASS threshold attribute has correct default value.
 PASS knee attribute has correct default value.
 PASS ratio attribute has correct default value.
+PASS attack attribute has correct default value.
+PASS release attribute has correct default value.
 PASS successfullyParsed is true
 
 TEST COMPLETE
index d122becc2531f79d9a5c3d99ae0460459f1fd11b..87c54d07c7231702ac2d7b1828216a90ba331054 100644 (file)
@@ -43,6 +43,16 @@ function runTest() {
         else
             testFailed("ratio attribute has incorrect default value.");
         
+        if (compressor.attack.value - 0.003 < 1e-7)
+            testPassed("attack attribute has correct default value.");
+        else
+            testFailed("attack attribute has incorrect default value.");
+
+        if (compressor.release.value - 0.25 < 1e-7)
+            testPassed("release attribute has correct default value.");
+        else
+            testFailed("release attribute has incorrect default value.");
+
     } catch(e) {
         testFailed("Exception thrown when accessing DynamicsCompressorNode attributes.");
     }
index d0440f272970aa97df4eff186e0756538a04345a..3d922133bc1970bcdeae425c346a535c338ca69b 100644 (file)
@@ -1,3 +1,23 @@
+2012-03-15  Gao Chun  <chun.gao@intel.com>
+
+        Expose attack, release as DynamicsCompressorNode's attributes.
+        https://bugs.webkit.org/show_bug.cgi?id=81221
+
+        Reviewed by Chris Rogers.
+
+        Test: webaudio/dynamicscompressor-basic.html
+
+        * platform/audio/DynamicsCompressor.h:
+        (DynamicsCompressor):
+        * webaudio/DynamicsCompressorNode.cpp:
+        (WebCore::DynamicsCompressorNode::DynamicsCompressorNode):
+        (WebCore::DynamicsCompressorNode::process):
+        * webaudio/DynamicsCompressorNode.h:
+        (WebCore::DynamicsCompressorNode::attack):
+        (WebCore::DynamicsCompressorNode::release):
+        (DynamicsCompressorNode):
+        * webaudio/DynamicsCompressorNode.idl:
+
 2012-03-15  Hans Wennborg  <hans@chromium.org>
 
         Speech JavaScript API: SpeechRecognition, Controller and Client
index 52013289841945da73fda660be1f2b7cd6191381..f781afe7b9722930e6f254ecc334d97752dd66ea 100644 (file)
@@ -85,8 +85,6 @@ protected:
     unsigned m_numberOfChannels;
 
     // m_parameters holds the tweakable compressor parameters.
-    // FIXME: expose some of the most important ones (such as threshold, attack, release)
-    // as DynamicsCompressorNode attributes.
     float m_parameters[ParamLast];
     void initializeParameters();
 
index ef70479072cc3506673d61e9ccefa4800fa7f036..c4e389897ce330fda88f093ff99134007d6174d3 100644 (file)
@@ -50,11 +50,15 @@ DynamicsCompressorNode::DynamicsCompressorNode(AudioContext* context, float samp
     m_knee = AudioParam::create("knee", 30, 0, 40);
     m_ratio = AudioParam::create("ratio", 12, 1, 20);
     m_reduction = AudioParam::create("reduction", 0, -20, 0);
+    m_attack = AudioParam::create("attack", 0.003, 0, 1);
+    m_release = AudioParam::create("release", 0.250, 0, 1);
 
     m_threshold->setContext(context);
     m_knee->setContext(context);
     m_ratio->setContext(context);
     m_reduction->setContext(context);
+    m_attack->setContext(context);
+    m_release->setContext(context);
 
     initialize();
 }
@@ -72,10 +76,14 @@ void DynamicsCompressorNode::process(size_t framesToProcess)
     float threshold = m_threshold->value();
     float knee = m_knee->value();
     float ratio = m_ratio->value();
+    float attack = m_attack->value();
+    float release = m_release->value();
 
     m_dynamicsCompressor->setParameterValue(DynamicsCompressor::ParamThreshold, threshold);
     m_dynamicsCompressor->setParameterValue(DynamicsCompressor::ParamKnee, knee);
     m_dynamicsCompressor->setParameterValue(DynamicsCompressor::ParamRatio, ratio);
+    m_dynamicsCompressor->setParameterValue(DynamicsCompressor::ParamAttack, attack);
+    m_dynamicsCompressor->setParameterValue(DynamicsCompressor::ParamRelease, release);
 
     m_dynamicsCompressor->process(input(0)->bus(), outputBus, framesToProcess);
 
index cf7e63a429fbdd49a617a7d16f0fb72ddeffff97..338dff3b0507633b922a00a941725eece89f9529 100644 (file)
@@ -52,6 +52,8 @@ public:
     AudioParam* threshold() { return m_threshold.get(); }
     AudioParam* knee() { return m_knee.get(); }
     AudioParam* ratio() { return m_ratio.get(); }
+    AudioParam* attack() { return m_attack.get(); }
+    AudioParam* release() { return m_release.get(); }
 
     // Amount by which the compressor is currently compressing the signal in decibels.
     AudioParam* reduction() { return m_reduction.get(); }
@@ -67,6 +69,8 @@ private:
     RefPtr<AudioParam> m_knee;
     RefPtr<AudioParam> m_ratio;
     RefPtr<AudioParam> m_reduction;
+    RefPtr<AudioParam> m_attack;
+    RefPtr<AudioParam> m_release;
 };
 
 } // namespace WebCore
index 60d64fda077e4ac170bc03c1ee96a3b2d8018b70..a2e35656bed3ec632bd8987701c5a5b5213b09de 100644 (file)
@@ -31,5 +31,7 @@ module audio {
         readonly attribute AudioParam knee; // in Decibels
         readonly attribute AudioParam ratio; // unit-less
         readonly attribute AudioParam reduction; // in Decibels
+        readonly attribute AudioParam attack; // in Seconds
+        readonly attribute AudioParam release; // in Seconds
     };
 }