History

added peakeq lil command

Paul Batchelor committed 5 years ago

Commit 3407e2f1 parent 1a2cdf98 files · +162 −0Browse files

Unified · Split

8 files
  1. nodes/config.mk +1 −0
  2. nodes/loader.c +2 −0
  3. nodes/peakeq/config.mk +2 −0
  4. nodes/peakeq/l_peakeq.c +33 −0
  5. nodes/peakeq/peakeq.c +113 −0
  6. nodes/peakeq/peakeq.h +4 −0
  7. nodes/peakeq/test.lil +6 −0
  8. nodes/sknodes.h +1 −0
nodes/config.mk+1−0
@@ -27,3 +27,4 @@ include nodes/chorus/config.mk · 26 unmodified lines
2727 include nodes/bezier/config.mk
2828 include nodes/bitnoise/config.mk
2929 include nodes/chaosnoise/config.mk
30+include nodes/peakeq/config.mk
nodes/loader.c+2−0
@@ -34,6 +34,7 @@ void sklil_load_chorus(lil_t lil); · 33 unmodified lines
3434 void sklil_load_bezier(lil_t lil);
3535 void sklil_load_bitnoise(lil_t lil);
3636 void sklil_load_chaosnoise(lil_t lil);
37+void sklil_load_peakeq(lil_t lil);
3738
3839 void sklil_nodes(lil_t lil)
3940 {
@@ -66,6 +67,7 @@ void sklil_nodes(lil_t lil) · 26 unmodified lines
6667 sklil_load_bezier(lil);
6768 sklil_load_bitnoise(lil);
6869 sklil_load_chaosnoise(lil);
70+ sklil_load_peakeq(lil);
6971 }
7072
7173 static lil_value_t computes(lil_t lil, size_t argc, lil_value_t *argv)
nodes/peakeq/config.mk+2−0
@@ -0,0 +1,2 @@
1+OBJ+=nodes/peakeq/peakeq.o
2+OBJ+=nodes/peakeq/l_peakeq.o
nodes/peakeq/l_peakeq.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 "peakeq.h"
9+
10+static lil_value_t peakeq(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, "peakeq", argc, 1);
19+
20+ for (i = 0; i < 4; i++) {
21+ rc = sklil_param(core, argv[i]);
22+ SKLIL_PARAM_CHECK(lil, rc, "peakeq");
23+ }
24+
25+ rc = sk_node_peakeq(core);
26+ SKLIL_ERROR_CHECK(lil, rc, "peakeq didn't work out.");
27+ return NULL;
28+}
29+
30+void sklil_load_peakeq(lil_t lil)
31+{
32+ lil_register(lil, "peakeq", peakeq);
33+}
nodes/peakeq/peakeq.c+113−0
@@ -0,0 +1,113 @@
1+#include <math.h>
2+#include <stdlib.h>
3+#include <stdint.h>
4+#include "patchwerk.h"
5+#include "core.h"
6+#define SK_PEAKEQ_PRIV
7+#include "dsp/peakeq.h"
8+
9+struct peakeq_n {
10+ pw_cable *in;
11+ pw_cable *freq;
12+ pw_cable *bw;
13+ pw_cable *gain;
14+ pw_cable *out;
15+ sk_peakeq peakeq;
16+};
17+
18+static void compute(pw_node *node)
19+{
20+ int blksize;
21+ int n;
22+ struct peakeq_n *peakeq;
23+
24+ blksize = pw_node_blksize(node);
25+
26+ peakeq = (struct peakeq_n *)pw_node_get_data(node);
27+
28+ for (n = 0; n < blksize; n++) {
29+ PWFLT in, freq, bw, gain, out;
30+ in = pw_cable_get(peakeq->in, n);
31+
32+ freq = pw_cable_get(peakeq->freq, n);
33+ sk_peakeq_freq(&peakeq->peakeq, freq);
34+
35+ bw = pw_cable_get(peakeq->bw, n);
36+ sk_peakeq_bandwidth(&peakeq->peakeq, bw);
37+
38+ gain = pw_cable_get(peakeq->gain, n);
39+ sk_peakeq_gain(&peakeq->peakeq, gain);
40+
41+ out = sk_peakeq_tick(&peakeq->peakeq, in);
42+ pw_cable_set(peakeq->out, n, out);
43+ }
44+}
45+
46+static void destroy(pw_node *node)
47+{
48+ pw_patch *patch;
49+ int rc;
50+ void *ud;
51+ rc = pw_node_get_patch(node, &patch);
52+ if (rc != PW_OK) return;
53+ pw_node_cables_free(node);
54+ ud = pw_node_get_data(node);
55+ pw_memory_free(patch, &ud);
56+}
57+
58+int sk_node_peakeq(sk_core *core)
59+{
60+ pw_patch *patch;
61+ pw_node *node;
62+ int rc;
63+ sk_param in, freq, bw, gain;
64+ void *ud;
65+ struct peakeq_n *peakeq;
66+ int sr;
67+
68+ rc = sk_param_get(core, &gain);
69+ SK_ERROR_CHECK(rc);
70+
71+ rc = sk_param_get(core, &bw);
72+ SK_ERROR_CHECK(rc);
73+
74+ rc = sk_param_get(core, &freq);
75+ SK_ERROR_CHECK(rc);
76+
77+ rc = sk_param_get(core, &in);
78+ SK_ERROR_CHECK(rc);
79+
80+ patch = sk_core_patch(core);
81+
82+ rc = pw_memory_alloc(patch, sizeof(struct peakeq_n), &ud);
83+ SK_PW_ERROR_CHECK(rc);
84+ peakeq = (struct peakeq_n *)ud;
85+
86+ sr = pw_patch_srate_get(patch);
87+ sk_peakeq_init(&peakeq->peakeq, sr);
88+
89+ rc = pw_patch_new_node(patch, &node);
90+ SK_PW_ERROR_CHECK(rc);
91+
92+ rc = pw_node_cables_alloc(node, 5);
93+ SK_PW_ERROR_CHECK(rc);
94+
95+ pw_node_set_block(node, 4);
96+
97+ pw_node_get_cable(node, 0, &peakeq->in);
98+ pw_node_get_cable(node, 1, &peakeq->freq);
99+ pw_node_get_cable(node, 2, &peakeq->bw);
100+ pw_node_get_cable(node, 3, &peakeq->gain);
101+ pw_node_get_cable(node, 4, &peakeq->out);
102+
103+ pw_node_set_data(node, peakeq);
104+ pw_node_set_compute(node, compute);
105+ pw_node_set_destroy(node, destroy);
106+
107+ sk_param_set(core, node, &in, 0);
108+ sk_param_set(core, node, &freq, 1);
109+ sk_param_set(core, node, &bw, 2);
110+ sk_param_set(core, node, &gain, 3);
111+ sk_param_out(core, node, 4);
112+ return 0;
113+}
nodes/peakeq/peakeq.h+4−0
@@ -0,0 +1,4 @@
1+#ifndef SK_NODE_PEAKEQ_H
2+#define SK_NODE_PEAKEQ_H
3+int sk_node_peakeq(sk_core *core);
4+#endif
nodes/peakeq/test.lil+6−0
@@ -0,0 +1,6 @@
1+# TODO: we really need a real noise module
2+chaosnoise 1.9 4000 0.141
3+mul zz 0.5
4+peakeq zz 2000 300 5
5+wavout zz "test.wav"
6+computes 10
nodes/sknodes.h+1−0
@@ -32,4 +32,5 @@ int sk_node_chorus(sk_core *core); · 31 unmodified lines
3232 int sk_node_bezier(sk_core *core);
3333 int sk_node_bitnoise(sk_core *core);
3434 int sk_node_chaosnoise(sk_core *core);
35+int sk_node_peakeq(sk_core *core);
3536 #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