History

added chaosnoise lil command

Paul Batchelor committed 5 years ago

Commit 1a2cdf91 parent 371e0a68 files · +146 −0Browse files

Unified · Split

8 files
  1. nodes/chaosnoise/chaosnoise.c +100 −0
  2. nodes/chaosnoise/chaosnoise.h +4 −0
  3. nodes/chaosnoise/config.mk +2 −0
  4. nodes/chaosnoise/l_chaosnoise.c +33 −0
  5. nodes/chaosnoise/test.lil +3 −0
  6. nodes/config.mk +1 −0
  7. nodes/loader.c +2 −0
  8. nodes/sknodes.h +1 −0
nodes/chaosnoise/chaosnoise.c+100−0
@@ -0,0 +1,100 @@
1#include <math.h>
2#include <stdlib.h>
3#include <stdint.h>
4#include "patchwerk.h"
5#include "core.h"
6#define SK_CHAOSNOISE_PRIV
7#include "dsp/chaosnoise.h"
8
9struct chaosnoise_n {
10 pw_cable *chaos;
11 pw_cable *rate;
12 pw_cable *out;
13 sk_chaosnoise chaosnoise;
14};
15
16static void compute(pw_node *node)
17{
18 int blksize;
19 int n;
20 struct chaosnoise_n *chaosnoise;
21
22 blksize = pw_node_blksize(node);
23
24 chaosnoise = (struct chaosnoise_n *)pw_node_get_data(node);
25
26 for (n = 0; n < blksize; n++) {
27 PWFLT chaos, rate, out;
28
29 chaos = pw_cable_get(chaosnoise->chaos, n);
30 sk_chaosnoise_chaos(&chaosnoise->chaosnoise, chaos);
31 rate = pw_cable_get(chaosnoise->rate, n);
32 sk_chaosnoise_rate(&chaosnoise->chaosnoise, rate);
33
34 out = sk_chaosnoise_tick(&chaosnoise->chaosnoise);
35 pw_cable_set(chaosnoise->out, n, out);
36 }
37}
38
39static void destroy(pw_node *node)
40{
41 pw_patch *patch;
42 int rc;
43 void *ud;
44 rc = pw_node_get_patch(node, &patch);
45 if (rc != PW_OK) return;
46 pw_node_cables_free(node);
47 ud = pw_node_get_data(node);
48 pw_memory_free(patch, &ud);
49}
50
51int sk_node_chaosnoise(sk_core *core)
52{
53 pw_patch *patch;
54 pw_node *node;
55 int rc;
56 sk_param chaos, rate;
57 SKFLT init;
58 void *ud;
59 struct chaosnoise_n *chaosnoise;
60 int sr;
61
62 rc = sk_param_get_constant(core, &init);
63 SK_ERROR_CHECK(rc);
64
65 rc = sk_param_get(core, &rate);
66 SK_ERROR_CHECK(rc);
67
68 rc = sk_param_get(core, &chaos);
69 SK_ERROR_CHECK(rc);
70
71 patch = sk_core_patch(core);
72
73 rc = pw_memory_alloc(patch, sizeof(struct chaosnoise_n), &ud);
74 SK_PW_ERROR_CHECK(rc);
75 chaosnoise = (struct chaosnoise_n *)ud;
76
77 sr = pw_patch_srate_get(patch);
78 sk_chaosnoise_init(&chaosnoise->chaosnoise, sr, init);
79
80 rc = pw_patch_new_node(patch, &node);
81 SK_PW_ERROR_CHECK(rc);
82
83 rc = pw_node_cables_alloc(node, 3);
84 SK_PW_ERROR_CHECK(rc);
85
86 pw_node_set_block(node, 2);
87
88 pw_node_get_cable(node, 0, &chaosnoise->chaos);
89 pw_node_get_cable(node, 1, &chaosnoise->rate);
90 pw_node_get_cable(node, 2, &chaosnoise->out);
91
92 pw_node_set_data(node, chaosnoise);
93 pw_node_set_compute(node, compute);
94 pw_node_set_destroy(node, destroy);
95
96 sk_param_set(core, node, &chaos, 0);
97 sk_param_set(core, node, &rate, 1);
98 sk_param_out(core, node, 2);
99 return 0;
100}
nodes/chaosnoise/chaosnoise.h+4−0
@@ -0,0 +1,4 @@
1#ifndef SK_NODE_CHAOSNOISE_H
2#define SK_NODE_CHAOSNOISE_H
3int sk_node_chaosnoise(sk_core *core);
4#endif
nodes/chaosnoise/config.mk+2−0
@@ -0,0 +1,2 @@
1OBJ+=nodes/chaosnoise/chaosnoise.o
2OBJ+=nodes/chaosnoise/l_chaosnoise.o
nodes/chaosnoise/l_chaosnoise.c+33−0
@@ -0,0 +1,33 @@
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 "chaosnoise.h"
9
10static lil_value_t chaosnoise(lil_t lil, size_t argc, lil_value_t *argv)
11{
12 sk_core *core;
13 int rc;
14 int i;
15
16 core = lil_get_data(lil);
17
18 SKLIL_ARITY_CHECK(lil, "chaosnoise", argc, 3);
19
20 for (i = 0; i < 3; i++) {
21 rc = sklil_param(core, argv[i]);
22 SKLIL_PARAM_CHECK(lil, rc, "chaosnoise");
23 }
24
25 rc = sk_node_chaosnoise(core);
26 SKLIL_ERROR_CHECK(lil, rc, "chaosnoise didn't work out.");
27 return NULL;
28}
29
30void sklil_load_chaosnoise(lil_t lil)
31{
32 lil_register(lil, "chaosnoise", chaosnoise);
33}
nodes/chaosnoise/test.lil+3−0
@@ -0,0 +1,3 @@
1chaosnoise 1.9 4000 0.141
2wavout zz "test.wav"
3computes 10
nodes/config.mk+1−0
@@ -26,3 +26,4 @@ include nodes/modalres/config.mk · 25 unmodified lines
26include nodes/chorus/config.mk26include nodes/chorus/config.mk
27include nodes/bezier/config.mk27include nodes/bezier/config.mk
28include nodes/bitnoise/config.mk28include nodes/bitnoise/config.mk
29include nodes/chaosnoise/config.mk
nodes/loader.c+2−0
@@ -33,6 +33,7 @@ void sklil_load_modalres(lil_t lil); · 32 unmodified lines
33void sklil_load_chorus(lil_t lil);33void sklil_load_chorus(lil_t lil);
34void sklil_load_bezier(lil_t lil);34void sklil_load_bezier(lil_t lil);
35void sklil_load_bitnoise(lil_t lil);35void sklil_load_bitnoise(lil_t lil);
36void sklil_load_chaosnoise(lil_t lil);
36 37
37void sklil_nodes(lil_t lil)38void sklil_nodes(lil_t lil)
38{39{
@@ -64,6 +65,7 @@ void sklil_nodes(lil_t lil) · 25 unmodified lines
64 sklil_load_chorus(lil);65 sklil_load_chorus(lil);
65 sklil_load_bezier(lil);66 sklil_load_bezier(lil);
66 sklil_load_bitnoise(lil);67 sklil_load_bitnoise(lil);
68 sklil_load_chaosnoise(lil);
67}69}
68 70
69static lil_value_t computes(lil_t lil, size_t argc, lil_value_t *argv)71static lil_value_t computes(lil_t lil, size_t argc, lil_value_t *argv)
nodes/sknodes.h+1−0
@@ -31,4 +31,5 @@ int sk_node_modalres(sk_core *core); · 30 unmodified lines
31int sk_node_chorus(sk_core *core);31int sk_node_chorus(sk_core *core);
32int sk_node_bezier(sk_core *core);32int sk_node_bezier(sk_core *core);
33int sk_node_bitnoise(sk_core *core);33int sk_node_bitnoise(sk_core *core);
34int sk_node_chaosnoise(sk_core *core);
34#endif35#endif

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t