[CM] Scheme, larger structures

James Hearon j_hearon at hotmail.com
Fri Jul 22 11:15:20 PDT 2016


Hi,

I had written about a scheme method to do something similar to CLM's with-mix
for larger compositional structures using multiple instruments and Bill had replied...

"If you want to concatenate several with-sounds into one,
just concatenate the instrument calls, with some variable
holding the section's start time."

I'm not sure I'm off in the right direction, but I tried to implement what Bill was suggesting and got stuck getting the instruments to read in the body of with-sound.  I tried a cons, let, string, and a vector on the instrument calls and couldn't get those to play in with-sound so I just put them in a pattern.  The instrument calls seem to be getting thru when I print, but for some reason with-sound is not recognizing them.

Maybe I'm off on the wrong design here.

Any help, comments appreciated.

Regards,
Jim


(load "/opt/snd-16/CM_patterns.scm")

(define (round-off z n)
  (let ((power (expt 10 n)))
    (/ (round (* power z)) power)))

(definstrument (examp1 start-time duration frequency amplitude)
(let* ((beg (seconds->samples start-time))
(end (+ beg (seconds->samples duration)))
(sine-wave (make-oscil :frequency frequency)))
(do ((i beg (+ i 1)))
((= i end))
(let ((x (* amplitude (oscil sine-wave))))
(outa i x)
(outb i x)))))

(definstrument (examp2 start-time duration frequency amplitude)
(let* ((beg (seconds->samples start-time))
       (end (+ beg (seconds->samples duration)))
       (gen (make-polywave 440.0 :partials '(1 1.69 3 5))))
(do ((i beg (+ i 1)))
    ((= i end))
(let ((x (* amplitude (polywave gen))))
(outa i x)
(outb i x) ))))

;sanity check
(with-sound (:output "/home/myTest.wav" :srate 48000 :channels 2
             :header-type mus-riff :statistics #t :play #t)
  (examp1 0 .5  480 .75)
  (examp2 1 .5  580 .07)
  (examp1 2 .5  380 .75)
)

(let ((aaa (make-heap '(360 800.345 1200 600))) ;freq
      (bbb (make-cycle '(1 1 .75 .25 .20 .15 .10 .10 .10 .10))) ;dur
      (ccc (make-heap '((examp1 i v (next aaa) .2) (examp2 i v (next aaa) .2) )))
      )
(with-sound (:reverb nrev :output "/home/myTest.wav" :srate 48000 :channels 2
             :header-type mus-riff :statistics #t :play #t)
        (let ((i 0))
                 (do ((k 0 (+ k 1)))
               ((>= k 25))
          (let ((v (next bbb)))
          ;(examp1 i v (next aaa) .2) ;works fine
        ;(format #t "~%next ccc:  ")
                ;(display (next ccc))
            (next ccc) ; xxx not working
        (set! i (+ (round-off i 2) v))
                )))))






















-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cm-mail.stanford.edu/mailman/private/cmdist/attachments/20160722/123f4b72/attachment.html>


More information about the Cmdist mailing list