File variableshapeosc.h¶
File List > DaisySP > Source > Synthesis > variableshapeosc.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_VARIABLESHAPEOSCILLATOR_H
#define DSY_VARIABLESHAPEOSCILLATOR_H
#include <stdint.h>
#ifdef __cplusplus
namespace daisysp
{
class VariableShapeOscillator
{
public:
VariableShapeOscillator() {}
~VariableShapeOscillator() {}
void Init(float sample_rate);
float Process();
void SetFreq(float frequency);
void SetPW(float pw);
void SetWaveshape(float waveshape);
void SetSync(bool enable_sync);
void SetSyncFreq(float frequency);
private:
float ComputeNaiveSample(float phase,
float pw,
float slope_up,
float slope_down,
float triangle_amount,
float square_amount);
float sample_rate_;
bool enable_sync_;
// Oscillator state.
float master_phase_;
float slave_phase_;
float next_sample_;
float previous_pw_;
bool high_;
// For interpolation of parameters.
float master_frequency_;
float slave_frequency_;
float pw_;
float waveshape_;
};
} // namespace daisysp
#endif
#endif