Skip to content

File vosim.h

File List > DaisySP > Source > Synthesis > vosim.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_VOSIM_H
#define DSY_VOSIM_H

#include <stdint.h>
#ifdef __cplusplus

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

    void Init(float sample_rate);

    float Process();

    void SetFreq(float freq);

    void SetForm1Freq(float freq);

    void SetForm2Freq(float freq);

    void SetShape(float shape);

  private:
    float Sine(float phase);

    float sample_rate_;

    // Oscillator state.
    float carrier_phase_;
    float formant_1_phase_;
    float formant_2_phase_;

    // For interpolation of parameters.
    float carrier_frequency_;
    float formant_1_frequency_;
    float formant_2_frequency_;
    float carrier_shape_;
};
} // namespace daisysp
#endif
#endif