Skip to content

File nlfilt.h

File List > DaisySP > DaisySP-LGPL > Source > Filters > nlfilt.h

Go to the documentation of this file

Source Code

/*
Copyright (c) 2023 Electrosmith, Corp, John ffitch, Richard Dobson

Use of this source code is governed by the LGPL V2.1
license that can be found in the LICENSE file or at
https://opensource.org/license/lgpl-2-1/
*/

#pragma once
#ifndef DSY_NLFILT_H
#define DSY_NLFILT_H
#include <stdlib.h>
#include <stdint.h>
#define DSY_NLFILT_MAX_DELAY 1024

namespace daisysp
{
class NlFilt
{
  public:
    void Init();

    void ProcessBlock(float *in, float *out, size_t size);


    inline void SetCoefficients(float a, float b, float d, float C, float L)
    {
        a_ = a;
        b_ = b;
        d_ = d;
        C_ = C;
        L_ = L;
    }


    inline void SetA(float a) { a_ = a; }
    inline void SetB(float b) { b_ = b; }
    inline void SetD(float d) { d_ = d; }
    inline void SetC(float C) { C_ = C; }
    inline void SetL(float L) { L_ = L; }

  private:
    int32_t Set();

    float   in_, a_, b_, d_, C_, L_;
    float   delay_[DSY_NLFILT_MAX_DELAY];
    int32_t point_;
};
} // namespace daisysp

#endif