From 63db9380f84cb3eb35d2de430b0783afa5773e85 Mon Sep 17 00:00:00 2001 From: sanine Date: Sun, 4 Sep 2022 00:39:24 -0500 Subject: implement callbacks --- examples/callback.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 examples/callback.c (limited to 'examples/callback.c') diff --git a/examples/callback.c b/examples/callback.c new file mode 100644 index 0000000..bf7e187 --- /dev/null +++ b/examples/callback.c @@ -0,0 +1,55 @@ +#include +#include +#include +#include + +#define PI 3.14159 + + +#define SAMPLE_RATE 44100 +#define N_CHANNELS 8 + +float f(float t) +{ + const int f0 = 440; + const int f1 = 880; + return ( t*f1 ) + ( (1-t)*f0 ); +} + + +void callback(int chan, void *d) +{ + bool *loop = d; + *loop = false; + printf("channel %d waves goodnight!\n", chan); +} + + +int main() +{ + float data[SAMPLE_RATE]; + for (long i=0; i