[CM] duplicating each N samples of an audio file

David O'Toole deeteeoh1138 at gmail.com
Sun Aug 25 15:03:17 PDT 2019


Hello there! I'm trying to duplicate each N samples of an audio file so
that ABCD becomes AABBCCDD and so on. I have modified one of the examples
to produce the following code below, but it doesn't work. It makes a
properly-sized blank audio file, but only the first block is written.
Indeed, putting in a print statement shows that the loop is only run once.
But NUM-BLOCKS turns out to be 51 which is what I expected. Forgive me if
this is a simple Scheme error, as I am more familiar with Common Lisp and
Elisp than I am with Scheme. Or I may be misunderstanding something about
Snd itself. I would greatly appreciate any help you can offer. Thank you.
---_David

(when (= 0 (length (sounds)))
  (open-sound "/home/dto/Desktop/beatloop.wav"))

(define echo-mosaic
  (lambda* (block-len snd chn)
    (let* ((len (framples snd chn))
  (num-blocks (floor (/ len (srate snd) block-len)))
  (new (new-sound #f :size (* 2 len))))
      (if (> num-blocks 1)
 (let ((actual-block-len (ceiling (/ len num-blocks))))
   (do ((n 0 (+ n 1)))
((= n num-blocks))
     (let ((beg (* n actual-block-len)))
(let ((reg (make-region beg (+ beg actual-block-len) chn)))
 (mix-region reg (* 2 beg) new chn)
 (mix-region reg (+ (* 2 beg) actual-block-len) new chn)
 (forget-region reg))))
   new)))))

(echo-mosaic 0.25 0 0)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cm-mail.stanford.edu/mailman/private/cmdist/attachments/20190825/94a5c67c/attachment.html>


More information about the Cmdist mailing list