summaryrefslogtreecommitdiffstats
path: root/src/osc_sin.c
blob: 66478d2de417b1f2b37b4f43dc08a21d22ce5f55 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "osc.h"

osc_t OSC_sin = {
  .name = "f_sin",
  .len = 20000,
  .start = 0,
  .end = 20000,
};

float
osc_sin(float offset)
{
  return osc_interpolate(offset,
                         sin(2 * M_PI * (int)offset / OSC_sin.len),
                         sin(2 * M_PI * osc_next_index(&OSC_sin, offset) / OSC_sin.len));
}

float
osc_sin_next(float f, float offset)
{
  return osc_next_offset(&OSC_sin, f, offset);
}