Skip to content

File modalvoice.h

File List > DaisySP > Source > PhysicalModeling > modalvoice.h

Go to the documentation of this file

Source Code

/*
Copyright (c) 2020 Electrosmith, Corp, Emilie Gillet

Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/

#pragma once
#ifndef DSY_MODAL_H
#define DSY_MODAL_H

#include <stdint.h>
#include "Filters/svf.h"
#include "PhysicalModeling/resonator.h"
#include "Noise/dust.h"
#ifdef __cplusplus

namespace daisysp
{
class ModalVoice
{
  public:
    ModalVoice() {}
    ~ModalVoice() {}

    void Init(float sample_rate);

    float Process(bool trigger = false);

    void SetSustain(bool sustain);

    void Trig();

    void SetFreq(float freq);

    void SetAccent(float accent);

    void SetStructure(float structure);

    void SetBrightness(float brightness);

    void SetDamping(float damping);

    float GetAux();

  private:
    float sample_rate_;

    bool  sustain_, trig_;
    float f0_, structure_, brightness_, damping_;
    float density_, accent_;
    float aux_;

    ResonatorSvf<1> excitation_filter_;
    Resonator       resonator_;
    Dust            dust_;
};
} // namespace daisysp
#endif
#endif