;;; a deconstructed bird, for simplification -- (load "unBird.scm") then (go) ;;; writes "/zap/test.wav" ;;; this is based on birds48k.scm, its first bird call, orchard-oriole with lots taken out ;;; tell scheme about some formats that are needed by the following code (use-modules (ice-9 optargs) (ice-9 format)) ;;; define a CLM-style instrument named bird, followed by parameters to the instrument ;;; the real work happens in the "audio run loop" where two envelopes are controlling an ;;; oscillator's amplitude and frequency, as it outputs one audio sample at a time to the sound file ;;; FOR THE ASSIGNMENT, YOU CAN JUST USE THIS INSTRUMENT AS IS (definstrument (bird start dur frequency freqskew amplitude freq-envelope amp-envelope) "(bird start dur frequency freqskew amplitude freq-envelope amp-envelope)" (let* ((gls-env (make-env freq-envelope (hz->radians freqskew) dur)) (os (make-oscil :frequency frequency)) (amp-env (make-env amp-envelope amplitude dur)) (len (inexact->exact (round (* (mus-srate) dur)))) (beg (inexact->exact (round (* (mus-srate) start)))) (end (+ beg len))) (if (c-g?) (throw 'with-sound-interrupt)) (run (lambda () (do ((i beg (1+ i))) ((= i end)) (outa i (* (env amp-env) (oscil os (env gls-env))) *output*)))))) ;;; define three envelopes as lists of x y pairs (define main-amp '(.00 .00 .25 1.00 .60 .70 .75 1.00 1.00 .0)) (define ascending '(.00 .00 1.00 1.0)) (define descending '(.00 1.00 1.00 .0)) ;;; define a bird call as a function of micro-events, each is a call to the above "bird instrument" ;;; THIS IS WHERE YOU DESIGN THE NEW BIRD CALL BY CHANGING THE MICRO-EVENTS (define (mybird beg) (bird beg .03 3700 100 .05 descending main-amp) ;; sine wave at beg lasting 30ms, freq descending from 3700 to 3600, amp = 0.05 (max = 1.0) (bird (+ beg .03) .05 2500 1000 .1 ascending main-amp) ;; sine wave at 30ms lasting 50ms, freq ascending from 2500 to 3500, amp = 0.1 ) ;;; finally, define a function that runs the new bird call function at time = 0 (define (go) "(go) executes the bird call" (with-sound (:srate 48000.0 :output "/zap/test.wav") (mybird 0) ))