File oscillatorbank.h¶
File List > DaisySP > Source > Synthesis > oscillatorbank.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_OSCILLATORBANK_H
#define DSY_OSCILLATORBANK_H
#include <stdint.h>
#ifdef __cplusplus
namespace daisysp
{
class OscillatorBank
{
public:
OscillatorBank() {}
~OscillatorBank() {}
void Init(float sample_rate);
float Process();
void SetFreq(float freq);
void SetAmplitudes(const float* amplitudes);
void SetSingleAmp(float amp, int idx);
void SetGain(float gain);
private:
// Oscillator state.
float phase_;
float next_sample_;
int segment_;
float gain_;
float registration_[7];
float unshifted_registration_[7];
float frequency_;
float saw_8_gain_;
float saw_4_gain_;
float saw_2_gain_;
float saw_1_gain_;
float sample_rate_;
bool recalc_, recalc_gain_;
bool cmp(float a, float b) { return fabsf(a - b) > .0000001; }
};
} // namespace daisysp
#endif
#endif