Skip to content

File tone.h

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

Go to the documentation of this file

Source Code

/*
Copyright (c) 2023 Electrosmith, Corp, Barry Vercoe, John FFitch, Gabriel Maldonado

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_TONE_H
#define DSY_TONE_H

#include <stdint.h>
#ifdef __cplusplus

namespace daisysp
{
class Tone
{
  public:
    Tone() {}
    ~Tone() {}
    void Init(float sample_rate);


    float Process(float in);

    inline void SetFreq(float freq)
    {
        freq_ = freq;
        CalculateCoefficients();
    }

    inline float GetFreq() { return freq_; }

  private:
    void  CalculateCoefficients();
    float out_, prevout_, in_, freq_, c1_, c2_, sample_rate_;
};
} // namespace daisysp
#endif
#endif