Unified · Split
| @@ -8,7 +8,7 @@ WORGLE_FLAGS=-g -Werror · 7 unmodified lines | ||
| 8 | 8 | C89?=$(CC) -std=c89 |
| 9 | 9 | C99?=$(CC) -std=c99 |
| 10 | 10 | |
| 11 | −CFLAGS += -Ipatchwerk -I. | |
| 11 | +CFLAGS += -Ipatchwerk -I. -Inodes | |
| 12 | 12 | CFLAGS += -Wall |
| 13 | 13 | CFLAGS += -O3 |
| 14 | 14 | CFLAGS += -g |
| @@ -33,6 +33,7 @@ swell.c swell.h \ · 18 unmodified lines | ||
| 33 | 33 | biramp.c biramp.h \ |
| 34 | 34 | core.c core.h \ |
| 35 | 35 | expmap.c expmap.h \ |
| 36 | +scale.c scale.h \ | |
| 36 | 37 | |
| 37 | 38 | OBJ=\ |
| 38 | 39 | bigverb.o \ |
| @@ -59,6 +60,9 @@ scale.o \ · 20 unmodified lines | ||
| 59 | 60 | include nodes/config.mk |
| 60 | 61 | |
| 61 | 62 | OBJ+=lil/lil.c99 |
| 63 | +OBJ+=lil/lil_main.c99 | |
| 64 | +OBJ+=nodes/loader.o | |
| 65 | +OBJ+=nodes/sklil.o | |
| 62 | 66 | |
| 63 | 67 | .SUFFIX: .org .c |
| 64 | 68 | |
| @@ -133,6 +137,9 @@ libsndkit.a: tangle $(OBJ) · 68 unmodified lines | ||
| 133 | 137 | @echo "Building $@" |
| 134 | 138 | @$(AR) rcs $@ $(OBJ) |
| 135 | 139 | |
| 140 | +sndkit: main.o $(OBJ) | |
| 141 | + $(CC) $(CFLAGS) $^ -o $@ | |
| 142 | + | |
| 136 | 143 | clean: |
| 137 | 144 | $(RM) $(TANGLED) |
| 138 | 145 | $(RM) worgle/worglite |
| @@ -118,6 +118,31 @@ void sk_core_compute(sk_core *core) · 117 unmodified lines | ||
| 118 | 118 | } |
| 119 | 119 | #+END_SRC |
| 120 | 120 | |
| 121 | +=sk_core_computes= is like =sk_core_compute=, but computes | |
| 122 | +an approximuate number of seconds of audio. This value | |
| 123 | +gets rounded to the nearest block. The number of blocks | |
| 124 | +rendered gets rendered. | |
| 125 | + | |
| 126 | +#+NAME: funcdefs | |
| 127 | +#+BEGIN_SRC c | |
| 128 | +size_t sk_core_computes(sk_core *core, SKFLT secs); | |
| 129 | +#+END_SRC | |
| 130 | + | |
| 131 | +#+NAME: funcs | |
| 132 | +#+BEGIN_SRC c | |
| 133 | +size_t sk_core_computes(sk_core *core, SKFLT secs) | |
| 134 | +{ | |
| 135 | + size_t nblocks, n; | |
| 136 | + nblocks = sk_core_seconds_to_blocks(core, secs); | |
| 137 | + | |
| 138 | + for (n = 0; n < nblocks; n++) { | |
| 139 | + sk_core_compute(core); | |
| 140 | + } | |
| 141 | + | |
| 142 | + return nblocks; | |
| 143 | +} | |
| 144 | +#+END_SRC | |
| 145 | + | |
| 121 | 146 | Building up nodes involves interacting with the patchwerk |
| 122 | 147 | API. To get the top level struct of that opaquely, use |
| 123 | 148 | =sk_core_patch=. |
| @@ -0,0 +1,5 @@ | ||
| 1 | +# basically ex3 | |
| 2 | +sine 350 0.2 | |
| 3 | +sine [add [sine 0.1 100] 440] 0.2 | |
| 4 | +add zz zz | |
| 5 | +wavout zz test.wav | |
| @@ -0,0 +1,3 @@ | ||
| 1 | +sine 440 0.5 | |
| 2 | +wavout zz "sine.wav" | |
| 3 | +computes 40 | |
| @@ -1 +1,2 @@ | ||
| 1 | 1 | OBJ+=nodes/arith/arith.o |
| 2 | +OBJ+=nodes/arith/l_arith.o | |
| @@ -0,0 +1,27 @@ | ||
| 1 | +#include <stdlib.h> | |
| 2 | +#include <stdio.h> | |
| 3 | +#include <string.h> | |
| 4 | +#include "lil/lil.h" | |
| 5 | +#include "patchwerk/patchwerk.h" | |
| 6 | +#include "core.h" | |
| 7 | +#include "sklil.h" | |
| 8 | +#include "arith.h" | |
| 9 | + | |
| 10 | +static lil_value_t add(lil_t lil, size_t argc, lil_value_t *argv) | |
| 11 | +{ | |
| 12 | + sk_core *core; | |
| 13 | + core = lil_get_data(lil); | |
| 14 | + | |
| 15 | + SKLIL_ARITY_CHECK(lil, "add", argc, 2); | |
| 16 | + | |
| 17 | + sklil_param(core, argv[0]); | |
| 18 | + sklil_param(core, argv[1]); | |
| 19 | + | |
| 20 | + sk_node_add(core); | |
| 21 | + return NULL; | |
| 22 | +} | |
| 23 | + | |
| 24 | +void sklil_load_arith(lil_t lil) | |
| 25 | +{ | |
| 26 | + lil_register(lil, "add", add); | |
| 27 | +} | |
| @@ -0,0 +1,44 @@ | ||
| 1 | +#include <stdlib.h> | |
| 2 | +#include <stdio.h> | |
| 3 | +#include "lil/lil.h" | |
| 4 | +#include "patchwerk/patchwerk.h" | |
| 5 | +#include "core.h" | |
| 6 | +#include "sklil.h" | |
| 7 | + | |
| 8 | +void sklil_load_sine(lil_t lil); | |
| 9 | +void sklil_load_wavout(lil_t lil); | |
| 10 | +void sklil_load_arith(lil_t lil); | |
| 11 | + | |
| 12 | +void sklil_nodes(lil_t lil) | |
| 13 | +{ | |
| 14 | + sklil_load_sine(lil); | |
| 15 | + sklil_load_wavout(lil); | |
| 16 | + sklil_load_arith(lil); | |
| 17 | +} | |
| 18 | + | |
| 19 | +static lil_value_t computes(lil_t lil, size_t argc, lil_value_t *argv) | |
| 20 | +{ | |
| 21 | + sk_core *core; | |
| 22 | + core = lil_get_data(lil); | |
| 23 | + | |
| 24 | + SKLIL_ARITY_CHECK(lil, "computes", argc, 1); | |
| 25 | + | |
| 26 | + sk_core_computes(core, lil_to_double(argv[0])); | |
| 27 | + return NULL; | |
| 28 | +} | |
| 29 | + | |
| 30 | +void sklil_loader(lil_t lil) | |
| 31 | +{ | |
| 32 | + sk_core *core; | |
| 33 | + core = sk_core_new(44100); | |
| 34 | + lil_set_data(lil, core); | |
| 35 | + sklil_nodes(lil); | |
| 36 | + lil_register(lil, "computes", computes); | |
| 37 | +} | |
| 38 | + | |
| 39 | +void sklil_clean(lil_t lil) | |
| 40 | +{ | |
| 41 | + sk_core *core; | |
| 42 | + core = lil_get_data(lil); | |
| 43 | + sk_core_del(core); | |
| 44 | +} | |
| @@ -1 +1,2 @@ | ||
| 1 | 1 | OBJ+=nodes/sine/sine.o |
| 2 | +OBJ+=nodes/sine/l_sine.o | |
| @@ -0,0 +1,27 @@ | ||
| 1 | +#include <stdlib.h> | |
| 2 | +#include <stdio.h> | |
| 3 | +#include <string.h> | |
| 4 | +#include "lil/lil.h" | |
| 5 | +#include "patchwerk/patchwerk.h" | |
| 6 | +#include "core.h" | |
| 7 | +#include "sklil.h" | |
| 8 | +#include "sine.h" | |
| 9 | + | |
| 10 | +static lil_value_t sine(lil_t lil, size_t argc, lil_value_t *argv) | |
| 11 | +{ | |
| 12 | + sk_core *core; | |
| 13 | + core = lil_get_data(lil); | |
| 14 | + | |
| 15 | + SKLIL_ARITY_CHECK(lil, "sine", argc, 2); | |
| 16 | + | |
| 17 | + sklil_param(core, argv[0]); | |
| 18 | + sklil_param(core, argv[1]); | |
| 19 | + | |
| 20 | + sk_node_sine(core); | |
| 21 | + return NULL; | |
| 22 | +} | |
| 23 | + | |
| 24 | +void sklil_load_sine(lil_t lil) | |
| 25 | +{ | |
| 26 | + lil_register(lil, "sine", sine); | |
| 27 | +} | |
| @@ -0,0 +1,18 @@ | ||
| 1 | +#include <stdlib.h> | |
| 2 | +#include <stdio.h> | |
| 3 | +#include <string.h> | |
| 4 | +#include "lil/lil.h" | |
| 5 | +#include "patchwerk/patchwerk.h" | |
| 6 | +#include "core.h" | |
| 7 | + | |
| 8 | +void sklil_param(sk_core *core, lil_value_t arg) | |
| 9 | +{ | |
| 10 | + const char *sarg; | |
| 11 | + sarg = lil_to_string(arg); | |
| 12 | + | |
| 13 | + if (!strcmp(sarg, "zz") || strlen(sarg) == 0) { | |
| 14 | + return; | |
| 15 | + } | |
| 16 | + | |
| 17 | + sk_core_constant(core, lil_to_double(arg)); | |
| 18 | +} | |
| @@ -0,0 +1,10 @@ | ||
| 1 | +#ifndef SKLIL_H | |
| 2 | +#define SKLIL_H | |
| 3 | +#define SKLIL_ARITY_CHECK(LIL, NODE, ARGC, NARGS) \ | |
| 4 | +if (ARGC < NARGS) { \ | |
| 5 | + lil_set_error(LIL, NODE ": not enough args."); \ | |
| 6 | + return NULL; \ | |
| 7 | +} | |
| 8 | + | |
| 9 | +void sklil_param(sk_core *core, lil_value_t arg); | |
| 10 | +#endif | |
| @@ -1 +1,2 @@ | ||
| 1 | 1 | OBJ+=nodes/wavout/wavout.c99 |
| 2 | +OBJ+=nodes/wavout/l_wavout.o | |
| @@ -0,0 +1,26 @@ | ||
| 1 | +#include <stdlib.h> | |
| 2 | +#include <stdio.h> | |
| 3 | +#include <string.h> | |
| 4 | +#include "lil/lil.h" | |
| 5 | +#include "patchwerk/patchwerk.h" | |
| 6 | +#include "core.h" | |
| 7 | +#include "sklil.h" | |
| 8 | +#include "wavout.h" | |
| 9 | + | |
| 10 | +static lil_value_t wavout(lil_t lil, size_t argc, lil_value_t *argv) | |
| 11 | +{ | |
| 12 | + sk_core *core; | |
| 13 | + core = lil_get_data(lil); | |
| 14 | + | |
| 15 | + SKLIL_ARITY_CHECK(lil, "wavout", argc, 2); | |
| 16 | + | |
| 17 | + sklil_param(core, argv[0]); | |
| 18 | + | |
| 19 | + sk_node_wavout(core, lil_to_string(argv[1])); | |
| 20 | + return NULL; | |
| 21 | +} | |
| 22 | + | |
| 23 | +void sklil_load_wavout(lil_t lil) | |
| 24 | +{ | |
| 25 | + lil_register(lil, "wavout", wavout); | |
| 26 | +} | |