-
Notifications
You must be signed in to change notification settings - Fork 2
/
PreDelay.cpp
46 lines (37 loc) · 970 Bytes
/
PreDelay.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
// PreDelay.cpp
// PreDelayTest - All
//
// Created by Squishy on 15/02/2018.
//
#include "PreDelay.hpp"
// USER HEADERS
#include "CircularBuffer.hpp"
PreDelay::PreDelay(){
setDelayLength(25);
Fs = 44100;
}
void PreDelay::process(float* samples, int bufferSize){
for(int i = 0; i < bufferSize; i++)
samples[i] = processSingleSample(samples[i]);
}
float PreDelay::processSingleSample(float sample){
buffer.write(sample);
return buffer.readCubic(delayLength - 1);
}
void PreDelay::setDelayLength(float inValue){
inValue = (inValue / 1000) * Fs;
if(inValue > buffer.getBufferLength())
delayLength = buffer.getBufferLength();
else if (inValue < 1.0)
delayLength = 1.0;
else
delayLength = inValue;
}
float PreDelay::getDelayLength(){
return delayLength;
}
void PreDelay::setFs(int sampleRate){
Fs = sampleRate;
setDelayLength(delayLength);
}