-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME
81 lines (72 loc) · 1.82 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
--
-- ckv
--
-- an audio language based on Lua,
-- inspired by ChucK
--
-- http://ckvlang.org/
--
-- Primary Author:
-- Tom Lieber tom@alltom.com
--
--
-- INSTALL:
--
-- detailed installation instructions are in the tutorial:
-- http://ckvlang.org/tutorial.html
--
-- but for advanced users, this is all you need to know:
--
-- Dependencies:
-- LUA: download, build, and "make install"
-- http://www.lua.org/
--
-- FFMPEG: download, build, and "make install"
-- http://ffmpeg.org/
--
-- ckv:
-- $ make
-- $ ./ckv -h
-- $ ./ckv README # this file is an executable example!
-- $ ./ckv ex/01.ckv
-- $ ./ckv ex/02.ckv
-- $ ./ckv ex/03.ckv ex/03a.ckv ex/03b.ckv
-- $ ./ckv ex/04.ckv
-- EXECUTABLE SUMMARY (run this file)
-- create audio generators in ckv!
-- OOP in Lua is kind of weird, but simple:
-- http://lua-users.org/wiki/ObjectOrientedProgramming
function Noise(gain)
return {
gain = gain or 1.0,
tick = function(self)
self.last = (math.random() * 2.0 - 1.0) * self.gain;
end
}
end
ev = Event:new();
function waiter(name)
while yield(ev) do
print("take that, " .. name .. string.rep("!", math.random(1, 10)))
end
end
-- fork(function, arg1, arg2, ...)
fork(waiter, "user");
-- fork an anonymous function
fork(function()
while yield(ev) do
local ugens = { "Noise()", "SinOsc()" };
local which = ugens[math.random(1, 2)];
-- fork_eval code in a string!
fork_eval("local n = " .. which .. ";"
.. "connect(n, speaker);"
.. "yield(second / 2);"
.. "disconnect(n, speaker);");
end
end)
global.nb = "to share between script files, put stuff in global!";
print(global.nb .. " and try \"ckv -h\" sometime!");
while true do
yield(math.random() * second * 4 + 1);
ev:broadcast();
end