History

phasewarp initial lil command. untested

Paul Batchelor committed 5 years ago

Commit b9fb3a41 parent e6882c76 files · +129 −0Browse files

Unified · Split

6 files
  1. nodes/config.mk +1 −0
  2. nodes/phasewarp/config.mk +2 −0
  3. nodes/phasewarp/l_phasewarp.c +31 −0
  4. nodes/phasewarp/phasewarp.c +87 −0
  5. nodes/phasewarp/phasewarp.h +4 −0
  6. nodes/phasewarp/test.lil +4 −0
nodes/config.mk+1−0
@@ -19,3 +19,4 @@ include nodes/expon/config.mk · 18 unmodified lines
19include nodes/rline/config.mk19include nodes/rline/config.mk
20include nodes/vardelay/config.mk20include nodes/vardelay/config.mk
21include nodes/expmap/config.mk21include nodes/expmap/config.mk
22include nodes/phasewarp/config.mk
nodes/phasewarp/config.mk+2−0
@@ -0,0 +1,2 @@
1OBJ+=nodes/phasewarp/phasewarp.o
2OBJ+=nodes/phasewarp/l_phasewarp.o
nodes/phasewarp/l_phasewarp.c+31−0
@@ -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 "phasewarp.h"
9
10static lil_value_t phasewarp(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, "phasewarp", argc, 2);
17
18 rc = sklil_param(core, argv[0]);
19 SKLIL_PARAM_CHECK(lil, rc, "phasewarp");
20 rc = sklil_param(core, argv[1]);
21 SKLIL_PARAM_CHECK(lil, rc, "phasewarp");
22
23 rc = sk_node_phasewarp(core);
24 SKLIL_ERROR_CHECK(lil, rc, "phasewarp didn't work out.");
25 return NULL;
26}
27
28void sklil_load_phasewarp(lil_t lil)
29{
30 lil_register(lil, "phasewarp", phasewarp);
31}
nodes/phasewarp/phasewarp.c+87−0
@@ -0,0 +1,87 @@
1#include <math.h>
2#include <stdlib.h>
3#include <stdint.h>
4#include "patchwerk.h"
5#include "core.h"
6#include "dsp/phasewarp.h"
7
8struct phasewarp_n {
9 pw_cable *in;
10 pw_cable *pos;
11 pw_cable *out;
12};
13
14static void compute(pw_node *node)
15{
16 int blksize;
17 int n;
18 struct phasewarp_n *phasewarp;
19
20 blksize = pw_node_blksize(node);
21
22 phasewarp = (struct phasewarp_n *)pw_node_get_data(node);
23
24 for (n = 0; n < blksize; n++) {
25 PWFLT in, pos, out;
26 in = pw_cable_get(phasewarp->in, n);
27 pos = pw_cable_get(phasewarp->pos, n);
28
29 out = sk_phasewarp_tick(in, pos);
30 pw_cable_set(phasewarp->out, n, out);
31 }
32}
33
34static void destroy(pw_node *node)
35{
36 pw_patch *patch;
37 int rc;
38 void *ud;
39 rc = pw_node_get_patch(node, &patch);
40 if (rc != PW_OK) return;
41 pw_node_cables_free(node);
42 ud = pw_node_get_data(node);
43 pw_memory_free(patch, &ud);
44}
45
46int sk_node_phasewarp(sk_core *core)
47{
48 pw_patch *patch;
49 pw_node *node;
50 int rc;
51 sk_param in, pos;
52 void *ud;
53 struct phasewarp_n *phasewarp;
54
55 rc = sk_param_get(core, &pos);
56 SK_ERROR_CHECK(rc);
57
58 rc = sk_param_get(core, &in);
59 SK_ERROR_CHECK(rc);
60
61 patch = sk_core_patch(core);
62
63 rc = pw_memory_alloc(patch, sizeof(struct phasewarp_n), &ud);
64 SK_PW_ERROR_CHECK(rc);
65 phasewarp = (struct phasewarp_n *)ud;
66
67 rc = pw_patch_new_node(patch, &node);
68 SK_PW_ERROR_CHECK(rc);
69
70 rc = pw_node_cables_alloc(node, 3);
71 SK_PW_ERROR_CHECK(rc);
72
73 pw_node_set_block(node, 2);
74
75 pw_node_get_cable(node, 0, &phasewarp->in);
76 pw_node_get_cable(node, 1, &phasewarp->pos);
77 pw_node_get_cable(node, 2, &phasewarp->out);
78
79 pw_node_set_data(node, phasewarp);
80 pw_node_set_compute(node, compute);
81 pw_node_set_destroy(node, destroy);
82
83 sk_param_set(core, node, &in, 0);
84 sk_param_set(core, node, &pos, 1);
85 sk_param_out(core, node, 2);
86 return 0;
87}
nodes/phasewarp/phasewarp.h+4−0
@@ -0,0 +1,4 @@
1#ifndef SK_NODE_PHASEWARP_H
2#define SK_NODE_PHASEWARP_H
3int sk_node_phasewarp(sk_core *core);
4#endif
nodes/phasewarp/test.lil+4−0
@@ -0,0 +1,4 @@
1# TBD
2phasor [58 mtof] 0
3wavout zz "test.wav"
4computes 10

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