From 42479d2ed8fcbad5fb3ffb52553dad05a329590f Mon Sep 17 00:00:00 2001 From: gramanas Date: Sun, 30 Jul 2023 20:51:05 +0300 Subject: oop --- src/osc.h | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'src/osc.h') diff --git a/src/osc.h b/src/osc.h index 732f134..7fd0303 100644 --- a/src/osc.h +++ b/src/osc.h @@ -2,6 +2,9 @@ #define OSC_H #include +#include +#include +#include /** * 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 */ /***************/ -- cgit v1.2.3