History

buffer commands in LIL

Paul Batchelor committed 5 years ago

Commit 93158fc1 parent b45a0c95 files · +78 −0Browse files

Unified · Split

5 files
  1. examples/sines.lil +33 −0
  2. nodes/buffer/buffer.c +41 −0
  3. nodes/buffer/config.mk +1 −0
  4. nodes/config.mk +1 −0
  5. nodes/loader.c +2 −0
examples/sines.lil+33−0
@@ -0,0 +1,33 @@
1+# mainly testing out hold/unhold functionality
2+# one LFO controls the frequency of 4 oscillators
3+
4+# function to create a voice
5+func voice {min max} {
6+ osc [regget 0] \
7+ [biscale [regget 1] $min $max] \
8+ [param 0.1] [param 0]
9+}
10+
11+# generate sine table in register 0
12+regset [gensine [tabnew 8192]] 0
13+
14+# generate held LFO signal in register 1
15+regset [hold [osc [regget 0] 0.1 1 0]] 1
16+
17+# create 4 voices and add them together
18+voice 400 500
19+voice 400 600
20+add zz zz
21+voice 400 300
22+add zz zz
23+voice 400 200
24+add zz zz
25+
26+# write output to wav file
27+wavout zz "sines.wav"
28+
29+# release LFO signal
30+unhold [regget 1]
31+
32+# compute ~30 seconds of sound
33+computes 30
nodes/buffer/buffer.c+41−0
@@ -0,0 +1,41 @@
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+
9+static lil_value_t hold(lil_t lil, size_t argc, lil_value_t *argv)
10+{
11+ sk_core *core;
12+ int rc;
13+
14+ core = lil_get_data(lil);
15+
16+ rc = sk_core_hold(core);
17+
18+ SKLIL_ERROR_CHECK(lil, rc, "hold didn't work out.");
19+
20+ return NULL;
21+}
22+
23+static lil_value_t unhold(lil_t lil, size_t argc, lil_value_t *argv)
24+{
25+ sk_core *core;
26+ int rc;
27+
28+ core = lil_get_data(lil);
29+
30+ rc = sk_core_hold(core);
31+
32+ SKLIL_ERROR_CHECK(lil, rc, "unhold didn't work out.");
33+
34+ return NULL;
35+}
36+
37+void sklil_load_buffer(lil_t lil)
38+{
39+ lil_register(lil, "hold", hold);
40+ lil_register(lil, "unhold", unhold);
41+}
nodes/buffer/config.mk+1−0
@@ -0,0 +1 @@
1+OBJ+=nodes/buffer/buffer.o
nodes/config.mk+1−0
@@ -8,3 +8,4 @@ include nodes/tabnew/config.mk · 7 unmodified lines
88 include nodes/gensine/config.mk
99 include nodes/osc/config.mk
1010 include nodes/reg/config.mk
11+include nodes/buffer/config.mk
nodes/loader.c+2−0
@@ -15,6 +15,7 @@ void sklil_load_tabnew(lil_t lil); · 14 unmodified lines
1515 void sklil_load_gensine(lil_t lil);
1616 void sklil_load_osc(lil_t lil);
1717 void sklil_load_reg(lil_t lil);
18+void sklil_load_buffer(lil_t lil);
1819
1920 void sklil_nodes(lil_t lil)
2021 {
@@ -28,6 +29,7 @@ void sklil_nodes(lil_t lil) · 7 unmodified lines
2829 sklil_load_gensine(lil);
2930 sklil_load_osc(lil);
3031 sklil_load_reg(lil);
32+ sklil_load_buffer(lil);
3133 }
3234
3335 static lil_value_t computes(lil_t lil, size_t argc, lil_value_t *argv)

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