Page 3 of 3

Re: Nyquist Drum Replacer

Posted: Wed Jun 09, 2021 7:45 pm
by Paul2
Modified your drum machine code a bit...

Code: Select all

;type generate
;name "Simple Sequencer"

;control filename "Select a mono WAV file" file "" "*default*/drum.wav" "WAV file|*.wav;*.WAV" "open,exists"
;control number "Number of beats" int "" 8 1 31
;control tempo "Tempo" int "bpm" 120 30 300
;control pat "Place every" choice "1 beat, 2 beats, 3 beats, 4 beats" 3

(setf pat (+ pat 1))

(defun get-sound (fname)
  (let ((fp (open fname)))
      (fp (close fp)
          (s-read filename))
      (t  (format nil "Error.~%~s~%cannot be opened."

(defun do-sequence (d-snd)
  (let ((delay (* (/ 60.0 tempo) pat))
        (out (s-rest 0)))
    (dotimes (i number out)
      (setf out
          (sim out
              (at (* i delay) (cue d-snd)))))))

(let ((drum-snd (get-sound filename)))
  (if (arrayp drum-snd)
      (format nil "Error.~%~s~%is stereo."
      (do-sequence drum-snd)))
Really quick and simple to add samples now.
Screen Shot 2021-06-09 at 9.56.57 PM.png
Screen Shot 2021-06-09 at 9.56.57 PM.png (21.04 KiB) Viewed 112 times
Samples used:
(All wav, mono)