1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-04-25 15:34:10 +02:00

Locate and position the current Audacity source code, and clear a variety of old junk out of the way into junk-branches

This commit is contained in:
ra
2010-01-23 19:44:49 +00:00
commit e74978ba77
1011 changed files with 781704 additions and 0 deletions

107
plug-ins/SilenceMarker.ny Normal file
View File

@@ -0,0 +1,107 @@
;nyquist plug-in
;version 1
;type analyze
;categories "http://lv2plug.in/ns/lv2core#AnalyserPlugin"
;name "Silence Finder..."
;action "Finding silence..."
;info "Written by Alex S. Brown, PMP (http://www.alexsbrown.com) \nReleased under terms of the GNU General Public License version 2\nAdds point labels in areas of silence according to the specified\nlevel and duration of silence. If too many silences are detected,\nincrease the silence level and duration; if too few are detected,\nreduce the level and duration."
;control sil-lev "Treat audio below this level as silence [ -dB]" real "" 26 0 100
;control sil-dur "Minimum duration of silence [seconds]" real "" 1.0 0.1 5.0
;control labelbeforedur "Label placement [seconds before silence ends]" real "" 0.3 0.0 1.0
;Create a function to make the sum the two channels if they are stereo
(defun mono-s (s-in) (if (arrayp s-in) (snd-add (aref s-in 0) (aref s-in 1))
s-in))
;Create a function to reduce the sample rate and prepare the signal for
;analysis. RMS is good to monitor volume the way humans hear it, but is not
;available in Audacity. Used a peak-calculating function instead.
;NOTE: this is the place to add any processing to improve the quality of the
;signal. Noise filters could improve the quality of matches for noisy signals.
;PERFORMANCE vs. ACCURACY
;Reducing the samples per second should improve the performance and decrease
;the accuracy of the labels. Increasing the samples per second will do the
;opposite. The more samples checked, the longer it takes. The more samples
;checked, the more precisely the program can place the silence labels.
;my-srate-ratio determines the number of samples in my-s. Set the number after (snd-srate s)
;higher to increase the number of samples.
(defun my-s (s-in)
(setq my-srate-ratio (truncate (/ (snd-srate (mono-s s-in)) 100)))
(snd-avg (mono-s s-in) my-srate-ratio my-srate-ratio OP-PEAK)
)
;Set the silence threshold level (convert it to a linear form)
(setq thres (db-to-linear (* -1 sil-lev)))
;Store the sample rate of the sound
(setq s1-srate (snd-srate (my-s s)))
;Initialize the variable that will hold the length of the sound.
;Do not calculate it now with snd-length, because it would waste memory.
;We will calculate it later.
(setq s1-length 0)
;Initialize the silence counter and the labels variable
(setq sil-c 0)
(setq l NIL)
;Convert the silence duration in seconds to a length in samples
(setq sil-length (* sil-dur s1-srate))
;Define a function to add new items to the list of labels
(defun add-label (l-time l-text)
(setq l (cons (list l-time l-text) l))
)
;The main working part of the program, it counts
;the number of sequential samples with volume under
;the threshold. It adds to a list of markers ever time
;there is a longer period of silence than the silence
;duration amount.
;It runs through a loop, adding to the list of markers (l)
;each time it finds silence.
(let (s1) ;Define s1 as a local variable to allow efficient memory use
; Get the sample into s1, then free s to save memory
(setq s1 (my-s s))
(setq s nil)
;Capture the result of this "do" loop, because we need the sountd's legnth
;in samples.
(setq s1-length
;Keep repeating, incrementing the counter and getting another sample
;each time through the loop.
(do ((n 1 (+ n 1)) (v (snd-fetch s1) (setq v (snd-fetch s1))))
;Exit when we run out of samples (v is nil) and return the number of
;samples processed (n)
((not v) n)
;Start the execution part of the do loop
;if found silence, increment the silence counter
(if (< v thres) (setq sil-c (+ sil-c 1)))
;If this sample is NOT silent and the previous samples were silent
;then mark the passage.
(if (and (> v thres) (> sil-c sil-length))
;Mark the user-set number of seconds BEFORE this point to avoid clipping the start
;of the material.
(add-label (- (/ n s1-srate) labelbeforedur) "S")
)
;If this sample is NOT silent, then reset the silence counter
(if (> v thres)
(setq sil-c 0)
)
)
)
)
;Check for a long period of silence at the end
;of the sample. If so, then mark it.
(if (> sil-c sil-length)
;If found, add a label
;Label time is the time the silence began plus the silence duration target
;amount. We calculate the time the silence began as the end-time minus the
;final value of the silence counter
(add-label (+ (/ (- s1-length sil-c) s1-srate) sil-dur) "S")
)
;If no silence markers were found, return a message
(if (null l)
(setq l "No silences found. Try reducing the silence\nlevel and minimum silence duration.")
)
l

146
plug-ins/SoundFinder.ny Normal file
View File

@@ -0,0 +1,146 @@
;nyquist plug-in
;version 1
;type analyze
;categories "http://lv2plug.in/ns/lv2core#AnalyserPlugin"
;name "Sound Finder..."
;action "Finding sound..."
;info "Written by Jeremy R. Brown (http://www.jeremy-brown.com/) \nbased on the Silence Finder script by\nAlex S. Brown, PMP (http://www.alexsbrown.com) \n\Released under terms of the GNU General Public License version 2\nAdds region labels for areas of sound according to the specified level\nand duration of surrounding silence. If too many labels are produced,\nincrease the silence level and duration; if too few are produced,\nreduce the level and duration."
;control sil-lev "Treat audio below this level as silence [ -dB]" real "" 26 0 100
;control sil-dur "Minimum duration of silence between sounds [seconds]" real "" 1.0 0.1 5.0
;control labelbeforedur "Label starting point [seconds before sound starts]" real "" 0.1 0.0 1.0
;control labelafterdur "Label ending point [seconds after sound ends]" real "" 0.1 0.0 1.0
;control finallabel "Add a label at the end of the track? [No=0, Yes=1]" int "" 0 0 1
;30Dec09: couple of changes made to default control values by Gale Andrews
;Create a function to make the sum the two channels if they are stereo
(defun mono-s (s-in) (if (arrayp s-in) (snd-add (aref s-in 0) (aref s-in 1))
s-in))
;Create a function to reduce the sample rate and prepare the signal for
;analysis. RMS is good to monitor volume the way humans hear it, but is not
;available in Audacity. Used a peak-calculating function instead.
;NOTE: this is the place to add any processing to improve the quality of the
;signal. Noise filters could improve the quality of matches for noisy signals.
;PERFORMANCE vs. ACCURACY
;Reducing the samples per second should improve the performance and decrease
;the accuracy of the labels. Increasing the samples per second will do the
;opposite. The more samples checked, the longer it takes. The more samples
;checked, the more precisely the program can place the silence labels.
;my-srate-ratio determines the number of samples in my-s. Set the number after (snd-srate s)
;higher to increase the number of samples.
(defun my-s (s-in)
(setq my-srate-ratio (truncate (/ (snd-srate (mono-s s-in)) 100)))
(snd-avg (mono-s s-in) my-srate-ratio my-srate-ratio OP-PEAK)
)
;Set the silence threshold level (convert it to a linear form)
(setq thres (db-to-linear (* -1 sil-lev)))
;Store the sample rate of the sound
(setq s1-srate (snd-srate (my-s s)))
;Initialize the variable that will hold the length of the sound.
;Do not calculate it now with snd-length, because it would waste memory.
;We will calculate it later.
(setq s1-length 0)
;Initialize the silence counter
(setq sil-c 0)
;Initialize the labels variable
(setq l NIL)
;Convert the silence duration in seconds to a length in samples
(setq sil-length (* sil-dur s1-srate))
;Set the sound-start marker to -1, indicating no sound has been found yet
(setq sound-start -1)
(setq silence-start -1)
;Set the flag that says we are looking for the start of a sound (as opposed to the start of a silence)
(setq sound-search 1)
;Set the counter that counts sounds
(setq sound-count 0)
(setq label-string "")
;Define a function to add new items to the list of labels
(defun add-label (l-starttime l-endtime l-text)
(setq l (cons (list l-starttime l-endtime l-text) l))
)
;The main working part of the program, it counts
;the number of sequential samples with volume under
;the threshold. It adds to a list of markers every time
;there is a longer period of silence than the silence
;duration amount.
;It runs through a loop, adding to the list of markers (l)
;each time it finds silence.
(let (s1) ;Define s1 as a local variable to allow efficient memory use
; Get the sample into s1, then free s to save memory
(setq s1 (my-s s))
(setq s nil)
;Capture the result of this "do" loop, because we need the sound's length
;in samples.
(setq s1-length
;Keep repeating, incrementing the counter and getting another sample
;each time through the loop.
(do ((n 1 (+ n 1)) (v (snd-fetch s1) (setq v (snd-fetch s1))))
;Exit when we run out of samples (v is nil) and return the number of
;samples processed (n)
((not v) n)
;Start the execution part of the do loop
;if found silence, increment the silence counter; if silence-start is not already > -1, set the start of silence to the current sample number (n)
(if (< v thres)
(progn
(setq sil-c (+ sil-c 1))
(if (= silence-start -1) (setq silence-start n))
)
)
;if found sound, and sound-search is 1, mark the start of the sound and change sound-search to 0 (look for silence next)
(if (and (>= v thres) (= sound-search 1))
(progn
(setq sound-search 0)
(setq sound-start n)
(setq sound-count (1+ sound-count))
)
)
;if found silence, and silence-counter is long enough, and sound-search is 0, and sound-start is not -1, and silence-start is not -1, that indicates the end of a sound (for which we have already found the beginning), which we should now label
(if (and (< v thres) (= sound-search 0) (/= sound-start -1) (> sil-c sil-length) (/= silence-start -1))
(progn
(setq sound-search 1)
(setq sil-c 0)
;Create the label text
(setq label-string (strcat label-string (format nil "~A" sound-count)))
(add-label (- (/ sound-start s1-srate) labelbeforedur) (+ (/ silence-start s1-srate) labelafterdur) label-string)
(setq label-string "")
(setq silence-start -1)
)
)
;if found sound, reset the silence-counter and silence-start
(if (>= v thres)
(progn
(setq sil-c 0)
(setq silence-start -1)
)
)
)
)
)
;if we're still looking for the end of a sound at the end of the file, end the sound at the end of the file
(if (= sound-search 0)
(progn
(setq label-string (strcat label-string (format nil "~A" sound-count)))
(add-label (- (/ sound-start s1-srate) labelbeforedur) (/ s1-length s1-srate) label-string)
)
)
;If no sound markers were found, return a message
;Otherwise, if some sounds were found, also optionally place a label at the end of the file.
(if (null l)
(setq l "No sounds found. Try reducing the silence\nlevel and minimum silence duration.")
(if (= finallabel 1) (add-label (/ s1-length s1-srate) (/ s1-length s1-srate) "[End]"))
)
l

10
plug-ins/analyze.ny Normal file
View File

@@ -0,0 +1,10 @@
;nyquist plug-in
;version 1
;type analyze
;categories "http://lv2plug.in/ns/lv2core#AnalyserPlugin"
;name "Sample Analyze Nyquist Plug-in"
;action "Analyzing absolutely nothing..."
(list (list 0 "beginning") (list (local-to-global 1) "end"))
; arch-tag: b50ba32c-68a6-4b1e-a7de-78ecdc4d6eed

22
plug-ins/beat.ny Normal file
View File

@@ -0,0 +1,22 @@
;nyquist plug-in
;version 1
;type analyze
;categories "http://audacityteam.org/namespace#OnsetDetector"
;name "Beat Finder..."
;action "Finding beats..."
;info "Released under terms of the GNU General Public License version 2"
;control thresval "Threshold Percentage" int "" 65 5 100
(setf s1 (if (arrayp s) (snd-add (aref s 0) (aref s 1)) s))
(defun signal () (force-srate 1000 (lp (snd-follow (lp s1 50) 0.001 0.01 0.1 512) 10)))
(setq max (peak (signal) NY:ALL))
(setq thres (* (/ thresval 100.0) max))
(setq s2 (signal))
(do ((c 0.0) (l NIL) (p T) (v (snd-fetch s2))) ((not v) l)
(if (and p (> v thres)) (setq l (cons (list c "B") l)))
(setq p (< v thres))
(setq c (+ c 0.001))
(setq v (snd-fetch s2)))
; arch-tag: 2204686b-2dcc-4891-964a-2749ac30661b

317
plug-ins/clicktrack.ny Normal file
View File

@@ -0,0 +1,317 @@
;nyquist plug-in
;version 3
;type generate
;categories "http://lv2plug.in/ns/lv2core#GeneratorPlugin"
;name "Click Track..."
;action "Generating Click Track..."
;info "by Dominic Mazzoni, modified by David R. Sky\nReleased under terms of the GNU General Public License version 2\nFor help, select one of two help screens in 'Action choice' below."
;control action "Action choice" choice "Generate track, help screen 1, help screen 2" 0
;control tempo "Tempo [beats per minute]" int "30 - 300 beats/minute" 120 30 300
;control sig "Beats per measure [bar]" int "1 - 20 beats/measure" 4 1 20
;control measures "Number of measures [bars]" int "1 - 1000 bars" 16 1 1000
;control click-track-dur "Optional click track duration [minutes seconds]" string "Whole numbers only" ""
;control ticklen "Individual click duration [milliseconds]" int "1 - 100 ms" 10 1 100
;control offset "Start time offset [seconds]" real "0 - 30 seconds" 0 0 30
;control click-type "Click sound" choice "ping,noise,tick" 0
;control q "Noise click resonance - discernable pitch [q]" int "1 - 20" 1 1 20
;control high "MIDI pitch of strong click" int "18 - 116" 92 18 116
;control low "MIDI pitch of weak click" int "18 - 116" 80 18 116
; original clicktrack.ny by Dominic Mazzoni,
; modified by David R. Sky:
; string input verification added by Steve Daulton, 2009.
; added click pitch [user request] and sound types fields September 2007
; added optional total click track duration field [requested by Mike Mullins]
; June 2009
; added individual click duration field [requested by Quinto Milana]
; June 2009]
; original code kept 'as is'.
; now includes:
; choice between click sounds [ping {sinewave}, noise or tick],
; user-set MIDI pitch values for strong and weak clicks,
; resonance of noise clicks
; [higher resonance gives them more discernable pitch],
; time offset for start of click track,
; and error-checking code to generate error message
; for such things as negative value inputs
; Drip sound generator by Paul Beach,
; used with permission.
;
; Thanks very much to Gale Andrews, who gave extensive visual feedback
; and suggestions!
; view 1 of 2 help screens, or generate click track
(cond ; 'master' cond
((= action 1) ; display help screen 1
(format nil
"Click Track Generator help - screen 1 of 2
Generates a click track at the selected tempo, beats per\nmeasure, and either number of measures or track duration,\nusing selected click sound.
'Tempo': number of beats (clicks) per minute.
'Beats per measure (bar)': For example, 3/4 time means one\nstrong click then two others to form one bar, repeated\ndepending on 'number of measures' or 'click track duration'.
'Optional click track duration': If you enter a value into this\nfield, either [minutes seconds] (separated by a space), or\n[seconds], the generated click track will be at or slightly\nlonger than this duration: the end of the track is extended\ninto a whole measure if the entered duration does not\nproduce this. Use whole numbers only.
If you enter a value into this field, the 'number of measures'\nvalue will be ignored.
To generate click track or view help screen 2,\n restart Click Track and select from 'Action choice'.") ; end format
) ; end display help screen 1
((= action 2) ; display help screen 2
(format nil
"Click Track Generator help - screen 2 of 2
'Individual click duration': the duration of each individual\nclick, minimum of 1 millisecond (ms) to maximum of 100 ms.
'Start time offset': makes the click track start at a later\ntime than the very beginning (zero seconds), maximum\nof 30 seconds.
'Click sound': choose between ping, noise or tick sound\nfor clicks.
'Noise click resonance': the higher this value, the more\nclearly noise clicks have a tone.
'MIDI pitch of strong/weak click': MIDI values indicate\nwhat pitch to use. C-notes are:
24, 36, 48, 60 (middle C), 72, 84, 96, 108.\nC# (C-sharp) above middle C is 61.
To generate click track or view help screen 1,\n restart Click Track and select from 'Action choice'.") ; end format
) ; end display help screen 2
(t ; perform clicktrack.ny
(setf click-type (+ click-type 1))
; check function: returns 1 on error
; min and max are allowable min and max values for arg
(defun check (arg min max)
(if (and (>= arg min) (<= arg max))
0 1))
; function to convert a string into a list
(defun string-to-list (string)
(read (make-string-input-stream (format nil "(~a)" string))))
; convert minutes-seconds string to a list
; for example, "4 30" becomes (4 30)
(setf m-s (string-to-list click-track-dur))
; initialize blank error-msg
(setf error-msg "")
; input values error checks
; tempo
(setf error-msg (if
(= (check tempo 30 300) 0)
error-msg
(strcat error-msg (format nil
"Tempo ~a outside valid range 30 to 300 bpm
" tempo))))
; beats per measure
(setf error-msg (if
(= (check sig 1 20) 0)
error-msg
(strcat error-msg (format nil
"Beats per measure ~a outside valid range 1 to 20
" sig))))
; number of measures
(setf error-msg (if
(= (check measures 1 1000) 0)
error-msg
(strcat error-msg (format nil
"Number of measures ~a outside valid range 1 to 1000
" measures))))
; time start offset
(setf error-msg (if
(= (check offset 0 30) 0)
error-msg
(strcat error-msg (format nil
"Time offset ~a outside valid range 0 to 30 seconds
" offset))))
; q
(setf error-msg (if
(= (check q 1 20) 0)
error-msg
(strcat error-msg (format nil
"Filter quality q ~a outside valid range 1 to 20
" q))))
; high MIDI pitch
(setf error-msg (if
(= (check high 18 116) 0)
error-msg
(strcat error-msg (format nil
"High MIDI pitch ~a outside valid range 18 to 116
" high))))
; low MIDI pitch
(setf error-msg (if
(= (check low 18 116) 0)
error-msg
(strcat error-msg (format nil
"Low MIDI pitch ~a outside valid range 18 to 116
" low))))
; validate string
(if (not (null m-s)) ; don't test if not set
(if (= (length m-s) 1) ; if there is only one item
(setf error-msg (if
(integerp (first m-s)) ; first is number
error-msg
(strcat error-msg (format nil
"If used, 'Optional click track duration' must be
entered as either one number [seconds], or two
numbers [minutes seconds] separated by a space.
Use whole numbers only.
"))))
; else if there is more than one item
(setf error-msg (if (and
(<= (length m-s) 2) ; there are no more than 2 items and
(integerp (first m-s)) ; first is number
(integerp (second m-s))) ; second is number
error-msg
(strcat error-msg (format nil
"If used, 'Optional click track duration' must be
entered as either one number [seconds], or two
numbers [minutes seconds] separated by a space.
Use whole numbers only.
"))))))
; optional click track length
; one number entered
(if (and (integerp (first m-s))(= (length m-s) 1))
(setf error-msg (if
(= (check (first m-s) 0 3660) 0)
error-msg
(strcat error-msg (format nil
"~a seconds is outside valid range 0 to 3660"
(first m-s))))))
; two numbers entered
(if (and
(integerp (first m-s))
(integerp (second m-s))
(= (length m-s) 2))
(setf error-msg (if (and
(= (check (first m-s) 0 60) 0)
(= (check (second m-s) 0 59) 0))
error-msg
(strcat error-msg (format nil
"~a is outside valid range 0 to [60 59]"
m-s)))))
(cond
; if error-msg is not blank, give error msg
((> (length error-msg) 0)
(setf error-msg (strcat (format nil
"Error - \n\nYou have entered at least one invalid value:\n
") error-msg))) ; end error msg
; no error so generate click track
(t
; duration of 1 click, originally statically 0.01 s
(setf ticklen (* (max 1 (min 100 ticklen)) 0.001))
(setf beatlen (/ 60.0 tempo))
; function to generate drip sound clicks
; code by Paul Beach www.proviewlandscape.com/liss/
; stretch-abs function makes this sound more like 'tick' sounds
(defun drip (p) ; p is pitch in hz
(lp
(stretch 1
(mult (exp-dec 0 0.015 0.25)
( sim
(mult (hzosc (* 2.40483 p)) 0.5 )
(mult (hzosc (* 5.52008 p)) 0.25 )
(mult (hzosc (* 8.653 p)) 0.125 )
(mult (hzosc (* 11.8 p)) 0.0625 )
)
)
)
440))
; function used to normalize noise and tick clicks
; this function is necessary because filtering
; changes amplitude of filtered noise clicks
(defun normalize (sound)
(setf peak-level (peak sound ny:all))
(scale (/ 1.0 peak-level) sound))
; make one measure
(setf measure (stretch-abs ticklen (mult 0.75
; pwl is used to add fast [5ms] fade-in and fade-out of clicks
(pwl 0 0 0.005 1 0.995 1 1 0 1)
(cond
((= click-type 1) ; ping accented clicks
(osc high))
((= click-type 2) ; noise accented clicks
(normalize (lowpass2 (noise 1) (step-to-hz high) q)))
((= click-type 3) ; tick accented clicks
(normalize (drip (step-to-hz high)))) ))))
(dotimes (x (- sig 1))
(setf measure (sim measure
(at (* beatlen (+ x 1))
(stretch-abs ticklen (mult 0.5
; again, pwl adds 5ms fade-in and fade-out to clicks
(pwl 0 0 0.005 1 0.995 1 1 0 1)
(cond
((= click-type 1) ;ping tone unaccented clicks
(osc low))
((= click-type 2) ; noise unaccented clicks
(normalize (lowpass2 (noise 1) (step-to-hz low) q)))
((= click-type 3) ; tick unaccented clicks
(normalize (drip (step-to-hz low)))) )))))))
; make the measure exactly the right length
(setf measure (sim measure
(stretch-abs (* sig beatlen) (const 0.0))))
; convert click-track-dur to number of measures,
; otherwise use user's measures value
(setf measures (if (null m-s)
measures
(/
(if ;2
(= (length m-s) 1)
(first m-s) ; just seconds
(+ (* 60 (first m-s)) (second m-s) ; minutes and seconds
) ; end +
) ; end if2
(* sig beatlen)) ; end /
) ; end if
) ; end setf measures
; round up to next whole number of measures only if
; measures > (truncate measures)
(setf measures (if
(> measures (truncate measures))
(truncate (1+ measures))
(truncate measures)
)) ; end if, setf measures
; loop measure n [measures-1] times
(setf result measure)
(dotimes (x (- measures 1))
(setf result (seq result measure)))
; add time offset to result,
; if offset > 0 seconds
(setf result (if (= offset 0) result
(sim (s-rest offset) (at-abs offset (cue result)))))
; return [click track] result
result
) ; end t
) ; end cond
) ; end t perform clicktrack.ny
) ; end 'master' cond

129
plug-ins/clipfix.ny Normal file
View File

@@ -0,0 +1,129 @@
;nyquist plug-in
;version 1
;type process
;categories "http://audacityteam.org/namespace#NoiseRemoval"
;name "Clip Fix..."
;action "Reconstructing clips..."
;info "Designed and implemented by Benjamin Schwartz.\n\nClip Fix attempts to reconstruct clipped regions by interpolating the\nlost signal. Before use, reduce amplification by 10 dB to give room for\nthe reconstruction. 'Threshold' is how close to the maximum sample\nmagnitude any sample must be to be considered clipped. If processing\nis slow, select only a few seconds of clipped audio at a time."
;control thresh "Threshold of Clipping [%]" real "" 95 0 100
(setf largenumber 100000000) ;;Largest number of samples that can be imported
(setf blocksize 100000)
;;Clip Fix is a simple, stupid (but not blind) digital-clipping-corrector
;;The algorithm is fairly simple:
;;1. Find all clipped regions
;;2. Get the slope immediately on either side of the region
;;3. Do a cubic spline interpolation.
;;4. Go to next region
;;Coded from start (didn't know lisp (well, scheme, but not not lisp and certainly not
;;some XLISP 2.0 derivative)) to finish
;;(fully working, more or less) in one afternoon (and some evening).
;;Written by Benjamin Schwartz, MIT class of 2006, on May 25, 2004.
;;Explanatory text added by Gale Andrews, May 2008.
;;If you modify this code, please retain the original credit to Benjamin Schwartz.
(defun declip (sin) ;;Central function
(let* ((threshold (* (peak sin largenumber) thresh 0.01))
(s2 (snd-copy sin))
(samplerate (snd-srate s2))
(s2length (snd-length s2 largenumber)))
(seqrep (i (1+ (/ s2length blocksize)))
(let ((l (min blocksize (- s2length (* i blocksize)))))
;;(print (list i t0 l samplerate))
(snd-from-array 0 samplerate
(workhorse
;;(let () (print (list s2 (type-of s2) l (type-of l)))
(snd-fetch-array s2 l l)
;;)
threshold))))
;;(setf r (snd-fetch-array (snd-copy s) (snd-length s largenumber) 1)) ;;Create a sound array
;;(snd-from-array (snd-t0 s) (snd-srate s) (workhorse r threshold))
))
(defun workhorse (r threshold)
(setf n (length r)) ;; Record its length
(setf exithigh ()) ;;Times when the wavefrom left the allowed region
(setf returnhigh ()) ;;Times when it returned to the allowed region
(setf drange 4)
(let ((i drange) (max (- n drange))) ;;Leave room at ends for derivative processing
(while (< i max)
(if (>= (aref r i) threshold)
(if (< (aref r (- i 1)) threshold)
(setq exithigh (cons (- i 1) exithigh))) ;;We just crossed the threshold up
(if (>= (aref r (- i 1)) threshold)
(setq returnhigh (cons i returnhigh)))) ;;We just crossed the threshold down
(setq i (1+ i))))
(setq exithigh (reverse exithigh)) ;;List comes out backwards
(setq returnhigh (reverse returnhigh))
(if (>= (aref r (1- drange)) threshold) ;;If the audio begins in a clipped region, ignore
(setq returnhigh (cdr returnhigh))) ;the extra return from threshold
(setf exitlow ()) ;; Same as above, but for the bottom threshold
(setf returnlow ())
(setf threshlow (* -1 threshold)) ;;Assumes your digital range is zero-centered
(let ((i drange) (max (- n drange)))
(while (< i max)
(if (<= (aref r i) threshlow)
(if (> (aref r (- i 1)) threshlow)
(setq exitlow (cons (- i 1) exitlow)))
(if (<= (aref r (- i 1)) threshlow)
(setq returnlow (cons i returnlow))))
(setq i (1+ i))))
(setq exitlow (reverse exitlow))
(setq returnlow (reverse returnlow))
(if (<= (aref r (1- drange)) threshlow)
(setq returnlow (cdr returnlow)))
(while (and exithigh returnhigh) ;;If there are more clipped regions
(let* ((t1 (car exithigh)) ;;exit time
(t2 (car returnhigh)) ;;return time
(d1 (max 0 (/ (- (aref r t1) (aref r (- t1 (1- drange)))) (1- drange)))) ;;slope at exit
(d2 (min 0 (/ (- (aref r (+ t2 (1- drange))) (aref r t2)) (1- drange)))) ;;slope at return
(m (/ (+ d2 d1) (* (- t2 t1) (- t2 t1)))) ;;interpolation is by (t-t1)(t-t2)(mx+b)
(b (- (/ d2 (- t2 t1)) (* m t2))) ;;These values of m and b make the cubic seamless
(j (1+ t1))) ;; j is the index
(while (< j t2)
(setf (aref r j) (+ (aref r t1) (* (- j t1) (- j t2) (+ (* m j) b))))
(setf (aref r j) (+ (* (- t2 j) (/ (aref r t1) (- t2 t1))) (* (- j t1) (/ (aref r t2) (- t2 t1))) (* (- j t1) (- j t2) (+ (* m j) b))))
(setq j (1+ j))))
(setq exithigh (cdr exithigh))
(setq returnhigh (cdr returnhigh)))
(while (and exitlow returnlow) ;;Same for bottom
(let* ((t1 (car exitlow))
(t2 (car returnlow))
(d1 (min 0 (/ (- (aref r t1) (aref r (- t1 (1- drange)))) (1- drange)))) ;;slope at exit
(d2 (max 0 (/ (- (aref r (+ t2 (1- drange))) (aref r t2)) (1- drange)))) ;;slope at return
(m (/ (+ d2 d1) (* (- t2 t1) (- t2 t1))))
(b (- (/ d2 (- t2 t1)) (* m t2)))
(a (/ (+ (aref r t1) (aref r t2)) 2))
(j (1+ t1)))
(while (< j t2)
(setf (aref r j) (+ (* (- t2 j) (/ (aref r t1) (- t2 t1))) (* (- j t1) (/ (aref r t2) (- t2 t1))) (* (- j t1) (- j t2) (+ (* m j) b))))
(setq j (1+ j))))
(setq exitlow (cdr exitlow))
(setq returnlow (cdr returnlow)))
r)
(if (arrayp s)
(dotimes (j (length s))
(setf (aref s j) (declip (aref s j))))
(setq s (declip s)))
s

7
plug-ins/crossfadein.ny Normal file
View File

@@ -0,0 +1,7 @@
;nyquist plug-in
;version 2
;type process
;categories "http://lv2plug.in/ns/lv2core#MixerPlugin"
;name "Cross Fade In"
;action "Cross-Fading In..."
(mult s (snd-exp (snd-scale 0.5 (snd-log (ramp)))))

9
plug-ins/crossfadeout.ny Normal file
View File

@@ -0,0 +1,9 @@
;nyquist plug-in
;version 2
;type process
;categories "http://lv2plug.in/ns/lv2core#MixerPlugin"
;name "Cross Fade Out"
;action "Cross-Fading Out..."
(mult s (snd-exp
(snd-scale 0.5 (snd-log
(sum 1 (snd-scale -1 (ramp)))))))

132
plug-ins/delay.ny Normal file
View File

@@ -0,0 +1,132 @@
;nyquist plug-in
;version 3
;type process
;categories "http://lv2plug.in/ns/lv2core#DelayPlugin"
;name "Delay..."
;action "Performing Delay Effect..."
;info "by Roger Dannenberg, modified by David R. Sky\nReleased under terms of the GNU General Public License Version 2 \nDelay type: 'bouncing ball' makes the echoes occur increasingly close\ntogether (faster); 'reverse bouncing ball' makes them occur increasingly far\napart (slower). In either bouncing ball effect, delay time is not time between\nechoes but the * maximum * delay time in bounces.\nApplying delay can cause clipping (distortion), especially when reducing the\ndecay value and using more echoes. It's normally best to use Effect > Amplify\nto set the peak amplitude to -6 dB before using delay.
;control delay-type "Delay type" choice "regular,bouncing ball,reverse bouncing ball" 0
;control decay "Decay amount [dB; negative value increases volume]" real "" 6 -1 24
;control delay "Delay time [seconds]" real "" 0.5 0 5
;control shift "Pitch change per echo [semitones; negative value = lower, 0 is off]" real "" 0 -2 2
;control count "Number of echoes" int "" 5 1 30
; Delay by Roger B. Dannenberg
; modified by David R. Sky October 2007,
; adding negative decay values, which gives delay effect
; increasing volume with each delay; and adding
; bouncing ball and reverse bouncing ball delay effects
; and pitch [semitone] change with each echo.
; modified by Richard Ash January 2008, removing all
; normalization functions.
; Note by Roger Dannenberg: this effect will use up memory proportional to
; delay * count, since that many samples must be buffered
; before the first block is freed.
; initialize empty error message
(setf error-msg "")
; check function: returns 1 on error
(defun check (arg min max)
(if (and (>= arg min) (<= arg max))
0 1))
; checking for erroneous user-input values:
(setf error-msg (if (= (check decay -1 24) 0)
error-msg
(strcat error-msg
(format nil "Decay value '~a' outside valid range -1.0 to 24.0 dB.
" decay))))
(setf error-msg (if (= (check delay 0 5) 0)
error-msg
(strcat error-msg
(format nil "Delay value '~a' outside valid range 0.0 to 5.0 seconds.
" delay))))
(setf error-msg (if (= (check shift -2 2) 0)
error-msg
(strcat error-msg
(format nil "Pitch change value '~a' outside valid range -2.0 to 2.0 semitones.
" shift))))
(setf error-msg (if (= (check count 1 30) 0)
error-msg
(strcat error-msg
(format nil "Number of echoes '~a' outside valid range 1 to 30 echoes.
" count))))
; finished error-checking
; if error-msg is longer than 0 characters,
; prepend opening message
(setf error-msg (if (> (length error-msg) 0)
(strcat "Error -\n\nYou have input at least one invalid value:
" error-msg)
error-msg))
(cond ; 1
((> (length error-msg) 0)
(format nil "~a" error-msg))
(t ; no input errors, perform delay
; convert shift value to a value the Nyquist code understands
(setf shift (expt 0.5 (/ shift 12.0)))
; for bouncing ball effects, set delay time to delay time/count
(setf delay (if (> delay-type 0)
(/ delay count) delay))
; function to stretch audio
(defun change (sound shift)
(if (arrayp sound)
(vector
(force-srate 44100 (stretch-abs shift (sound (aref sound 0))))
(force-srate 44100 (stretch-abs shift (sound (aref sound 1)))))
(force-srate 44100 (stretch-abs shift (sound sound)))))
(cond ; 2
((= delay-type 0) ; regular delay
; delay function
(defun delays (s decay delay count shift)
(if (= count 0) (cue s)
(sim (cue s)
(loud decay (at delay (delays (change s shift)
decay delay (- count 1) shift))))))
(stretch-abs 1 (delays s (- 0 decay) delay count shift)))
((= delay-type 1) ; bouncing ball delay
; bouncing ball delay function
(defun bounces (s decay delay count shift)
(if (= count 0) (cue s)
(sim (cue s)
(loud decay (at (mult delay count)
(bounces (change s shift) decay delay
(- count 1) shift))))))
(stretch-abs 1 (bounces s (- 0 decay) delay count shift)))
((= delay-type 2) ; reverse bouncing ball delay
; reverse bouncing ball delay function
(defun revbounces (s decay delay count revcount shift)
(if (= count 0) (cue s)
(sim (cue s)
(loud decay (at (mult delay (- revcount count))
(revbounces (change s shift) decay delay
(- count 1 ) revcount shift))))))
(setf revcount (1+ count))
(stretch-abs 1 (revbounces s (- 0 decay) delay count revcount shift)))
) ; end cond2, different delay effect choices
) ; end cond1 t
) ; end cond 1

142
plug-ins/equalabel.ny Normal file
View File

@@ -0,0 +1,142 @@
;nyquist plug-in
;version 3
;type analyze
;categories "http://audacityteam.org/namespace#TimeAnalyser"
;name "Regular Interval Labels..."
;action "Adding equally-spaced labels to the label track..."
;info "equalabel.ny by David R. Sky www.shellworld.net/~davidsky/ \nReleased under terms of the GNU General Public License version 2\nCreate equally spaced labels by choosing the number of labels or the interval\nbetween them. Making your final audio segment equal with others may slightly\nchange the label interval that you had set.\nNote: Equalabel.ny does not overwrite an existing label track, but adds to it.\nCode for label placement based on silencemarker.ny by Alex S.Brown."
;control start "Time to place first label [seconds]" string " " "0.0"
;control placement "Label placement method" choice "Label interval,Number of labels" 0
;control time "Set either: Label interval [seconds]" string " " "60.0"
;control label-number "Or: Number of labels" int "" 10 2 100
;control text "Label text" string "" "Label"
;control prepend "Prepend numbers to label text?" choice "No - just use text,Yes" 1
;control include "Include final label?" choice "No,Yes" 0
;control t-choice "Final audio segment equal with others?" choice "No,Yes" 1
; Regular interval labels by David R. Sky, June-October 2007.
; Released under terms of the GNU General Public License version 2
; http://www.gnu.org/copyleft/gpl.html
; Thanks Sami Jumppanen for plug-in suggestion.
; Thanks Alex S. Brown for code showing how to place labels.
; Thanks Dominic Mazzoni, Pierre M.I., Gale Andrews
; for improvement suggestions.
; function to convert string to list
(defun string-to-list (str)
(read (make-string-input-stream (format nil "(~a)" str))))
; convert start string to a number
(setf start (first (string-to-list start)))
; convert time string to a number
(setf time (first (string-to-list time)))
; get selection duration in seconds,
; then subtract start offset
(setf dur (- (/ len *sound-srate*) start))
; give an error message
; if user-set label interval is greater than selection duration,
; taking into accound start time offset
(cond ; outermost cond
((and (> time dur) (= placement 0))
(format nil
"Including your time offset of ~a seconds, your requested~%label interval of ~a seconds is greater than the duration~%of your selected audio (~a seconds). ~%
Please run this plug-in again using a smaller label interval. ~%"
start time dur))
(t ; label interval time is equal to or less than selection duration
; choose between user-selected label interval or number of labels
(cond
((= placement 1) ; number of labels
(setf time (if (= include 0)
(float (/ dur label-number)) (1+ (float (/ dur label-number)))))
(setf labels (if (= include 0) label-number (1+ label-number)))
) ; end placement 1
(t ; user-selected time interval
; calculate number of labels in selection
; this includes label at start of selection
; which is label number 0 if numbers are prepended to label text
; if final label is unwanted, decrement number of labels by 1
(setf labels (if (= include 0)
(truncate (/ dur time))
(+ 1 (truncate (/ dur time)))
) ; end if
) ; end setf labels
; setf check-labels: number of labels if user includes last label
; this is for checking purposes in the [setf time ...] section of code
(setf check-labels (+ 1 (truncate (/ dur time))))
; function to calculate new time value
; if user value does not create equal duration final audio chunk
; returns new time value
(defun new-time (time dur check-labels)
; calculate duration of last audio chunk
(setf last-label (- dur (* time check-labels)))
(if (< last-label (* time 0.5)) ; last chunk is less than 1/2 time
(/ dur (- check-labels 1))
(/ dur check-labels)
) ; end if
) ; end defun new-time
(setf time ; depending whether user wants specified time used
; or wants equal duration audio chunks including last chunk
; user time may create equal audio chunks even for last chunk
(cond ; 1
((= t-choice 0) time) ; use user time value...
(t ; ...otherwise calculate time for equal duration audio chunks
(cond ; 2
; if user time value creates equal final audio segment duration anyway
; then use user interval
((= dur (* time (- check-labels 1))) time)
; user time value does not create equal duration audio chunks
(t
(new-time time dur check-labels)
) ; end t
) ; end cond 2
) ; end of calculation for equal duration audio chunks
) ; end cond1
) ; end setf time
) ; end t
) ; end cond choosing between user-set label interval or number of labels
; function to add labels to the label track
; from silencemarker.ny by Alex S. Brown
(defun add-label (l-time l-text)
(setq l (cons (list l-time l-text) l)))
; function to prepend label number before label text
(defun prepend-number (i text)
(format nil "~a~a" i text))
; initialize blank label track
(setq l nil)
; add the labels
(dotimes (i labels)
(if (= prepend 1) ; prepend numbers to label text?
(add-label (+ start (* i time)) (prepend-number i text)) ; yes
(add-label (+ start (* i time)) text) ; no
) ; end if
) ; end dotimes i
; return label track
l
) ; close t of outermost cond
) ; end outermost cond

95
plug-ins/highpass.ny Normal file
View File

@@ -0,0 +1,95 @@
;nyquist plug-in
;version 3
;type process
;categories "http://lv2plug.in/ns/lv2core#HighpassPlugin"
;name "High Pass Filter..."
;action "Performing High Pass Filter..."
;info "by Dominic Mazzoni, modified by David R. Sky\nReleased under terms of the GNU General Public License Version 2\nAttenuates frequencies below your specified cutoff frequency.\nHigher rolloff values give a sharper attenuation of frequencies below\nthe cutoff frequency. If using a rolloff of 12 dB, a [q] value greater than\ndefault 0.7 increases resonance ['ringing'] of the cutoff frequency and\ncould result in clipping."
;control rolloff-choice " Rolloff [dB per octave]" choice " 6 dB,12 dB,24 dB,36 dB,48 dB" 0
;control q " Filter quality [q] for 12 dB rolloff" real "" 0.7071 .1 20
;control f " Cutoff frequency [Hz]" real "" 1000 1 20000
; note that all Nyquist highpass functions
; [hp, highpass2, highpass4, highpass6, highpass8]
; are defined below with -s suffix.
; This enables highpass functions other than hp
; to deal with stereo selection,
; and dummy q arg for all but highpass2
; 6dB/octave
(defun hp-s (s f q) ; dummy q arg
(hp s f))
; 12dB/octave
(defun highpass2-s (s f q)
(if (arrayp s)
(vector (highpass2 (aref s 0) f q)
(highpass2 (aref s 1) f q))
(highpass2 s f q)))
; 24dB/octave
(defun highpass4-s (s f q) ; dummy q arg
(if (arrayp s)
(vector (highpass4 (aref s 0) f)
(highpass4 (aref s 1) f))
(highpass4 s f)))
; 36dB/octave
(defun highpass6-s (s f q) ; dummy q arg
(if (arrayp s)
(vector (highpass6 (aref s 0) f)
(highpass6 (aref s 1) f))
(highpass6 s f)))
; 48dB/octave
(defun highpass8-s (s f q) ; dummy q arg
(if (arrayp s)
(vector (highpass8 (aref s 0) f)
(highpass8 (aref s 1) f))
(highpass8 s f)))
; check function: returns 1 on error
(defun check (arg min max)
(if (and (>= arg min) (<= arg max))
0 1))
; initialize blank error-msg
(setf error-msg "")
; check for erroneous q value
(setf error-msg (if
(and (= rolloff-choice 1)
(= (check q 0.1 20) 1))
(strcat error-msg (format nil
"q value ~a lies outside valid range 0.1 to 20
for your chosen rolloff of 12 dB per octave.
" q))
error-msg))
; check for erroneous frequency cutoff value
(setf error-msg (if
(= (check f 1 20000) 0)
error-msg
(strcat error-msg (format nil
"Cutoff frequency ~a Hz lies outside valid range 1 to 20000.
" f))))
(cond
((> (length error-msg) 0)
(setf error-msg (strcat (format nil
"Error - \n\nYou have entered at least one invalid value:
") error-msg))
(format nil "~a" error-msg))
;
(t ; perform highpass effect
(funcall (nth rolloff-choice '(hp-s highpass2-s highpass4-s highpass6-s highpass8-s))
s f q)))
; from previous commit
; arch-tag: 49302eba-9945-43d7-aade-f1c7eded27af

93
plug-ins/lowpass.ny Normal file
View File

@@ -0,0 +1,93 @@
;nyquist plug-in
;version 3
;type process
;categories "http://lv2plug.in/ns/lv2core#LowpassPlugin"
;name "Low Pass Filter..."
;action "Performing Low Pass Filter..."
;info "by Dominic Mazzoni, modified by David R. Sky\nReleased under terms of the GNU General Public License Version 2\nAttenuates high frequencies above your specified cutoff frequency.\nHigher rolloff values give a sharper attenuation of frequencies above\nthe cutoff frequency. If using a rolloff of 12 dB, a [q] value greater than\ndefault 0.7 increases resonance ['ringing'] of the cutoff frequency and\ncould result in clipping.""
;control rolloff-choice " Rolloff [dB per octave]" choice " 6 dB,12 dB,24 dB,36 dB,48 dB" 0
;control q " Filter quality [q] for 12 dB rolloff" real "" 0.7071 .1 20
;control f " Cutoff frequency [Hz]" real "" 1000 1 20000
; note that all Nyquist lowpass functions
; [lp, lowpass2, lowpass4, lowpass6, lowpass8]
; are defined below with -s suffix.
; This enables lowpass functions other than lp
; to deal with stereo selection,
; and dummy q arg for all but lowpass2
; 6dB/octave
(defun lp-s (s f q) ; dummy q arg
(lp s f))
; 12dB/octave
(defun lowpass2-s (s f q)
(if (arrayp s)
(vector (lowpass2 (aref s 0) f q)
(lowpass2 (aref s 1) f q))
(lowpass2 s f q)))
; 24dB/octave
(defun lowpass4-s (s f q) ; dummy q arg
(if (arrayp s)
(vector (lowpass4 (aref s 0) f)
(lowpass4 (aref s 1) f))
(lowpass4 s f)))
; 36dB/octave
(defun lowpass6-s (s f q) ; dummy q arg
(if (arrayp s)
(vector (lowpass6 (aref s 0) f)
(lowpass6 (aref s 1) f))
(lowpass6 s f)))
; 48dB/octave
(defun lowpass8-s (s f q) ; dummy q arg
(if (arrayp s)
(vector (lowpass8 (aref s 0) f)
(lowpass8 (aref s 1) f))
(lowpass8 s f)))
; check function: returns 1 on error
(defun check (arg min max)
(if (and (>= arg min) (<= arg max))
0 1))
; initialize blank error-msg
(setf error-msg "")
; check for erroneous q value
(setf error-msg (if
(and (= rolloff-choice 1)
(= (check q 0.1 20) 1))
(strcat error-msg (format nil
"q value ~a lies outside valid range 0.1 to 20
for your chosen rolloff of 12 dB per octave.
" q))
error-msg))
; check for erroneous frequency cutoff value
(setf error-msg (if
(= (check f 1 20000) 0)
error-msg
(strcat error-msg (format nil
"Cutoff frequency ~a Hz lies outside valid range 1 to 20000.
" f))))
(cond
((> (length error-msg) 0)
(setf error-msg (strcat (format nil
"Error - \n\nYou have entered at least one invalid value:
") error-msg))
(format nil "~a" error-msg))
;
(t ; perform lowpass effect
(funcall (nth rolloff-choice '(lp-s lowpass2-s lowpass4-s lowpass6-s lowpass8-s))
s f q)))
; from previous commit
; arch-tag: c2d96e46-b4e2-47c0-9a19-761011418e02

34
plug-ins/pluck.ny Normal file
View File

@@ -0,0 +1,34 @@
;nyquist plug-in
;version 3
;type generate
;categories "http://lv2plug.in/ns/lv2core#GeneratorPlugin"
;name "Pluck..."
;action "Generating pluck sound..."
;info "modified by David R. Sky\nReleased under terms of the GNU General Public License version 2 \nMIDI values for C notes: 36, 48, 60 [middle C], 72, 84, 96."
;control p "Pluck MIDI pitch" int "" 60 1 127
;control fade "Fade-out type" choice "abrupt,gradual" 0
;control dur "Duration [seconds]" real "" 1 0.1 30
; original pluck.ny modified by David R.Sky October 2007
; [vastly simplified later]
; to give user option to use [default] abrupt or gradual fade-out,
; and ability to make pluck sound up to 30 seconds in duration.
; Modified January 2007 to use 'snd-pluck' by edgar-rft@web.de
; instead of the Nyquist 'pluck' function, and normalise to 0.8
; maximum amplitude. As defined in Audacity, 'pluck' has
; incorrect length duration and clipping at the start which gives
; rise to DC offset. Using 'snd-pluck' avoids the clipping and
; offset so we don't need the highpass8 filter that we used before.
; set final-amp for abrupt or gradual fade
(setf final-amp (if (= fade 1) 0.001 0.000001))
(let* ((pluck-sound (snd-pluck *sound-srate* (step-to-hz p) 0 dur final-amp))
(max-peak (peak pluck-sound ny:all)))
(scale (/ 0.8 max-peak) pluck-sound))
;arch-tag: bebc6cb8-3bb0-42d5-a467-df6bd1a7f1e4

126
plug-ins/rissetdrum.ny Normal file
View File

@@ -0,0 +1,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)))

41
plug-ins/tremolo.ny Normal file
View File

@@ -0,0 +1,41 @@
;nyquist plug-in
;version 3
;type process
;categories "http://lv2plug.in/ns/lv2core#ModulatorPlugin"
;name "Tremolo..."
;action "Applying Tremolo..."
;info "by Dominic Mazzoni, modified by David R. Sky\nReleased under terms of the GNU General Public License Version 2\n'Starting phase' sets where to start tremolo in the waveform cycle.\n'Wetness level' sets depth of tremolo - 0 percent is no tremolo,\n100 percent sweeps between zero and maximum volume.\n'Frequency' controls the speed of the oscillation - use higher\nfrequencies for faster oscillation."
;control wave "Waveform type" choice "sine,triangle,sawtooth,inverse sawtooth,square" 0
;control phase " Starting phase [degrees]" int "" 0 -180 180
;control amount " Wetness level [percent]" int "" 40 0 100
;control lfo " Frequency [Hz]" real "" 4.0 0.1 10.0
; set tremolo *waveform*
(setq *waveform* (cond
((= wave 0) ; sine
*sine-table*)
((= wave 1) ; triangle
*tri-table*)
((= wave 2) ; sawtooth
(abs-env (list (pwl 0 -1 .995 1 1 -1 1) (hz-to-step 1.0) t)))
((= wave 3) ; inverse sawtooth
(abs-env (list (pwl 0 1 .995 -1 1 1 1) (hz-to-step 1.0) t)))
(t ; square
(abs-env (list (pwl 0 1 .495 1 .5 -1 .995 -1 1 1 1) (hz-to-step 1.0) t)))))
; check for negative [invalid] frequency value
(cond ((<= lfo 0)
(format nil
"Error\n\nYou have entered an invalid frequency of ~a Hz.
Please enter a frequency above 0 Hz." lfo))
;
(t
; apply tremolo
(mult (sum (const (- 1.0 (/ amount 200.0))) (scale (/ amount 200.0)
(osc (hz-to-step lfo) 1.0 *waveform* phase))) s)))
; from previous commit
; arch-tag: 0ee3925a-8016-44db-91e8-8c4b7a9f3992

106
plug-ins/vocalremover.ny Normal file
View File

@@ -0,0 +1,106 @@
;nyquist plug-in
;version 3
;type process
;categories "http://lv2plug.in/ns/lv2core#UtilityPlugin"
;name "Vocal Remover (for center-panned vocals)..."
;action "Removing vocals or other center-panned audio..."
;info "by David R. Sky www.shellworld.net/~davidsky/ \nReleased under terms of the GNU General Public License version 2 \nRemoves center-panned audio in a stereo track by inversion and panning to center.\n\n'Simple' removal removes all the center-panned audio. If too much audio is removed,\ntry removing only selected frequencies - enter these in the box 'Frequency band\nlower and upper limit'. Then choose 'Remove band' to remove only frequencies in\nthat band, or 'Retain band' to remove only frequencies outside that band. After\nremoval, the audio will sound mono because both channels are panned to center.\n\nFor further help, select 'View Help' in the first dropdown menu and click OK. After\nreading Help, please reopen Vocal Remover to use it.\n"
;control action "Remove vocals or view Help" choice "Remove vocals,View Help" 0
;control bc "Removal choice" choice "Simple (entire spectrum),Remove frequency band,Retain frequency band" 0
;control range "Frequency band lower and upper limit [Hz]\n [Enter two values between 0 and 20000]" string " " "500 2000"
; Center pan Remover by David R. Sky November 12, 2004
; updated October/November 2007. Further modified by
; Gale Andrews January 2008 to make full spectrum removal
; the default, restore a single Help screen and restore error checking.
; Ideally wants rewriting so that no error checking occurs when
; default full spectrum removal selected.
; Thanks to David Hostetler for notes in his own vocal remover plug-in,
; which makes this plug-in more effective. See -
; http://www.freelists.org/archives/audacity4blind/06-2006/msg00049.html
(cond ; either explain this effect or perform it
((= action 1) ; display Help screen
(format nil
"Vocal Remover requires a stereo track and works best on audio in a lossless format\nlike WAV or AIFF rather than a compressed, lossy format like MP3. If your song is on\na CD, use a program like CD-ex to rip it to WAV or AIFF before using Vocal Remover.
Vocals (or other audio) can only be removed with this plug-in when panned to center,\nin other words sounding equally loud in both left and right channels. Vocals are often\nrecorded this way. When one channel is inverted and then both panned to center,\nany audio which is identical in both channels is cancelled out, so becomes inaudible.\nThis means that if audio you don't want to remove also happens to be center-panned,\nit will be cancelled out along with the vocals. Drums are an example of audio that is\noften center-panned and can thus disappear when vocals are removed. However, if\nthe vocals and other center-panned parts of the audio differ from each other in pitch\n(and thus in frequency), removing only selected frequencies from the audio can solve\nsuch problems.
Vocal Remover therefore has three choices of removal method. 'Simple' inverts the\nentire frequency spectrum of one channel. If all the audio except the vocals is panned\nhard away from center, this will work the best. If some of the other audio is common\nto both channels, this choice may remove too much music, in which case try the\nremaining options. 'Remove frequency band' removes frequencies in a band whose\nupper and lower limit you specify in the 'Frequency band...' box. Try this choice,\nentering the approxmate frequency range of the vocals, if they are apparently at a\nvery different pitch than the other audio (for example, a high female voice). 'Retain\nfrequency band' removes only those frequencies lying outside the limit you specify,\nretaining the others. This choice can help if there is audio of a particular frequency\nrange (such as low drums or bass) that is lost when using the other methods. Simply\nenter the approximate frequency range of the audio you wish to retain."))
(t ; perform effect
(defun string-to-list (str)
(read (make-string-input-stream (format nil "(~a)" str))))
(setf range (string-to-list range))
; initialize empty error-msg
(setf error-msg "")
; Error-checking...
;
; check that selected audio is stereo
(setf error-msg (if (arrayp s)
error-msg
(strcat error-msg (format nil
"Error:\n\nVocal Remover requires an unsplit, stereo track.\n\nIf you have a stereo track split into left and right\nchannels, use 'Make Stereo Track' on the Track\nDropdown Menu, then run Vocal Remover again.
"))))
; Check there are two input frequency values given. If not and remove or retain band is selected,
; ask to enter their required values. If not and 'Simple' removal selected, ask to enter any two values.
(setf error-msg (if
(and (> bc 0)
(< (length range) 2))
(strcat error-msg (format nil
"Error:\n\nPlease enter both a lower and upper value for the\nfrequency band you want to remove or retain.\n\nBoth values must be between 0 and 20000.
" (nth bc '("" ""))))
; are range values numbers?
(if
(or (not (numberp (first range))) (not (numberp (second range))))
(strcat error-msg (format nil
"To perform 'Simple' removal you can enter any\ntwo numbers (separated by a space) in the\n'Frequency band lower and upper limit' box.\nThe numbers entered don't affect the result.\n\nTo remove or retain a frequency band, enter\nlower and upper values for the band between\n0 and 20000.
" (first range) (second range)))
; if 'Simple' removal not selected, throw error if both frequency values are not between 0 and 20000
(if (or (= bc 0)
(and
(>= (first range) 0) (<= (first range) 20000)
(>= (second range) 0) (<= (second range) 20000)))
error-msg
(strcat error-msg (format nil
"Error:\n\n~aAt least one frequency value in your band is invalid. \nYou entered: ~a ~a\n\nBoth the lower and upper values must be between\n0 and 20000.
"(nth bc '("" "" ""))
(first range) (second range)))))))
(cond
((> (length error-msg) 0)
(format nil "~a" error-msg))
(t ; no error msg
(setf lower (min (first range) (second range)))
(setf upper (max (first range) (second range)))
(cond
((= bc 1) ; invert [delete] band of frequencies inside range
(sum (aref s 0) (mult -1 (aref s 1))
(highpass8 (aref s 1) upper)
(lowpass8 (aref s 1) lower)))
((= bc 2) ; invert [delete] frequencies outside band range
(sum (aref s 0) (mult -1 (aref s 1))
(highpass8 (lowpass8 (aref s 1) upper) lower)))
(t ; invert one channel
(sum (aref s 0) (mult -1 (aref s 1)))))
) ; end t apply effect
) ; end cond between display error msg or apply effect
) ; end t perform effect
) ; end cond explain effect or perform it

114
plug-ins/vocoder.ny Normal file
View File

@@ -0,0 +1,114 @@
;nyquist plug-in
;version 3
;type process
;categories "http://lv2plug.in/ns/lv2core#SpectralPlugin"
;name "Vocoder..."
;action "Processing Vocoder..."
;info "by Edgar-RFT and David R. Sky\nReleased under terms of the GNU General Public License version 2\nNote: Vocoder works only on * stereo * tracks. Setting channel processing\nto '1 (right channel)' processes only the right channel of your stereo track."
;control dst "Distance: [1 to 120, default = 20]" real "" 20 1 120
;control mst "Channel processing" choice " 2 (both channels), 1 (right channel)" 0
;control bands "Number of vocoder bands" int "" 40 10 240
;control track-vl "Amplitude of original audio [percent]" real "" 100 0 100
;control noise-vl "Amplitude of white noise [percent]" real "" 0 0 100
;control radar-vl "Amplitude of Radar Needles [percent]" real "" 0 0 100
;control radar-f "Frequency of Radar Needles [Hz]" real "" 30 1 100
; vocoder by Edgar-RFT
; a bit of code added by David R. Sky
; Released under terms of the GNU Public License version 2
; http://www.opensource.org/licenses/gpl-license.php
; maybe the code once again has to be changed into _one_ local let-binding
; if you have lots of nyquist "[gc:" messages try this:
; (expand 100) ; gives Xlisp more memory but I have noticed no speed difference
; number of octaves between 20hz and 20khz
(setf octaves (/ (log 1000.0) (log 2.0)))
; convert octaves to number of steps (semitones)
(setf steps (* octaves 12.0))
; interval - number of steps per vocoder band
(setf interval (/ steps bands))
; Some useful calculations but not used in this plugin
; half tone distance in linear
; (print (exp (/ (log 2.0) 12)))
; octave distance in linear
; (print (exp (/ (log 1000.0) 40)))
; The Radar Wavetable
; make *radar-table* a global variable.
(setf contol-dummy *control-srate*) ; save old *control-srate*
(set-control-srate *sound-srate*)
(setf *radar-table* (pwl (/ 1.0 *control-srate*) 1.0 ; 1.0 after 1 sample
(/ 2.0 *control-srate*) 0.0 ; 0.0 after 2 samples
(/ 1.0 radar-f))) ; stay 0.0 until end of the period
(set-control-srate contol-dummy) ; restore *control-srate*
; make *radar-table* become a nyquist wavetable of frequency radar-f
(setf *radar-table* (list *radar-table* (hz-to-step radar-f) T))
; increase the volume of the audacity track in the middle of the slider
; the sqrt trick is something like an artifical db scaling
(setf track-vol (sqrt (/ track-vl 100.0)))
; decrease the volume of the white noise in the middle of the slider
; the expt trick is an inverse db scaling
(setf noise-vol (expt (/ noise-vl 100.0) 2.0))
; also increase the volume of the needles in the middle of the slider
(setf radar-vol (sqrt (/ radar-vl 100.0)))
; here you can switch the tracks on and off for bug tracking
; (setf radar-vol 0)
; (setf noise-vol 0)
; (setf track-vol 0)
; The Mixer
; calculate duration of audacity selection
(setf duration (/ len *sound-srate*))
; if track volume slider is less than 100 percent decrease track volume
(if (< track-vl 100) (setf s (vector (aref s 0) (scale track-vol (aref s 1)))))
; if radar volume slider is more than 0 percent add some radar needles
(if (> radar-vl 0) (setf s (vector (aref s 0) (sim (aref s 1)
(scale radar-vol (osc (hz-to-step radar-f) duration *radar-table*))))))
; if noise volume slider is more than 0 percent add some white noise
(if (> noise-vl 0) (setf s (vector (aref s 0) (sim (aref s 1)
(scale noise-vol (noise duration))))))
; The Vocoder
(defun vocoder ()
(let ((p (+ (hz-to-step 20) (/ interval 2.0))) ; midi step of 20 Hz + offset
f ; we can leave f initialized to NIL
(q (/ (sqrt 2.0) (/ octaves bands))) ; explanation still missing
(result 0)) ; must be initialized to 0 because you cannot sum to NIL
(dotimes (i bands)
(setf f (step-to-hz p))
(setf result (sum result
(bandpass2 (mult (lowpass8
(s-max (bandpass2 (aref s 0) f q)
(scale -1 (bandpass2 (aref s 0) f q))) (/ f dst))
(bandpass2 (aref s 1) f q)) f q)))
(setf p (+ p interval)))
result))
; The Program
(if (arrayp s) (let ()
(cond ((= mst 1) (vector (aref s 0) (setf (aref s 1) (vocoder))))
((= mst 0) (setf s (vocoder))))
(cond ((= mst 1) (setq peakamp (peak (aref s 1) ny:all)))
((= mst 0) (setq peakamp (peak s ny:all))))
(cond ((= mst 1) (vector (aref s 0) (setf (aref s 1)
(scale (/ 1.0 peakamp) (aref s 1)))))
((= mst 0) (setf s (scale (/ 1.0 peakamp) s))))
s))