I’m struggling to successfully implementing minBlep anti-aliasing into my oscillator. In particular, I’m not quite understanding what I should use as an argument for the time parameter of the addDiscontinuity function.
My oscillator is built based on a float_4 class that has an internal float_4 Phase parameter that increments from 0 to 1, adding the a scaled sampleTime based on the frequency once per process. When the phase exceeds 1, I fold it back by subtracting -1, thus retaining the fraction.
Phase += sampleTime * Frequency;
for (int p = 0; p < Phase.size; p++){
if(Phase[p]>=1){
Phase[p] -= 1;
}
}
(Sidenote, I am aware this is an ugly and very non-simd implementation. I’ve not quite figured out how to use the masks and ifelse methods in the simd library.)
In addition, I have built functions that take the Phase and generate the corresponding point on a waveform, where each waveform is centered around 0, and scaled between -1 and 1.
Example:
float SawWave(float Phase){
return (0.5-Phase)*2;
}
In this case, the discontinuity occurs when whenever the Phase folds back, and it goes into the if statement. Thus, my line of thinking was that as I know exactly when the fold occurs, I should then be able to just be able to carry a bool to the waveform generator that sets to true on phase foldback, so that the addDiscontinuity function executes exactly once, exactly when the phase foldback occurs, and use 0, -2 as arguments.
float SawWave(float Phase, bool Blep){
float t = (0.5-Phase)*2;
if(Blep){
minBlepper.addDiscontinutity(0,-2);
return t+minBlepper.process();
else{
return (0.5-Phase)*2;
}
}
This didn’t do…well, anything. So clearly, I’m missing something in how I’m approaching and thinking about this. Does anyone have any insight?