Ensure oscillator step fits within lookup bounds
parent
864e4d1431
commit
ba6cb260a4
3
osc.c
3
osc.c
|
@ -28,5 +28,8 @@ void osc_setfreq(struct osc_t *osc, double freq)
|
||||||
{
|
{
|
||||||
osc->freq = freq;
|
osc->freq = freq;
|
||||||
osc->step = freq / _sample_rate * LOOKUP_SAMPLES;
|
osc->step = freq / _sample_rate * LOOKUP_SAMPLES;
|
||||||
|
|
||||||
|
/* Ensure step does not go out of bound */
|
||||||
|
while (osc->step > LOOKUP_SAMPLES) osc->step -= LOOKUP_SAMPLES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue