Home | History | Annotate | Download | only in common_audio
      1 /*
      2  *  Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
      3  *
      4  *  Use of this source code is governed by a BSD-style license
      5  *  that can be found in the LICENSE file in the root of the source
      6  *  tree. An additional intellectual property rights grant can be found
      7  *  in the file PATENTS.  All contributing project authors may
      8  *  be found in the AUTHORS file in the root of the source tree.
      9  */
     10 
     11 #ifndef WEBRTC_COMMON_AUDIO_FIR_FILTER_H_
     12 #define WEBRTC_COMMON_AUDIO_FIR_FILTER_H_
     13 
     14 #include <string.h>
     15 
     16 namespace webrtc {
     17 
     18 // Finite Impulse Response filter using floating-point arithmetic.
     19 class FIRFilter {
     20  public:
     21   // Creates a filter with the given coefficients. All initial state values will
     22   // be zeros.
     23   // The length of the chunks fed to the filter should never be greater than
     24   // |max_input_length|. This is needed because, when vectorizing it is
     25   // necessary to concatenate the input after the state, and resizing this array
     26   // dynamically is expensive.
     27   static FIRFilter* Create(const float* coefficients,
     28                            size_t coefficients_length,
     29                            size_t max_input_length);
     30 
     31   virtual ~FIRFilter() {}
     32 
     33   // Filters the |in| data supplied.
     34   // |out| must be previously allocated and it must be at least of |length|.
     35   virtual void Filter(const float* in, size_t length, float* out) = 0;
     36 };
     37 
     38 }  // namespace webrtc
     39 
     40 #endif  // WEBRTC_COMMON_AUDIO_FIR_FILTER_H_
     41