-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.dsp
79 lines (63 loc) · 1.96 KB
/
test.dsp
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
// Kommentar
declare name "mynewplug";
declare copyright "(c) Hans Höglund 2012";
util = environment {
filter = library("filter.lib");
music = library("music.lib");
math = library("math.lib");
};
smooth(c) = *(1-c) : +~*(c);
integrate(f) = +(f) ~ _;
integrateW(f,g) = (+(f) : g) ~ _;
samples = integrate(1)-1; // 0,1,2,3,...
/*samples = 1 : xloop(+);*/
time = float(samples) / float(util.math.SR);
testOsc
= select2(checkbox("Use table"),
sin1(freq),
sin2(freq)
)
: *(vol) : meter
with {
freqA = fmod(time*800,800) + 40;
freqV = hslider("freq [unit:Hz]", 0, 40, 4000, 1);
freq = select2(checkbox("Auto freq"), freqV, freqA);
vol = hslider("volume [unit:dB]", 0, -96, 0, 0.1) : util.music.db2linear : smooth(0.999) ;
meter = hbargraph("Output",-1,1);
rate = float(util.math.SR);
pi = util.math.PI;
tau = 2.0*pi;
// Stateful ramp
xramp(f) = integrateW( f : /(rate), \(x).(fmod(x,1)) )
;
// Pure ramp FIXME
ramp(f) = samples : *(int(f)) : %(int(rate)) : float : /(rate)
;
tableOsc(g,f) = rdtable(size,table,phase)
with {
size = 1 << 16;
phase = xramp(f) : *(size) : int;
table = float(samples)/size : g;
}
;
sin1(f) = xramp(f) : * (tau) : sin
;
sin2(f) = f : tableOsc ( *(tau) : sin )
;
saw1(f) = xramp(f) : * (2) : -(1)
;
saw2(f) = f : tableOsc ( *(2) : -(1) )
;
sq1(f) = xramp(f) : \(g).(select2(g < 0.5, -1, 1))
;
sq2(f) = f : tableOsc ( \(g).(select2(g < 0.5, -1, 1)) )
;
tri1(f) = saw1(f) : abs : *(2) : -(1)
;
tri2(f) = saw2(f) : abs : *(2) : -(1)
;
}
;
process
= testOsc
;