diff options
Diffstat (limited to 'src/osc.h')
-rw-r--r-- | src/osc.h | 28 |
1 files changed, 21 insertions, 7 deletions
@@ -2,6 +2,9 @@ #define OSC_H #include <math.h> +#include <stddef.h> +#include <string.h> +#include <stdlib.h> /** * The main idea of the osc is the following: @@ -19,6 +22,14 @@ enum osc_type { WAVE, SAMPLE }; +struct osc_t; +struct osc_ops { + void (*set_start)(struct osc_t *, long); + void (*set_end) (struct osc_t *, long); + void (*set_len) (struct osc_t *, long); + float (*sample) (struct osc_t *, float); + float (*next) (struct osc_t *, float, float); +}; typedef struct osc_t { char name[16]; @@ -27,15 +38,16 @@ typedef struct osc_t { long start; long end; enum osc_type type; + const struct osc_ops * ops; } osc_t; -#define MAKE_OSC(_name, _len, _type) {\ - .name = _name, \ - .data = 0, \ - .len = _len, \ - .start = 0, \ - .end = _len, \ - .type = _type, \ +#define MAKE_OSC(_name, _len, _type) { \ + .name = _name, \ + .data = 0, \ + .len = _len, \ + .start = 0, \ + .end = _len, \ + .type = _type, \ }; /* Initializes the wavetables and functions for the oscilators */ @@ -47,6 +59,8 @@ int osc_next_index(osc_t * osc, float offset); int osc_load_wav(osc_t * osc, const char * path); +osc_t * make_tri(const char * name); + /***************/ /* OSCILATORS */ /***************/ |