[CM] scheme, larger structures

James Hearon j_hearon at hotmail.com
Thu Aug 11 10:33:35 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 tried several ways to concatenate definstrument calls and place those with the
body of with-sound, but nothing seems to work.  It seems like ws.scm just wants
a direct call to a definstrument in the body part.

I gave up and tried concatenating with-sound blocks instead, and it works after a fashion but the
creation of separate audio files means those still have to be stitched together at some point.
At least this is getting closer to what I was after.


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 :frequency frequency :partials '(1 1.69 3 5))))
(do ((i beg (+ i 1)))
    ((= i end))
(let ((x (* amplitude (polywave gen))))
(outa i x)
(outb i x) ))))

(let ((var '())
      (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 '(241 840.345 1000 960 500))) ;freq
      (ddd (make-cycle '(.2 1.25 .75 .25 .20 .15 .10 .10 .50 .10 .50))) ;dur
      )
     (set! var (cons
(with-sound (:reverb nrev :output "Test1.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) .3)
        (set! i (+ (round-off i 2) v))
                ))))  ;;end of with-sound
(with-sound (:output "Test2.wav" :srate 48000 :channels 2
             :header-type mus-riff :statistics #t :play #t)
        (let ((j 1))
                 (do ((k 0 (+ k 1)))
               ((>= k 25))
          (let ((v (next ddd)))
                 (examp2 j v (next ccc) .1)
        (set! j (+ (round-off j 2) v))
                ))))  ;;end of with-sound
) ;end var
) ;end set!
  var
  ) ;end let

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


More information about the Cmdist mailing list