1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-27 15:50:10 +01:00

Update Pluck and Rhythm Track plug-ins

Using new time widget.
This commit is contained in:
Steve Daulton
2018-04-28 19:18:00 +01:00
parent cf07f858ec
commit da01838758
2 changed files with 95 additions and 273 deletions

View File

@@ -16,41 +16,30 @@ $copyright (_ "Released under terms of the GNU General Public License version 2"
;; For information about writing and modifying Nyquist plug-ins:
;; https://wiki.audacityteam.org/wiki/Nyquist_Plug-ins_Reference
; 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
; reduces offset so we don't need the highpass8 filter that we used before.
; Updated to v4 by Steve Daulton May 2015
$control pitch (_ "Pluck MIDI pitch") int "" 60 1 120
$control fade (_ "Fade-out type") choice (
(_ "Abrupt")
(_ "Gradual")
) 0
$control dur (_ "Duration [seconds]") real "" 1 0.1 30
$control fade (_ "Fade-out type") choice ((_ "Abrupt") (_ "Gradual")) 0
$control dur (_ "Duration (60s max)") time "" 1 0.0 60
; set final-amp for abrupt or gradual fade
(setf final-amp (if (= fade 1) 0.001 0.000001))
;; Get length of preview
(setq pdur
(if (get '*track* 'view) ;NIL if preview
dur
(get '*project* 'preview-duration)))
(cond
((> dur 0)
;; Get length of preview
(setq pdur
(if (get '*track* 'view) ;NIL if preview
dur
(get '*project* 'preview-duration)))
(let* ((pluck-sound (snd-pluck *sound-srate* (step-to-hz pitch) 0 dur final-amp))
(pluck-sound (extract-abs 0 pdur pluck-sound)) ; shorten if necessary for preview.
(max-peak (peak pluck-sound ny:all)))
;; snd-pluck has a random element and will occasionally produce
;; zero amplitude at very high pitch settings. Avoid division by zero.
(if (> max-peak 0)
(scale (/ 0.8 max-peak) pluck-sound)
pluck-sound))
(let* ((pluck-sound (snd-pluck *sound-srate* (step-to-hz pitch) 0 dur final-amp))
(pluck-sound (extract-abs 0 pdur pluck-sound)) ; shorten if necessary for preview.
(max-peak (peak pluck-sound ny:all)))
;; snd-pluck has a random element and will occasionally produce
;; zero amplitude at very high pitch settings. Avoid division by zero.
(if (> max-peak 0)
(scale (/ 0.8 max-peak) pluck-sound)
pluck-sound)))
;; If previewing give Audacity a bit of silence, else return null string.
((get '*track* 'view) "")
(t (s-rest 0.1)))