summaryrefslogtreecommitdiffstats
path: root/src/osc_sound.c
blob: 2a0d519e0bcb9c42a78e3388e72834c42165599f (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
31
32
33
34
35
#include "osc.h"

#include <stdlib.h>

osc_t OSC_sound = {
  .name = "w_sound",
  .data = 0,
  .len = 0,
  .start = 0,
  .end = 0,
  .type = WAVE,
};

OSC_COMMON(sound)

float
osc_sound(float offset)
{
  if (!OSC_sound.len) {
//    osc_load_wav(&OSC_sound, "/home/gramanas/code/synth-project/waves/test_lick.wav");
    //osc_load_wav(&OSC_sound, "/home/gramanas/code/synth-project/waves/Free Wavetables[128]/FM Synthesis[128-44.1khz-16bit]/FM Sq- NotPM.wav");
    osc_load_wav(&OSC_sound, "/home/gramanas/code/synth-project/waves/Free Wavetables[2048]/Melda Oscillator[2048-44.1khz-32bit]/Melda CustumWave2.wav");
    OSC_sound.len = 2048;
  }
  
  return osc_interpolate(offset,
                         OSC_sound.data[(int)offset],
                         OSC_sound.data[osc_next_index(&OSC_sound, offset)]);
}

float
osc_sound_next(float f, float offset)
{
  return osc_next_offset(&OSC_sound, f, offset);
}