diff options
author | gramanas <anastasis.gramm2@gmail.com> | 2023-07-30 20:51:05 +0300 |
---|---|---|
committer | gramanas <anastasis.gramm2@gmail.com> | 2023-07-30 20:51:05 +0300 |
commit | 42479d2ed8fcbad5fb3ffb52553dad05a329590f (patch) | |
tree | ab0c0f9c1cec48b3b2b465cf8031fd68b53d4fc5 /src/osc.h | |
parent | 3466a5ee2a4e03dae73f6c441d6f1daa5718952d (diff) | |
download | synth-project-42479d2ed8fcbad5fb3ffb52553dad05a329590f.tar.gz synth-project-42479d2ed8fcbad5fb3ffb52553dad05a329590f.tar.bz2 synth-project-42479d2ed8fcbad5fb3ffb52553dad05a329590f.zip |
oop
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 */ /***************/ |