You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Vibrato-effect/BerVibrato/BerVibrato.h

47 lines
996 B

#ifndef VIBRATO_PROCESSOR_H
#define VIBRATO_PROCESSOR_H
#include "Lfo.h"
#include "RingBuffer.h"
const float BASE_DELAY_SEC = 0.002; // 2 ms
const float VIBRATO_FREQUENCY_DEFAULT_HZ = 2;
const float VIBRATO_FREQUENCY_MAX_HZ = 14;
const float VIBRATO_DEPTH_DEFAULT_PERCENT = 50;
class BerVibrato
{
public:
BerVibrato();
public:
void initialize(float sampleRate);
void process(float* input, float*output, int numberOfSamples);
void setFrequency(float frequency);
void setDepth(float depth);
public:
INLINE float processOneSample(float input)
{
float lfoValue = lfo.getValue();
int maxDelay = BASE_DELAY_SEC * sampleRate;
float delay = lfoValue * depth * maxDelay;
delay += additionalDelay;
float value = buffer.getHermiteAt(delay);
buffer.write_margined(input);
return value;
}
private:
float sampleRate;
Lfo lfo;
RingBuffer buffer;
float depth;
static const int additionalDelay = 1;
};
#endif