Skip to content

File stringvoice.h

File List > DaisySP > Source > PhysicalModeling > stringvoice.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_STRINGVOICE_H
#define DSY_STRINGVOICE_H

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

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

    void Init(float sample_rate);

    void Reset();

    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_, brightness_, damping_;
    float density_, accent_;
    float aux_;

    Dust   dust_;
    Svf    excitation_filter_;
    String string_;
    size_t remaining_noise_samples_;
};
} // namespace daisysp
#endif
#endif