-
Notifications
You must be signed in to change notification settings - Fork 4
/
chimesdelay.ny
252 lines (111 loc) · 4.34 KB
/
chimesdelay.ny
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 2
;type process
;name "Chimes delay (V2)..."
;action "Applying chimes delay..."
;info "Chimes delay by David R. Sky\nThanks to Steven Jones for Nyquist help\nIf chimes note list is blank, list is made from low to high notes\nReleased under terms of the GNU Public License"
;control chimeslist "Chimes note list" string "" "-24 -12 -5 0 4 7 12 14 19"
;control minnote "Minimum note" int "semitones" -12 -48 48
;control maxnote "Maximum note" int "semitones" 24 -48 48
;control maxdelay "Maximum delay time" real "seconds" 10.0 0.5 120.0
;control minvol "Minimum volume" int "%" 50.0 0.0 100.0
;control count "Number of chime delays" int "number" 20 1 100
; Chimes Delay by David R. Sky, January 30, 2005
; Version 2 plug-in, works in Audacity 1.2.3 and later
; Released under terms of the GNU Public License
; http://www.opensource.org/licenses/gpl-license.php
;
; Thanks very much to Steven Jones -
; his 'Harmonic Noise' generator plug-in
; is the source of Nyquist code
; to handle string input note lists.
; Thanks too for range function from math.lsp.
;
; For mono audio:
; generates random delay times, random volumes, random pitch changes
; (chooses randomly from user-defined or generated note list).
; For stereo audio:
; includes above plus random panning
; (best that audio is first panned to center for stereo).
; If input string is empty,
; generate list based on min and max notes.
; taking audio sample already loaded into Audacity
(setq sample (if (arrayp s)
(vector (aref s 0) (aref s 1)) s))
; making sure min and max really are min and max
(setf lownote (min minnote maxnote))
(setf highnote (max minnote maxnote))
; code from Steven Jones
; verbatim from 'Harmonic Noise' generator plug-in
; convert input string to semitone-shift list
(defun eval-string-to-list (symname str)
(let ((form (strcat "(setq " symname " (list " str "))")))
(eval (read (make-string-input-stream form)))))
; evaluating chimes note list
(eval-string-to-list "notelist" chimeslist)
; range function by Steven Jones:
; used only when string note list is empty
(defun range (n start &optional (increment 1.0) (acc ()))
(if (plusp n)
(cons start (range (- n 1) (+ start increment) increment acc)) acc))
; if no chimes list, make list using lownote and highnote values
; (if length of notelist is 0,
; generate list using range function)
(setf n (+ 1 (- highnote lownote)))
(setf notelist (if (= (length notelist) 0)
(range n lownote) notelist))
; random number generator
(defun get-random (min max mult div)
(setf min (* min mult))
(setf max (* max mult))
(setf rnd (/ (+ min (random (truncate max))) div)))
; panning function
(defun pan4 (where s)
(vector (mult (aref s 0) (sum 1 (mult -1 where)))
(mult (aref s 1) where)))
; convert randomly-generated semitone step shift value
; to value for use by stretch-abs
(defun convert (shift)
(expt 2.0 (/ shift -12.0)))
; generating chime delays
; comments appear above the line they describe
(if (arrayp s)
; generate stereo Chimes Delay
(sim
; randomly change note of original audio
; but do not apply delay, volume or pan changes
(force-srate 44100 (stretch-abs
(convert (nth (random (length notelist)) notelist))
(vector (sound (aref sample 0)) (sound (aref sample 1)))))
(simrep (i count)
; random pan
(pan4 (get-random 0.0 1.0 51.0 50.0)
; random amplitude
(mult (get-random minvol 101 1.0 100.0)
; random note shift
(force-srate 44100 (stretch-abs
(convert (nth (random (length notelist)) notelist))
(vector
; random delay
(at-abs (get-random 0.0 maxdelay 1001.0 1000.0)
(sound (aref sample 0)))
(at-abs rnd
(sound (aref sample 1))))))))))
; end stereo Chimes Delay
; generate mono Chimes Delay
(sim
; randomly change note of original audio
; but do not apply delay or volume changes
(force-srate 44100 (stretch-abs
(convert (nth (random (length notelist)) notelist))
(sound sample)))
(simrep (i count)
; random delay
(at-abs (get-random 0.0 maxdelay 1001.0 1000.0)
; random note shift
(force-srate 44100 (stretch-abs
(convert (nth (random (length notelist)) notelist))
(sound
; random amplitude
(mult (get-random minvol 101 1.0 100.0) sample))))))))
; end mono chimes delay