Unified · Split
| @@ -28,3 +28,4 @@ include nodes/bezier/config.mk · 27 unmodified lines | |||
| 28 | include nodes/bitnoise/config.mk | 28 | include nodes/bitnoise/config.mk |
| 29 | include nodes/chaosnoise/config.mk | 29 | include nodes/chaosnoise/config.mk |
| 30 | include nodes/peakeq/config.mk | 30 | include nodes/peakeq/config.mk |
| 31 | include nodes/valp1/config.mk | ||
| @@ -35,6 +35,7 @@ void sklil_load_bezier(lil_t lil); · 34 unmodified lines | |||
| 35 | void sklil_load_bitnoise(lil_t lil); | 35 | void sklil_load_bitnoise(lil_t lil); |
| 36 | void sklil_load_chaosnoise(lil_t lil); | 36 | void sklil_load_chaosnoise(lil_t lil); |
| 37 | void sklil_load_peakeq(lil_t lil); | 37 | void sklil_load_peakeq(lil_t lil); |
| 38 | void sklil_load_valp1(lil_t lil); | ||
| 38 | 39 | ||
| 39 | void sklil_nodes(lil_t lil) | 40 | void sklil_nodes(lil_t lil) |
| 40 | { | 41 | { |
| @@ -68,6 +69,7 @@ void sklil_nodes(lil_t lil) · 27 unmodified lines | |||
| 68 | sklil_load_bitnoise(lil); | 69 | sklil_load_bitnoise(lil); |
| 69 | sklil_load_chaosnoise(lil); | 70 | sklil_load_chaosnoise(lil); |
| 70 | sklil_load_peakeq(lil); | 71 | sklil_load_peakeq(lil); |
| 72 | sklil_load_valp1(lil); | ||
| 71 | } | 73 | } |
| 72 | 74 | ||
| 73 | static lil_value_t computes(lil_t lil, size_t argc, lil_value_t *argv) | 75 | static lil_value_t computes(lil_t lil, size_t argc, lil_value_t *argv) |
| @@ -33,4 +33,5 @@ int sk_node_bezier(sk_core *core); · 32 unmodified lines | |||
| 33 | int sk_node_bitnoise(sk_core *core); | 33 | int sk_node_bitnoise(sk_core *core); |
| 34 | int sk_node_chaosnoise(sk_core *core); | 34 | int sk_node_chaosnoise(sk_core *core); |
| 35 | int sk_node_peakeq(sk_core *core); | 35 | int sk_node_peakeq(sk_core *core); |
| 36 | int sk_node_valp1(sk_core *core); | ||
| 36 | #endif | 37 | #endif |
| @@ -0,0 +1,2 @@ | |||
| 1 | OBJ+=nodes/valp1/valp1.o | ||
| 2 | OBJ+=nodes/valp1/l_valp1.o | ||
| @@ -0,0 +1,31 @@ | |||
| 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 "valp1.h" | ||
| 9 | |||
| 10 | static lil_value_t valp1(lil_t lil, size_t argc, lil_value_t *argv) | ||
| 11 | { | ||
| 12 | sk_core *core; | ||
| 13 | int rc; | ||
| 14 | core = lil_get_data(lil); | ||
| 15 | |||
| 16 | SKLIL_ARITY_CHECK(lil, "valp1", argc, 1); | ||
| 17 | |||
| 18 | rc = sklil_param(core, argv[0]); | ||
| 19 | SKLIL_PARAM_CHECK(lil, rc, "valp1"); | ||
| 20 | rc = sklil_param(core, argv[1]); | ||
| 21 | SKLIL_PARAM_CHECK(lil, rc, "valp1"); | ||
| 22 | |||
| 23 | rc = sk_node_valp1(core); | ||
| 24 | SKLIL_ERROR_CHECK(lil, rc, "valp1 didn't work out."); | ||
| 25 | return NULL; | ||
| 26 | } | ||
| 27 | |||
| 28 | void sklil_load_valp1(lil_t lil) | ||
| 29 | { | ||
| 30 | lil_register(lil, "valp1", valp1); | ||
| 31 | } | ||
| @@ -0,0 +1,5 @@ | |||
| 1 | chaosnoise 1.9 4000 0.141 | ||
| 2 | valp1 zz 300 | ||
| 3 | mul zz 0.5 | ||
| 4 | wavout zz "test.wav" | ||
| 5 | computes 10 | ||
| @@ -0,0 +1,94 @@ | |||
| 1 | #include <math.h> | ||
| 2 | #include <stdlib.h> | ||
| 3 | #include <stdint.h> | ||
| 4 | #include "patchwerk.h" | ||
| 5 | #include "core.h" | ||
| 6 | #define SK_VALP1_PRIV | ||
| 7 | #include "dsp/valp1.h" | ||
| 8 | |||
| 9 | struct valp1_n { | ||
| 10 | pw_cable *in; | ||
| 11 | pw_cable *freq; | ||
| 12 | pw_cable *out; | ||
| 13 | sk_valp1 valp1; | ||
| 14 | }; | ||
| 15 | |||
| 16 | static void compute(pw_node *node) | ||
| 17 | { | ||
| 18 | int blksize; | ||
| 19 | int n; | ||
| 20 | struct valp1_n *valp1; | ||
| 21 | |||
| 22 | blksize = pw_node_blksize(node); | ||
| 23 | |||
| 24 | valp1 = (struct valp1_n *)pw_node_get_data(node); | ||
| 25 | |||
| 26 | for (n = 0; n < blksize; n++) { | ||
| 27 | PWFLT in, freq, out; | ||
| 28 | in = pw_cable_get(valp1->in, n); | ||
| 29 | freq = pw_cable_get(valp1->freq, n); | ||
| 30 | sk_valp1_freq(&valp1->valp1, freq); | ||
| 31 | |||
| 32 | out = sk_valp1_tick(&valp1->valp1, in); | ||
| 33 | pw_cable_set(valp1->out, n, out); | ||
| 34 | } | ||
| 35 | } | ||
| 36 | |||
| 37 | static void destroy(pw_node *node) | ||
| 38 | { | ||
| 39 | pw_patch *patch; | ||
| 40 | int rc; | ||
| 41 | void *ud; | ||
| 42 | rc = pw_node_get_patch(node, &patch); | ||
| 43 | if (rc != PW_OK) return; | ||
| 44 | pw_node_cables_free(node); | ||
| 45 | ud = pw_node_get_data(node); | ||
| 46 | pw_memory_free(patch, &ud); | ||
| 47 | } | ||
| 48 | |||
| 49 | int sk_node_valp1(sk_core *core) | ||
| 50 | { | ||
| 51 | pw_patch *patch; | ||
| 52 | pw_node *node; | ||
| 53 | int rc; | ||
| 54 | sk_param in, freq; | ||
| 55 | void *ud; | ||
| 56 | struct valp1_n *valp1; | ||
| 57 | int sr; | ||
| 58 | |||
| 59 | rc = sk_param_get(core, &freq); | ||
| 60 | SK_ERROR_CHECK(rc); | ||
| 61 | |||
| 62 | rc = sk_param_get(core, &in); | ||
| 63 | SK_ERROR_CHECK(rc); | ||
| 64 | |||
| 65 | patch = sk_core_patch(core); | ||
| 66 | |||
| 67 | rc = pw_memory_alloc(patch, sizeof(struct valp1_n), &ud); | ||
| 68 | SK_PW_ERROR_CHECK(rc); | ||
| 69 | valp1 = (struct valp1_n *)ud; | ||
| 70 | |||
| 71 | sr = pw_patch_srate_get(patch); | ||
| 72 | sk_valp1_init(&valp1->valp1, sr); | ||
| 73 | |||
| 74 | rc = pw_patch_new_node(patch, &node); | ||
| 75 | SK_PW_ERROR_CHECK(rc); | ||
| 76 | |||
| 77 | rc = pw_node_cables_alloc(node, 3); | ||
| 78 | SK_PW_ERROR_CHECK(rc); | ||
| 79 | |||
| 80 | pw_node_set_block(node, 2); | ||
| 81 | |||
| 82 | pw_node_get_cable(node, 0, &valp1->in); | ||
| 83 | pw_node_get_cable(node, 1, &valp1->freq); | ||
| 84 | pw_node_get_cable(node, 2, &valp1->out); | ||
| 85 | |||
| 86 | pw_node_set_data(node, valp1); | ||
| 87 | pw_node_set_compute(node, compute); | ||
| 88 | pw_node_set_destroy(node, destroy); | ||
| 89 | |||
| 90 | sk_param_set(core, node, &in, 0); | ||
| 91 | sk_param_set(core, node, &freq, 1); | ||
| 92 | sk_param_out(core, node, 2); | ||
| 93 | return 0; | ||
| 94 | } | ||
| @@ -0,0 +1,4 @@ | |||
| 1 | #ifndef SK_NODE_VALP1_H | ||
| 2 | #define SK_NODE_VALP1_H | ||
| 3 | int sk_node_valp1(sk_core *core); | ||
| 4 | #endif | ||