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:
@@ -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:
|
;; For information about writing and modifying Nyquist plug-ins:
|
||||||
;; https://wiki.audacityteam.org/wiki/Nyquist_Plug-ins_Reference
|
;; 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 pitch (_ "Pluck MIDI pitch") int "" 60 1 120
|
||||||
$control fade (_ "Fade-out type") choice (
|
$control fade (_ "Fade-out type") choice ((_ "Abrupt") (_ "Gradual")) 0
|
||||||
(_ "Abrupt")
|
$control dur (_ "Duration (60s max)") time "" 1 0.0 60
|
||||||
(_ "Gradual")
|
|
||||||
) 0
|
|
||||||
$control dur (_ "Duration [seconds]") real "" 1 0.1 30
|
|
||||||
|
|
||||||
|
|
||||||
; set final-amp for abrupt or gradual fade
|
; set final-amp for abrupt or gradual fade
|
||||||
(setf final-amp (if (= fade 1) 0.001 0.000001))
|
(setf final-amp (if (= fade 1) 0.001 0.000001))
|
||||||
|
|
||||||
;; Get length of preview
|
(cond
|
||||||
(setq pdur
|
((> dur 0)
|
||||||
(if (get '*track* 'view) ;NIL if preview
|
;; Get length of preview
|
||||||
dur
|
(setq pdur
|
||||||
(get '*project* 'preview-duration)))
|
(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))
|
(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.
|
(pluck-sound (extract-abs 0 pdur pluck-sound)) ; shorten if necessary for preview.
|
||||||
(max-peak (peak pluck-sound ny:all)))
|
(max-peak (peak pluck-sound ny:all)))
|
||||||
;; snd-pluck has a random element and will occasionally produce
|
;; snd-pluck has a random element and will occasionally produce
|
||||||
;; zero amplitude at very high pitch settings. Avoid division by zero.
|
;; zero amplitude at very high pitch settings. Avoid division by zero.
|
||||||
(if (> max-peak 0)
|
(if (> max-peak 0)
|
||||||
(scale (/ 0.8 max-peak) pluck-sound)
|
(scale (/ 0.8 max-peak) pluck-sound)
|
||||||
pluck-sound))
|
pluck-sound)))
|
||||||
|
;; If previewing give Audacity a bit of silence, else return null string.
|
||||||
|
((get '*track* 'view) "")
|
||||||
|
(t (s-rest 0.1)))
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ $copyright (_ "Released under terms of the GNU General Public License version 2"
|
|||||||
;; by Dominic Mazzoni, David R. Sky and Steve Daulton.
|
;; by Dominic Mazzoni, David R. Sky and Steve Daulton.
|
||||||
;; Drip sound generator by Paul Beach
|
;; Drip sound generator by Paul Beach
|
||||||
|
|
||||||
|
;; TODO: add more drum sounds
|
||||||
|
|
||||||
;; Released under terms of the GNU General Public License version 2:
|
;; Released under terms of the GNU General Public License version 2:
|
||||||
;; http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
;; http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
;;
|
;;
|
||||||
@@ -18,108 +20,27 @@ $copyright (_ "Released under terms of the GNU General Public License version 2"
|
|||||||
;; https://wiki.audacityteam.org/wiki/Nyquist_Plug-ins_Reference
|
;; https://wiki.audacityteam.org/wiki/Nyquist_Plug-ins_Reference
|
||||||
|
|
||||||
|
|
||||||
$control action (_ "Action choice") choice (
|
$control tempo (_ "Tempo (bpm)") real (_ "30 - 300 beats/minute") 120 30 300
|
||||||
("Generate" (_ "Generate Track"))
|
$control timesig (_ "Beats per bar") int (_ "1 - 20 beats/measure") 4 1 20
|
||||||
("Help1" (_ "Help Screen 1"))
|
|
||||||
("Help2" (_ "Help Screen 2"))
|
|
||||||
) 0
|
|
||||||
$control tempo (_ "Tempo (beats per minute)") real (_ "30 - 300 beats/minute") 120 30 300
|
|
||||||
$control timesig (_ "Beats per measure (bar)") int (_ "1 - 20 beats/measure") 4 1 20
|
|
||||||
$control swing (_ "Swing amount") float (_ "+/- 1") 0 -1 1
|
$control swing (_ "Swing amount") float (_ "+/- 1") 0 -1 1
|
||||||
$control measures (_ "Number of measures (bars)") int (_ "1 - 1000 bars") 16 1 1000
|
$control text (_ "Set 'Number of bars' to zero to enable the 'Rhythm track duration'.")
|
||||||
$control click-track-dur (_ "Optional rhythm track duration (minutes seconds)") string (_ "Whole numbers only") ""
|
$control bars (_ "Number of bars") int (_ "1 - 1000 bars") 16 0 1000
|
||||||
|
$control click-track-dur (_ "Rhythm track duration") time "Used if 'Number of bars' = 0" 0 0 nil
|
||||||
;;control ticklen "Individual beat duration (milliseconds)" int "1 - 100 ms" 10 1 100
|
$control offset (_ "Start time offset") time (_ "Silence before first beat") 0 0 nil
|
||||||
|
$control click-type (_ "Beat sound") choice (("Metronome" (_ "Metronome Tick"))
|
||||||
$control offset (_ "Start time offset (seconds)") real (_ "0 - 30 seconds") 0 0 30
|
(_ "Ping (short)")
|
||||||
$control click-type (_ "Beat sound") choice (
|
(_ "Ping (long)")
|
||||||
("Metronome" (_ "Metronome Tick"))
|
(_ "Cowbell")
|
||||||
(_ "Ping")
|
("ResonantNoise" (_ "Resonant Noise"))
|
||||||
(_ "Cowbell")
|
("NoiseClick" (_ "Noise Click"))
|
||||||
("ResonantNoise" (_ "Resonant Noise"))
|
(_ "Drip (short)")
|
||||||
("NoiseClick" (_ "Noise Click"))
|
(_ "Drip (long)")) 0
|
||||||
(_ "Drip")
|
|
||||||
) 0
|
|
||||||
|
|
||||||
;;control q "Noise click resonance - discernable pitch (q)" int "1 - 20" 1 1 20
|
|
||||||
|
|
||||||
$control high (_ "MIDI pitch of strong beat") int (_ "18 - 116") 84 18 116
|
$control high (_ "MIDI pitch of strong beat") int (_ "18 - 116") 84 18 116
|
||||||
$control low (_ "MIDI pitch of weak beat") int (_ "18 - 116") 80 18 116
|
$control low (_ "MIDI pitch of weak beat") int (_ "18 - 116") 80 18 116
|
||||||
|
|
||||||
;; allow q control to be commented out.
|
|
||||||
(if (not (boundp 'q))
|
|
||||||
(setf q 10))
|
|
||||||
|
|
||||||
;; allow ticklen control to be commented out.
|
|
||||||
(if (not (boundp 'ticklen))
|
|
||||||
(setf ticklen 10))
|
|
||||||
|
|
||||||
;; TODO: Hard code tick length (long and short versions)
|
|
||||||
;; TODO: add drum sounds
|
|
||||||
|
|
||||||
|
|
||||||
(defun help1 ()
|
|
||||||
(format nil
|
|
||||||
(_ "Rhythm Track Generator help - screen 1 of 2
|
|
||||||
|
|
||||||
Generates a rhythm track at the selected tempo, beats per
|
|
||||||
measure, and either number of measures or track duration,
|
|
||||||
using the selected sound.
|
|
||||||
|
|
||||||
'Tempo': number of beats (clicks) per minute.
|
|
||||||
|
|
||||||
'Beats per measure (bar)': For example, 3/4 time means one
|
|
||||||
strong beat then two others to form one bar, repeated
|
|
||||||
depending on 'number of measures' or 'rhythm track duration'.
|
|
||||||
|
|
||||||
'Swing amount': When set to a non-zero amount, alternate
|
|
||||||
beats are delayed or advanced to give a swing feel. At
|
|
||||||
maximum / minimum settings the rhythm plays with triplet timing.
|
|
||||||
|
|
||||||
'Optional rhythm track duration': If you enter a value into this
|
|
||||||
field, either (minutes seconds - separated by a space), or
|
|
||||||
(seconds), the generated rhythm track will be at or slightly
|
|
||||||
longer than this duration: the end of the track is extended
|
|
||||||
into a whole measure if the entered duration does not
|
|
||||||
produce this. Use whole numbers only.
|
|
||||||
|
|
||||||
If you enter a value into this field, the 'number of measures'
|
|
||||||
value will be ignored.
|
|
||||||
|
|
||||||
To generate rhythm track or view help screen 2,
|
|
||||||
restart Rhythm Track and select from 'Action choice'."))) ;end of help1
|
|
||||||
|
|
||||||
|
|
||||||
(defun help2 ()
|
|
||||||
(format nil
|
|
||||||
(_ "Rhythm Track Generator help - screen 2 of 2
|
|
||||||
|
|
||||||
'Start time offset': makes the rhythm track start at a later
|
|
||||||
time than the very beginning (zero seconds), maximum
|
|
||||||
of 30 seconds.
|
|
||||||
|
|
||||||
'Beat sound': choose which sound to use for the beats.
|
|
||||||
|
|
||||||
'MIDI pitch of strong/weak beat': MIDI values indicate
|
|
||||||
what pitch to use. C-notes are:
|
|
||||||
|
|
||||||
24, 36, 48, 60 (middle C), 72, 84, 96, 108.
|
|
||||||
C# (C-sharp) above middle C is 61.
|
|
||||||
|
|
||||||
To generate rhythm track or view help screen 1,
|
|
||||||
restart Rhythm Track and select from 'Action choice'."))) ;end of help 2
|
|
||||||
|
|
||||||
|
|
||||||
;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))))
|
|
||||||
|
|
||||||
|
;; Helper functions:
|
||||||
|
|
||||||
(defun round-up (x)
|
(defun round-up (x)
|
||||||
(if (> x (truncate x))
|
(if (> x (truncate x))
|
||||||
@@ -127,18 +48,22 @@ restart Rhythm Track and select from 'Action choice'."))) ;end of help 2
|
|||||||
(truncate x)))
|
(truncate x)))
|
||||||
|
|
||||||
|
|
||||||
(defun m-s-to-seconds (mslist)
|
;; Filtering causes changes amplitude, so we normalize to
|
||||||
(if (= (length mslist) 1)
|
;; achieve a predictable level.
|
||||||
;just seconds
|
(defun normalize (sound)
|
||||||
(first mslist)
|
(scale (/ (peak sound ny:all)) sound))
|
||||||
;minutes and seconds
|
|
||||||
(+ (* 60 (first mslist))(second mslist))))
|
|
||||||
|
|
||||||
|
|
||||||
;Function to generate drip sound clicks
|
(defun s-rest-abs (d)
|
||||||
;code by Paul Beach www.proviewlandscape.com/liss/
|
(abs-env (s-rest d)))
|
||||||
;stretch-abs function makes this sound more like 'tick' sounds.
|
|
||||||
;limit hz to nyquist frequency.
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; Click sound synthesis
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
|
||||||
|
;; Drip sound by Paul Beach www.proviewlandscape.com/liss/
|
||||||
(defun drip (p) ;p is pitch in hz
|
(defun drip (p) ;p is pitch in hz
|
||||||
(let* ((maxhz (/ *sound-srate* 2.1))
|
(let* ((maxhz (/ *sound-srate* 2.1))
|
||||||
(hz1 (min maxhz (* 2.40483 p)))
|
(hz1 (min maxhz (* 2.40483 p)))
|
||||||
@@ -155,86 +80,7 @@ restart Rhythm Track and select from 'Action choice'."))) ;end of help 2
|
|||||||
(mult (hzosc hz4) 0.0625))))
|
(mult (hzosc hz4) 0.0625))))
|
||||||
440)))
|
440)))
|
||||||
|
|
||||||
|
;; Metronome tick by Steve Daulton.
|
||||||
;Function used to normalize noise and tick clicks
|
|
||||||
;this function is necessary because filtering
|
|
||||||
;changes amplitude of filtered noise clicks
|
|
||||||
(defun normalize (sound)
|
|
||||||
(scale (/ (peak sound ny:all)) sound))
|
|
||||||
|
|
||||||
|
|
||||||
;; Error Checking
|
|
||||||
(defun errorcheck ()
|
|
||||||
; tempo
|
|
||||||
(if (= (check tempo 30 300) 1)
|
|
||||||
(setq error-msg (strcat error-msg (format nil
|
|
||||||
(_ "Tempo ~a outside valid range 30 to 300 bpm
|
|
||||||
") tempo))))
|
|
||||||
|
|
||||||
;beats per measure
|
|
||||||
(if (= (check timesig 1 20) 1)
|
|
||||||
(setq error-msg (strcat error-msg (format nil
|
|
||||||
(_ "Beats per measure ~a outside valid range 1 to 20
|
|
||||||
") timesig))))
|
|
||||||
|
|
||||||
;number of measures
|
|
||||||
(if (= (check measures 1 1000) 1)
|
|
||||||
(setq error-msg (strcat error-msg (format nil
|
|
||||||
(_ "Number of measures ~a outside valid range 1 to 1000
|
|
||||||
") measures))))
|
|
||||||
|
|
||||||
;time start offset
|
|
||||||
(if (= (check offset 0 30) 1)
|
|
||||||
(setq error-msg (strcat error-msg (format nil
|
|
||||||
(_ "Time offset ~a outside valid range 0 to 30 seconds
|
|
||||||
") offset))))
|
|
||||||
|
|
||||||
; q
|
|
||||||
(if (= (check q 1 20) 1)
|
|
||||||
(setq error-msg (strcat error-msg (format nil
|
|
||||||
(_ "Filter quality q ~a outside valid range 1 to 20
|
|
||||||
") q))))
|
|
||||||
|
|
||||||
;high MIDI pitch
|
|
||||||
(if (= (check high 18 116) 1)
|
|
||||||
(setq error-msg (strcat error-msg (format nil
|
|
||||||
(_ "High MIDI pitch ~a outside valid range 18 to 116
|
|
||||||
") high))))
|
|
||||||
|
|
||||||
;low MIDI pitch
|
|
||||||
(if (= (check low 18 116) 1)
|
|
||||||
(setq error-msg (strcat error-msg (format nil
|
|
||||||
(_ "Low MIDI pitch ~a outside valid range 18 to 116
|
|
||||||
") low))))
|
|
||||||
|
|
||||||
;validate string
|
|
||||||
(if (> (length m-s) 0) ;if at least one item
|
|
||||||
(cond
|
|
||||||
((or
|
|
||||||
(> (length m-s) 2) ;there are more than 2 items or
|
|
||||||
(not (integerp (first m-s))) ;first is not an integer or
|
|
||||||
(and (= (length m-s) 2)(not (integerp (second m-s))))) ;second is not an integer
|
|
||||||
(setq error-msg (strcat error-msg (format nil
|
|
||||||
(_ "If used, 'Optional rhythm track duration' must be
|
|
||||||
entered as either one number (seconds), or two
|
|
||||||
numbers (minutes seconds) separated by a space.
|
|
||||||
Use whole numbers only.~%")))))
|
|
||||||
;one or two integers
|
|
||||||
((and
|
|
||||||
(= (length m-s) 1) ;one integer and
|
|
||||||
(= (check (first m-s) 0 3660) 1)) ;outside valid range
|
|
||||||
(setq error-msg (strcat error-msg (format nil
|
|
||||||
(_ "~a seconds is outside valid range 0 to 3660~%") (first m-s)))))
|
|
||||||
;one or two integers
|
|
||||||
((and
|
|
||||||
(= (length m-s) 2) ;2 integers and
|
|
||||||
(or
|
|
||||||
(= (check (first m-s) 0 60) 1) ;1st is outside valid range or
|
|
||||||
(= (check (second m-s) 0 59) 1))) ;2nd is outside valid range or
|
|
||||||
(setq error-msg (strcat error-msg (format nil
|
|
||||||
(_ "~a is outside valid range 0 to (60 59)~%")
|
|
||||||
m-s))))))) ;end of error checking
|
|
||||||
|
|
||||||
(defun metronome-tick (hz peak)
|
(defun metronome-tick (hz peak)
|
||||||
(let* ((ln 300)
|
(let* ((ln 300)
|
||||||
(sig-array (make-array ln))
|
(sig-array (make-array ln))
|
||||||
@@ -254,9 +100,7 @@ Use whole numbers only.~%")))))
|
|||||||
(mult (abs-env (pwlv 1.11 0.02 1.11 0.05 0 ))
|
(mult (abs-env (pwlv 1.11 0.02 1.11 0.05 0 ))
|
||||||
(jcrev (mult peak gain sig) 0.01 0.1)))))
|
(jcrev (mult peak gain sig) 0.01 0.1)))))
|
||||||
|
|
||||||
(defun s-rest-abs (d)
|
;; Cowbell by Steve Daulton.
|
||||||
(abs-env (s-rest d)))
|
|
||||||
|
|
||||||
(defun cowbell (hz)
|
(defun cowbell (hz)
|
||||||
(sim
|
(sim
|
||||||
(mult (pwev 0.3 0.8 0.0005)
|
(mult (pwev 0.3 0.8 0.0005)
|
||||||
@@ -267,12 +111,14 @@ Use whole numbers only.~%")))))
|
|||||||
(hzosc (* hz 1.52) *tri-table*))))
|
(hzosc (* hz 1.52) *tri-table*))))
|
||||||
|
|
||||||
|
|
||||||
|
;; Single tick generators:
|
||||||
|
|
||||||
(defun get-metronome-tick (hz gain)
|
(defun get-metronome-tick (hz gain)
|
||||||
(resample
|
(resample
|
||||||
(sound-srate-abs 44100 (metronome-tick hz gain))
|
(sound-srate-abs 44100 (metronome-tick hz gain))
|
||||||
*sound-srate*))
|
*sound-srate*))
|
||||||
|
|
||||||
(defun get-ping (pitch)
|
(defun get-ping (pitch ticklen)
|
||||||
(stretch-abs ticklen
|
(stretch-abs ticklen
|
||||||
(mult
|
(mult
|
||||||
(control-srate-abs *sound-srate* (pwl 0.005 amp 0.995 amp 1))
|
(control-srate-abs *sound-srate* (pwl 0.005 amp 0.995 amp 1))
|
||||||
@@ -290,7 +136,7 @@ Use whole numbers only.~%")))))
|
|||||||
(control-srate-abs *sound-srate* (pwl 0.005 amp 0.995 amp 1))
|
(control-srate-abs *sound-srate* (pwl 0.005 amp 0.995 amp 1))
|
||||||
(normalize (lowpass2 (noise 1) (step-to-hz pitch) 2)))))
|
(normalize (lowpass2 (noise 1) (step-to-hz pitch) 2)))))
|
||||||
|
|
||||||
(defun get-drip (pitch)
|
(defun get-drip (pitch ticklen)
|
||||||
(stretch-abs ticklen
|
(stretch-abs ticklen
|
||||||
(mult
|
(mult
|
||||||
(control-srate-abs *sound-srate* (pwl 0.005 amp 0.995 amp 1))
|
(control-srate-abs *sound-srate* (pwl 0.005 amp 0.995 amp 1))
|
||||||
@@ -299,23 +145,26 @@ Use whole numbers only.~%")))))
|
|||||||
(defun get-cowbell (pitch)
|
(defun get-cowbell (pitch)
|
||||||
(mult 0.8 (cowbell (step-to-hz pitch))))
|
(mult 0.8 (cowbell (step-to-hz pitch))))
|
||||||
|
|
||||||
;Function to make click
|
;; Make selected click
|
||||||
(defun click (type accent)
|
(defun click (type accent)
|
||||||
(setq pitch (if (= accent 1) high low))
|
(setq pitch (if (= accent 1) high low))
|
||||||
(setq amp (if (= accent 1) 0.75 0.5))
|
(setq amp (if (= accent 1) 0.75 0.5))
|
||||||
(case type
|
(case type
|
||||||
(0 (get-metronome-tick (step-to-hz pitch) amp))
|
(0 (get-metronome-tick (step-to-hz pitch) amp))
|
||||||
(1 (get-ping pitch))
|
(1 (get-ping pitch 0.01))
|
||||||
(2 (get-cowbell pitch))
|
(2 (get-ping pitch 0.08))
|
||||||
(3 (get-resonant-noise pitch))
|
(3 (get-cowbell pitch))
|
||||||
(4 (get-noise-click pitch))
|
(4 (get-resonant-noise pitch))
|
||||||
(t (get-drip pitch))))
|
(5 (get-noise-click pitch))
|
||||||
|
(6 (get-drip pitch 0.007))
|
||||||
|
(t (get-drip pitch 0.1))))
|
||||||
|
|
||||||
|
|
||||||
(defun swing-adjust (i val)
|
(defun swing-adjust (i val)
|
||||||
(* val (/ 3.0) (rem (1+ i) 2)))
|
(* val (/ 3.0) (rem (1+ i) 2)))
|
||||||
|
|
||||||
;Function to make one measure and save it in the global *measure*
|
|
||||||
|
;Make one measure and save it in the global *measure*
|
||||||
(defun makemeasure ()
|
(defun makemeasure ()
|
||||||
(setf *measure*
|
(setf *measure*
|
||||||
(sim
|
(sim
|
||||||
@@ -326,56 +175,40 @@ Use whole numbers only.~%")))))
|
|||||||
(cue (click click-type 0))))))) ;unaccented beat
|
(cue (click click-type 0))))))) ;unaccented beat
|
||||||
|
|
||||||
|
|
||||||
(defun make-click-track (measures mdur)
|
(defun make-click-track (bars mdur)
|
||||||
(setf *measure* (set-logical-stop (cue *measure*) (* timesig beatlen)))
|
(setf *measure* (set-logical-stop (cue *measure*) (* timesig beatlen)))
|
||||||
(seqrep (i measures) (cue *measure*)))
|
(seqrep (i bars) (cue *measure*)))
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;
|
||||||
;; START MAIN PROGRAM
|
;; MAIN PROGRAM
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
;view 1 of 2 help screens, or generate rhythm track
|
|
||||||
(cond ;'master' cond
|
|
||||||
((= action 1)(help1)); display help screen 1
|
|
||||||
((= action 2)(help2)) ; display help screen 2
|
|
||||||
(t ;Run Program
|
|
||||||
(setq len (/ (* 60.0 *sound-srate* timesig measures) tempo))
|
|
||||||
(setq error-msg "") ;initialize error-msg
|
|
||||||
|
|
||||||
;convert minutes-seconds string to a list
|
(setq len (/ (* 60.0 *sound-srate* timesig bars) tempo))
|
||||||
;for example, "4 30" becomes (4 30)
|
(setf beatlen (/ 60.0 tempo))
|
||||||
(setf m-s (string-to-list click-track-dur))
|
|
||||||
|
|
||||||
;run error checks on input values
|
;call function to make one measure
|
||||||
(errorcheck)
|
(makemeasure)
|
||||||
|
|
||||||
(if (= (length error-msg) 0) ;if no errors, generate Rhythm Track
|
; If 'Number of bars' = 0, calculate bars from 'Rhythm track duration'.
|
||||||
(progn
|
(when (= bars 0)
|
||||||
; duration of 1 beat, originally statically 0.01 s
|
(setq bars (/ click-track-dur (* timesig beatlen))))
|
||||||
(setf ticklen (* (max 1 (min 100 ticklen)) 0.001))
|
|
||||||
(setf beatlen (/ 60.0 tempo))
|
|
||||||
|
|
||||||
;call function to make one measure
|
;if previewing, restrict number of bars
|
||||||
(makemeasure)
|
(let ((preview (/ (get '*project* 'preview-duration)
|
||||||
|
(* timesig beatlen))))
|
||||||
|
(if (not (get '*track* 'view)) ;NIL if previewing
|
||||||
|
(setq bars (min preview bars))))
|
||||||
|
|
||||||
;calculate measures from text input (if used)
|
;round up number of bars
|
||||||
(if m-s (setq measures
|
(setq bars (round-up bars))
|
||||||
(/ (m-s-to-seconds m-s)(* timesig beatlen))))
|
|
||||||
|
|
||||||
;if previewing, restrict number of measures
|
(if (< bars 1)
|
||||||
(let ((preview (/ (get '*project* 'preview-duration)
|
(_ "Set either 'Number of bars' or
|
||||||
(* timesig beatlen))))
|
'Rhythm track duration' to greater than zero.")
|
||||||
(if (not (get '*track* 'view)) ;NIL if preview
|
(if (get '*track* 'view) ;NIL if previewing
|
||||||
(setq measures (min preview measures))))
|
(seq (s-rest offset)
|
||||||
|
(make-click-track bars (* timesig beatlen)))
|
||||||
;round up number of measures
|
;; Don't preview the offset (silence).
|
||||||
(setq measures (round-up measures))
|
(make-click-track bars (* timesig beatlen))))
|
||||||
|
|
||||||
;add time offset and beatlen of silence to rhythm track,
|
|
||||||
(seq
|
|
||||||
(s-rest offset) ;offset
|
|
||||||
(make-click-track measures (* timesig beatlen)))) ;click track
|
|
||||||
;Else error message
|
|
||||||
(setq error-msg (strcat (format nil
|
|
||||||
(_ "Error.~%You have entered at least one invalid value:~%~%")) error-msg)))))
|
|
||||||
|
|||||||
Reference in New Issue
Block a user