summaryrefslogtreecommitdiffstats
path: root/src/osc_tri.c
blob: c4a56f54b9611569d2b7c77f6813c7d1ce1541b7 (plain) (blame)
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
#include "osc.h"

osc_t OSC_tri = {
  .name = "w_triangle",
  .start = 0,
  .end = 2,
  .len = 2,
};

float
tri(int index)
{
  if (index == 0) return -1.0f;
  else if (index == 1) return 1.0f;
  else return 0.0f;
}

float
osc_tri(float offset)
{
  return osc_interpolate(offset,
                         tri((int)offset),
                         tri(osc_next_index(&OSC_tri, offset)));
}

float
osc_tri_next(float f, float offset)
{
  return osc_next_offset(&OSC_tri, f, offset);
}