File: generators.expr

package info (click to toggle)
python-pyo 1.0.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 23,692 kB
  • sloc: ansic: 137,415; python: 135,293; makefile: 390; cpp: 242; sh: 163
file content (35 lines) | stat: -rw-r--r-- 594 bytes parent folder | download | duplicates (6)
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
// Sine wave oscillator
// usage: (osc freq phase)
(define osc (
        sin (* twopi (~ $1 $2))
    )
)

// Triangular wave oscillator
// usage: (tri freq phase)
(define tri (
        (let #ph (~ $1 $2))
        (- (* (min #ph (- 1 #ph)) 4) 1)
    )
)

// Square wave oscillator
// usage: (square freq phase)
(define square (
        (- (* (< (~ $1 $2) 0.5) 2) 1)
    )
)

// Pulse-Width-Modulation oscillator
// usage: (pwm freq duty)
(define pwm (
        (- (* (< (~ $1) $2) 2) 1)
    )
)

// White noise generator
// usage: (noise gain)
(define noise (
        (randf (neg $1) $1)
    )
)