-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathfsinosc.go
More file actions
32 lines (29 loc) · 873 Bytes
/
fsinosc.go
File metadata and controls
32 lines (29 loc) · 873 Bytes
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
package sc
// FSinOsc is a very fast sine wave generator implemented using a
// ringing filter. This generates a much cleaner sine wave than a
// table lookup oscillator and is a lot faster. However, the
// amplitude of the wave will vary with frequency. Generally the
// amplitude will go down as you raise the frequency and go up
// as you lower the frequency.
type FSinOsc struct {
// Freq is frequency in Hz
Freq Input
// Phase is the initial phase offset
Phase Input
}
func (fso *FSinOsc) defaults() {
if fso.Freq == nil {
fso.Freq = C(440)
}
if fso.Phase == nil {
fso.Phase = C(0)
}
}
// Rate creates a new ugen at a specific rate.
// If rate is an unsupported value this method will cause
// a runtime panic.
func (fso FSinOsc) Rate(rate int8) Input {
CheckRate(rate)
(&fso).defaults()
return NewInput("FSinOsc", rate, 0, 1, fso.Freq, fso.Phase)
}