On Sun, Aug 25, 2019 at 06:03:17PM -0400, David O'Toole wrote: > 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)
There is a trivial error; it is correct: (let ((reg (make-region beg (+ beg actual-block-len -1) snd chn))) ...) The result of your echo-mosaic is a new empty sound file with pending mixes. Perhaps you want save-sound after loop: (do ((n 0 (+ n 1))) - ((= n num-blocks)) + ((= n num-blocks) (save-sound new)) possibly with a filename for new-sound. _______________________________________________ Cmdist mailing list [email protected] https://cm-mail.stanford.edu/mailman/listinfo/cmdist
