-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcosc.go
36 lines (33 loc) · 904 Bytes
/
cosc.go
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
package sc
// COsc is a chorusing wavetable lookup oscillator.
// Produces sum of 2 signals at
// freq +- (beats / 2)
// Due to summing, the peak amplitude is twice that of the wavetable.
type COsc struct {
// BufNum the number of a buffer filled in wavetable format
BufNum Input
// Freq frequency in Hz
Freq Input
// Beats beat frequency in Hz
Beats Input
}
func (cosc *COsc) defaults() {
if cosc.Freq == nil {
cosc.Freq = C(440)
}
if cosc.Beats == nil {
cosc.Beats = C(0.5)
}
}
// Rate creates a new ugen at a specific rate.
// If rate is an unsupported value this method will cause
// a runtime panic.
// There will also be a runtime panic if BufNum is nil.
func (cosc COsc) Rate(rate int8) Input {
CheckRate(rate)
if cosc.BufNum == nil {
panic("COsc requires a buffer number")
}
(&cosc).defaults()
return NewInput("COsc", rate, 0, 1, cosc.BufNum, cosc.Freq, cosc.Beats)
}