From 3466a5ee2a4e03dae73f6c441d6f1daa5718952d Mon Sep 17 00:00:00 2001 From: gramanas Date: Fri, 7 Jul 2023 22:19:48 +0300 Subject: moar --- src/osc.h | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'src/osc.h') diff --git a/src/osc.h b/src/osc.h index 3915e5a..732f134 100644 --- a/src/osc.h +++ b/src/osc.h @@ -28,6 +28,15 @@ typedef struct osc_t { long end; enum osc_type type; } osc_t; + +#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 */ void init_osc(); @@ -42,31 +51,35 @@ int osc_load_wav(osc_t * osc, const char * path); /* OSCILATORS */ /***************/ -#define OSC_COMMON(osc) \ - void \ - set_##osc##_start(long start) \ - { OSC_##osc.start = start; } \ - void \ - set_##osc##_end(long end) \ - { OSC_##osc.end = end; } - +// function prototypes common for all oscs #define OSC_COMMON_H(osc) \ void \ set_##osc##_start(long start); \ void \ set_##osc##_end(long end); \ + void \ + set_##osc##_len(long len); \ float \ osc_##osc(float offset); \ float \ osc_##osc##_next(float f, float offset); -/*****************/ -/* osc functions */ -/*****************/ +// function definitions common for all oscs +#define OSC_COMMON(osc) \ + void \ + set_##osc##_start(long start) \ + { OSC_##osc.start = start; } \ + void \ + set_##osc##_end(long end) \ + { OSC_##osc.end = end; } \ + void \ + set_##osc##_len(long len) \ + { OSC_##osc.len = len; } OSC_COMMON_H(tri) OSC_COMMON_H(sin) OSC_COMMON_H(weird) OSC_COMMON_H(sound) +OSC_COMMON_H(saw) #endif /* OSC_H */ -- cgit v1.2.3