Add methods to compute magnitude and phase response for biquads
[WebKit-https.git] / Source / WebCore / webaudio / BiquadFilterNode.cpp
index f16d8e5f96d757bf95d57242b6e2db95ce61cf0a..80c3f938cd0199e287dc53a3ba95b8c8ecad839a 100644 (file)
@@ -53,6 +53,25 @@ void BiquadFilterNode::setType(unsigned short type, ExceptionCode& ec)
     biquadProcessor()->setType(static_cast<BiquadProcessor::FilterType>(type));
 }
 
+
+void BiquadFilterNode::getFrequencyResponse(const Float32Array* frequencyHz,
+                                            Float32Array* magResponse,
+                                            Float32Array* phaseResponse)
+{
+    if (!frequencyHz || !magResponse || !phaseResponse)
+        return;
+    
+    int n = std::min(frequencyHz->length(),
+                     std::min(magResponse->length(), phaseResponse->length()));
+
+    if (n) {
+        biquadProcessor()->getFrequencyResponse(n,
+                                                frequencyHz->data(),
+                                                magResponse->data(),
+                                                phaseResponse->data());
+    }
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(WEB_AUDIO)