File: rissetdrum.ny

package info (click to toggle)
audacity 2.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 44,240 kB
  • sloc: cpp: 182,841; ansic: 120,375; sh: 26,421; lisp: 7,495; makefile: 1,606; python: 240; xml: 104; perl: 31
file content (126 lines) | stat: -rw-r--r-- 2,329 bytes parent folder | download | duplicates (2)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
;nyquist plug-in

;version 3

;type generate

;categories "http://lv2plug.in/ns/lv2core#GeneratorPlugin"

;name "Risset Drum..."

;action "Generating Risset Drum..."

;info "Risset Drum generator by Steven Jones, after Jean Claude Risset\nReleased under terms of the GNU General Public License version 2\nProduces a realistic drum sound consisting of three components;\na sine wave ring-modulated by narrow band noise, an enharmonic\ntone, and a relatively strong sine wave at the fundamental"



;control frq "Frequency [Hz]" real "" 100 50 2000

;control decay "Decay [seconds]" real "" 2 0.125 10

;control cf "Center frequency of noise [Hz]" real "" 500 100 5000

;control bw "Width of noise band [Hz]" real "" 400 10 1000

;control noise "Amount of noise in mix [percent]" real "" 50 0 100



(if (not (boundp '*rdrum-wtabsize*))

    (progn

      (setq *rdrum-wtabsize*  2048)

      (setq *rdrum-wtab* 

     (list (sum

          (scale 1.00 (build-harmonic 10 *rdrum-wtabsize*))

          (scale 1.50 (build-harmonic 16 *rdrum-wtabsize*))

          (scale 2.00 (build-harmonic 22 *rdrum-wtabsize*))

          (scale 1.50 (build-harmonic 23 *rdrum-wtabsize*)))

             (hz-to-step 1) t))))





(defun log2 (n)

  (/ (log (float n))(log 2.0)))





(defun percussion (decay)

  (let* ((half-life (expt 2.0 (- (log2 decay) 3))))

    (exp-dec 0 half-life decay)))





(defun pink (dur cutoff)

  (lowpass6 (noise dur) cutoff))

  



(defun risset-drum (frq decay cf bw noise)

  (let* ((decay2 (* decay 0.50))

      (pitch1 (hz-to-step frq))

      (pitch2 (hz-to-step (* frq 0.10)))

      (noise-mix  (float (min (max (/ noise 100) 0) 1)))

      (tone-mix   (- 1 noise-mix)))

    (sum (mult 

       (sum (scale noise-mix 

               (mult (sine (hz-to-step cf) decay2)

                     (pink decay2 bw)))

            (scale (* tone-mix 0.17)

                      (osc pitch2 decay2 *rdrum-wtab*)))

       (percussion decay2))

      (mult (scale tone-mix (sine pitch1 decay))

               (percussion decay)))))

      



;; Generate signal and normalize.

;; ISSUE: Is there any way to normalize signal without 

;; generating it twice?

;;

(setf peakval (peak (risset-drum frq decay cf bw (/ noise 100))

ny:all))

(scale (/ 0.8 peakval)(risset-drum frq decay cf bw (/ noise 100)))