File phaser.h¶
File List > DaisySP > Source > Effects > phaser.h
Go to the documentation of this file
Source Code¶
/*
Copyright (c) 2020 Electrosmith, Corp
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_PHASER_H
#define DSY_PHASER_H
#ifdef __cplusplus
#include <stdint.h>
#include "Utility/delayline.h"
namespace daisysp
{
class PhaserEngine
{
public:
PhaserEngine() {}
~PhaserEngine() {}
void Init(float sample_rate);
float Process(float in);
void SetLfoDepth(float depth);
void SetLfoFreq(float lfo_freq);
void SetFreq(float ap_freq);
void SetFeedback(float feedback);
private:
float sample_rate_;
static constexpr int32_t kDelayLength
= 2400; // 50 ms at 48kHz = .05 * 48000
//triangle lfo
float lfo_phase_;
float lfo_freq_;
float lfo_amp_;
float os_;
float feedback_;
float ap_freq_;
float deltime_;
float last_sample_;
DelayLine<float, kDelayLength> del_;
float ProcessLfo();
};
//wraps up all of the phaser engines
class Phaser
{
public:
Phaser() {}
~Phaser() {}
void Init(float sample_rate);
float Process(float in);
void SetPoles(int poles);
void SetLfoDepth(float depth);
void SetLfoFreq(float lfo_freq);
void SetFreq(float ap_freq);
void SetFeedback(float feedback);
private:
static constexpr int kMaxPoles = 8;
PhaserEngine engines_[kMaxPoles];
float gain_frac_;
int poles_;
};
} //namespace daisysp
#endif
#endif