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
5func 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
12regset [gensine [tabnew 8192]] 0
13
14# generate held LFO signal in register 1
15regset [hold [osc [regget 0] 0.1 1 0]] 1
16
17# create 4 voices and add them together
18voice 400 500
19voice 400 600
20add zz zz
21voice 400 300
22add zz zz
23voice 400 200
24add zz zz
25
26# write output to wav file
27wavout zz "sines.wav"
28
29# release LFO signal
30unhold [regget 1]
31
32# compute ~30 seconds of sound
33computes 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
9static 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
23static 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
37void 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 @@
1OBJ+=nodes/buffer/buffer.o
nodes/config.mk+1−0
@@ -8,3 +8,4 @@ include nodes/tabnew/config.mk · 7 unmodified lines
8include nodes/gensine/config.mk8include nodes/gensine/config.mk
9include nodes/osc/config.mk9include nodes/osc/config.mk
10include nodes/reg/config.mk10include nodes/reg/config.mk
11include nodes/buffer/config.mk
nodes/loader.c+2−0
@@ -15,6 +15,7 @@ void sklil_load_tabnew(lil_t lil); · 14 unmodified lines
15void sklil_load_gensine(lil_t lil);15void sklil_load_gensine(lil_t lil);
16void sklil_load_osc(lil_t lil);16void sklil_load_osc(lil_t lil);
17void sklil_load_reg(lil_t lil);17void sklil_load_reg(lil_t lil);
18void sklil_load_buffer(lil_t lil);
18 19
19void sklil_nodes(lil_t lil)20void sklil_nodes(lil_t lil)
20{21{
@@ -28,6 +29,7 @@ void sklil_nodes(lil_t lil) · 7 unmodified lines
28 sklil_load_gensine(lil);29 sklil_load_gensine(lil);
29 sklil_load_osc(lil);30 sklil_load_osc(lil);
30 sklil_load_reg(lil);31 sklil_load_reg(lil);
32 sklil_load_buffer(lil);
31}33}
32 34
33static lil_value_t computes(lil_t lil, size_t argc, lil_value_t *argv)35static 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