;nyquist plug-in ;version 3 ;type process ;name "Change Speed..." ;info "by Steve Daulton (www.easyspacepro.com)\n\nUse one of:\nThe target 'Final length' (hh:mm:ss),\nThe original and target tempo (BPM or RPM),\nPercent speed change.\n" ;; changespeed.ny by Steve Daulton. 17th May 2011. ;; Released under terms of the GNU General Public License version 2: ;; http://www.gnu.org/licenses/old-licenses/gpl-2.0.html ;; version 1.0 17th May 2011 ;control mode "Change Speed by" choice "Length (time),BPM or RPM,Percent" 0 ;control time "Final length" string "hh:mm:ss" "00:00:30.0" ;control ibpm "Initial Tempo" real "BPM or RPM" 78 0 400 ;control fbpm "Final Tempo" real "BPM or RPM" 45 0 400 ;control percent "Percent Change" real "%" 0 -99 400 ; function to convert a string into a list (defun string-to-list (string) (read (make-string-input-stream (format nil "(~a)" string)))) (defun subst-char-string (string old new) (setq newstring "") ; initialise the new string (dotimes (i (length string)) (let ((ch (char string i))) ; ch is the next character in the string (if (char= ch old)(setq ch new)) (setq newstring (strcat newstring (string ch))))) ; add character to string newstring) (defun ratio-from-time (timelist) (setq newlen (+(*(first timelist)3600)(*(second timelist)60)(third timelist))) (*(/ newlen(get-duration 1))*sound-srate*)) (setq ratio (case mode (0 (setq time (subst-char-string time '#\: '#\space)) (setf timelist (string-to-list time)) (if (or (/=(length timelist)3) (not(numberp (first timelist))) (not(numberp (second timelist))) (not(numberp (third timelist)))) (setq err "Error.\n'Final Length' must be in the form of three numbers separated by colons.") (ratio-from-time timelist))) (1 (*(/ ibpm fbpm) *sound-srate*)) (2 (*(/ 100.0 (+ 100.0 percent)) *sound-srate*)))) (if (numberp ratio) (if (and (< ratio (* 100 *sound-srate*))(> ratio (/ *sound-srate* 100.0))) (resample s ratio) (print "Error.\nSpeed Change out of range.")) (print ratio))