Add methods to compute magnitude and phase response for biquads
[WebKit-https.git] / Source / WebCore / webaudio / BiquadProcessor.h
index 3bb7a015059d2daf1aef1ebd4d8e1fd4e5b17604..c7f7d3068a3cf5de5c824131913bcf6459237986 100644 (file)
@@ -49,10 +49,10 @@ public:
         Allpass = 7
     };
 
-    BiquadProcessor(double sampleRate, size_t numberOfChannels, bool autoInitialize);
+    BiquadProcessor(float sampleRate, size_t numberOfChannels, bool autoInitialize);
 
     // Old constructor used by deprecated LowPass2FilterNode and HighPass2FilterNode
-    BiquadProcessor(FilterType, double sampleRate, size_t numberOfChannels, bool autoInitialize = true);
+    BiquadProcessor(FilterType, float sampleRate, size_t numberOfChannels, bool autoInitialize = true);
 
     virtual ~BiquadProcessor();
     
@@ -60,6 +60,15 @@ public:
         
     virtual void process(AudioBus* source, AudioBus* destination, size_t framesToProcess);
 
+    // Get the magnitude and phase response of the filter at the given
+    // set of frequencies (in Hz). The phase response is in radians.
+    void getFrequencyResponse(int nFrequencies,
+                              const float* frequencyHz,
+                              float* magResponse,
+                              float* phaseResponse);
+
+    void checkForDirtyCoefficients();
+    
     bool filterCoefficientsDirty() const { return m_filterCoefficientsDirty; }
 
     AudioParam* parameter1() { return m_parameter1.get(); }
@@ -67,7 +76,7 @@ public:
     AudioParam* parameter3() { return m_parameter3.get(); }
 
     FilterType type() const { return m_type; }
-    void setType(FilterType type) { m_type = type; }
+    void setType(FilterType);
 
 private:
     FilterType m_type;