<html><body><div style="color:#000; background-color:#fff; font-family:lucida console, sans-serif;font-size:10pt"><div style="font-family: 'lucida console', sans-serif; font-size: 10pt; ">below is the live-coding documentation in S7 Scheme</div><div style="font-family: 'lucida console', sans-serif; font-size: 10pt; "><br></div><div style="font-family: 'lucida console', sans-serif; font-size: 10pt; "><br></div><div style="font-family: 'lucida console', sans-serif; font-size: 10pt; "><br></div><div><div><font class="Apple-style-span" size="2">;;; -*- syntax: Lisp; font-size: 16; theme: "Emacs"; -*-</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">;</font></div><div><font class="Apple-style-span" size="2">;; Live Coding &nbsp;(Halim Beere, halimbeere@gmail.com)</font></div><div><font class="Apple-style-span" size="2">;</font></div><div><font class="Apple-style-span"
 size="2"><br></font></div><div><font class="Apple-style-span" size="2">; To do live coding, two things are needed. &nbsp;(1) Sprouting processes</font></div><div><font class="Apple-style-span" size="2">; on the fly and having them sync with other processes already running.</font></div><div><font class="Apple-style-span" size="2">; To do this, see the Metronomes example file.</font></div><div><font class="Apple-style-span" size="2">; And (2) updating an already running process with new behavior.</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">; By default, Grace will allow you to sprout a single process as many</font></div><div><font class="Apple-style-span" size="2">; times as you like. &nbsp;This is by design. &nbsp;Define the following</font></div><div><font class="Apple-style-span" size="2">; process, tick-tock().</font></div><div><font class="Apple-style-span"
 size="2"><br></font></div><div><font class="Apple-style-span" size="2">(define (tick-tock )</font></div><div><font class="Apple-style-span" size="2">&nbsp; (process&nbsp;</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; with transp = (between -20 20)</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; for x from 0</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; do</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; (if (= (mod x 2) 0)</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; &nbsp; (send "mp:midi" :key (+ 72 transp) :dur (metro-dur 0.5))</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; &nbsp; (send "mp:midi" :key (+ (pick '(84 82 80 79)) transp) :dur (metro-dur 0.5)))</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; (wait .5)))</font></div><div><font class="Apple-style-span"
 size="2"><br></font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">; now sprout it several times. &nbsp;You'll notice that</font></div><div><font class="Apple-style-span" size="2">; several of them will run simultaneously.</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(sprout (tick-tock ) (sync ))</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">; stop all processes</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(stop )</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">; behind the scenes each of these processes actually has a default</font></div><div><font class="Apple-style-span" size="2">; id number.
 &nbsp;The default is 0, and Grace does not limit the</font></div><div><font class="Apple-style-span" size="2">; the number of processes that can exist with id 0. &nbsp;This is ONLY</font></div><div><font class="Apple-style-span" size="2">; true of the default id.</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">; Let's sprout tick-tock() with its own unique id.</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(sprout (tick-tock ) (sync ) 1)</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">; Now, if we try to sprout tick-tock() AGAIN with the same id (which</font></div><div><font class="Apple-style-span" size="2">; is given above as the number 1), then the new process will replace</font></div><div><font class="Apple-style-span" size="2">; the old
 process. &nbsp;Evaluate the next line several times.</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(sprout (tick-tock ) :id 1)</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(stop )</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">; For any id (except the default id of 0), Grace will only allow ONE</font></div><div><font class="Apple-style-span" size="2">; process to exist with that id. &nbsp;If you try to sprout another process</font></div><div><font class="Apple-style-span" size="2">; with that same id, the old process will be replaced with the new one.</font></div><div><font class="Apple-style-span" size="2">; This will occur even if the processes have different names. &nbsp;The name</font></div><div><font class="Apple-style-span"
 size="2">; doesn't matter. &nbsp;Only the id number.</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">; For instance, define the below process.</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(define (hymn )</font></div><div><font class="Apple-style-span" size="2">&nbsp; (process&nbsp;</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; with subpat = (make-cycle '(2 1.5 1 .5))</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; with pat = (make-cycle (list 2 2 1 subpat))</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; for rhy = (next pat)</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; do</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; (send "mp:midi" :key (+ 63 12) :dur (metro-dur rhy))</font></div><div><font
 class="Apple-style-span" size="2">&nbsp; &nbsp; (send "mp:midi" :key 63 :dur (metro-dur rhy))</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; (send "mp:midi" :key (- (pick '(67 68 70 72)) 12) :dur (metro-dur rhy))</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; (send "mp:midi" :key (+ (pick '(67 68 70 72)) 12) :dur (metro-dur rhy))</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; (wait rhy)))</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">; sprout it with id 1.</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(sprout (hymn ) (sync ) :id 1)</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">; sprout tick-tock with id 1.</font></div><div><font class="Apple-style-span"
 size="2"><br></font></div><div><font class="Apple-style-span" size="2">(sprout (tick-tock ) (sync ) :id 1)</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">; Go back and forth above, and notice that each process will wait until</font></div><div><font class="Apple-style-span" size="2">; the other is finished before replacing it. The replace happens</font></div><div><font class="Apple-style-span" size="2">; in time, in other words.</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">; Sprout with a different id. &nbsp;Choose one below</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(sprout (hymn ) (sync ) :id 2)</font></div><div><font class="Apple-style-span"
 size="2"><br></font></div><div><font class="Apple-style-span" size="2">(sprout (tick-tock ) (sync ) :id 2)</font></div><div><font class="Apple-style-span" size="2">; Now you have two processes running, each with a different id.</font></div><div><font class="Apple-style-span" size="2">; You can selectively stop a process by indicating its id, and stop</font></div><div><font class="Apple-style-span" size="2">; will not touch the other running processes.</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(stop 1)</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(stop 2)</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">; Try this again, but first let's sprout using three custom ids, then&nbsp;</font></div><div><font class="Apple-style-span" size="2">; a
 few using the default id.</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(sprout (tick-tock ) (sync ) :id 1)</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(sprout (tick-tock ) (sync ) :id 2)</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(sprout (tick-tock ) (sync ) :id 3)</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(sprout (tick-tock ) (sync ))</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(sprout (tick-tock ) (sync ))</font></div><div><font class="Apple-style-span"
 size="2"><br></font></div><div><font class="Apple-style-span" size="2">; Like above, we can stop just the process with id = 1.</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(stop 1)</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">; But we can also stop ONLY the processes that have default ids.</font></div><div><font class="Apple-style-span" size="2">; Recall that the default id is 0, so we call:</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(stop 0)</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">; Now only processes id = 2 and id = 3 are running.</font></div><div><font class="Apple-style-span" size="2">;
 Calling stop() with no arguments will stop all running processes,</font></div><div><font class="Apple-style-span" size="2">; regardless of their ids.</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(stop )</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">; note that ids can also be strings, if desired. &nbsp;note that strings</font></div><div><font class="Apple-style-span" size="2">; are converted to numbers behind the scenes, so there is a slight</font></div><div><font class="Apple-style-span" size="2">; chance that a custom numbered id you choose could conflict with</font></div><div><font class="Apple-style-span" size="2">; the id of a string once converted to a number. For example,</font></div><div><font class="Apple-style-span" size="2">; an id of "bass" will become id number 3016415.</font></div><div><font
 class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(string-hash "bass")</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">; Of course, it is unlikely that you will choose 3016415 as your id,</font></div><div><font class="Apple-style-span" size="2">; but if you ever have strange behavior when using ids, you may</font></div><div><font class="Apple-style-span" size="2">; want to check to see if your string ids are conflicting with your</font></div><div><font class="Apple-style-span" size="2">; numbered ids.</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">; both sprout and stop can handle strings.</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(sprout (tick-tock ) :id "soprano")</font></div><div><font
 class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">; replace it</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(sprout (tick-tock ) :id "soprano")</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">; stop it</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(stop "soprano")</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">; strings are supported to help ids be more memorable and descriptive.</font></div><div><font class="Apple-style-span" size="2">; this may help reduce confusion while live coding!</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(sprout (hymn ) :id
 "hymn")</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(stop "hymn")</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">; Of course, one of the main reasons to do this is to allow a user</font></div><div><font class="Apple-style-span" size="2">; to update an existing process with new behavior. &nbsp;Let's do exactly</font></div><div><font class="Apple-style-span" size="2">; that.</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">; Define the process again, slightly different from above.</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(define (tick-tock )</font></div><div><font class="Apple-style-span" size="2">&nbsp; (process&nbsp;</font></div><div><font class="Apple-style-span"
 size="2">&nbsp; &nbsp; for x from 0</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; do</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; (if (= (mod x 2) 0)</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; &nbsp; (send "mp:midi" :key 72 :dur (metro-dur .5))</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; &nbsp; (send "mp:midi" :key (pick '(84 82 80 79)) :dur (metro-dur 0.5)))</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; (wait .5)))</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">; sprout it.</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(sprout (tick-tock ) (sync ) :id "tick")</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">; We
 could simply alter the code above and re-define the process, but</font></div><div><font class="Apple-style-span" size="2">; the code is duplicated and altered below for illustration purposes.</font></div><div><font class="Apple-style-span" size="2">; Notice that we changed the rhythm of the process.</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(define (tick-tock )</font></div><div><font class="Apple-style-span" size="2">&nbsp; (process</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; with rhy-pat = (make-cycle '(.5 .25 .25))</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; for x from 0</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; for dur = (next rhy-pat)</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; do&nbsp;</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; (if (=
 (mod x 2) 0)</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; &nbsp; (send "mp:midi" :key 72 :dur (metro-dur dur))</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; &nbsp; (send "mp:midi" :key (pick '(84 82 80 79)) :dur (metro-dur dur)))</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; (wait dur)))</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">; Now that we have redefined our process, let's sprout it again with</font></div><div><font class="Apple-style-span" size="2">; the same id -&gt; "tick"</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(sprout (tick-tock ) :id "tick")</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">; And one more time, let's alter the process and re-sprout
 it.</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(define (tick-tock )</font></div><div><font class="Apple-style-span" size="2">&nbsp; (process&nbsp;</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; with rhy-pat = (make-cycle '(.25 .25 .125 .125 .125 .125))</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; with root = 72</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; for x from 0</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; for dur = (next rhy-pat)</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; do&nbsp;</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; (if (= (mod x 10) 0)</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; &nbsp; (set! root (+ (pick '(72 75 79)) (pick '(-24 -12 0))))</font></div><div><font
 class="Apple-style-span" size="2">&nbsp; &nbsp; &nbsp; (set! dur (pick '(.25 .5))))</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; (if (= (mod x 2) 0)</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; &nbsp; (send "mp:midi" :key root :dur (* (metro-dur dur) 2))</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; &nbsp; (send "mp:midi" :key (+ (pick '(84 82 80 79)) (pick '(-24 -12 0))) :dur (metro-dur dur)))</font></div><div><font class="Apple-style-span" size="2">&nbsp; &nbsp; (wait dur)))</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(sprout (tick-tock ) (sync ) :id "tick")</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">; sprout another version on top with a new id, using to the metronome</font></div><div><font class="Apple-style-span" size="2">;
 to keep it in sync</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(sprout (tick-tock ) (sync ) :id "tock")</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">; lastly, sprout our old hymn() process with a default id.</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(sprout (hymn ) (sync ))</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">; stop the first process</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(stop "tick")</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">; stop the second process</font></div><div><font
 class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(stop "tock")</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">; stop the default process</font></div><div><font class="Apple-style-span" size="2"><br></font></div><div><font class="Apple-style-span" size="2">(stop 0)</font></div></div><div style="font-family: 'lucida console', sans-serif; font-size: 10pt; ">&nbsp;</div><div style="font-family: 'lucida console', sans-serif; font-size: 10pt; ">--<br>Aykut Caglayan (PhD)<br>http://aykutcaglayan.blogspot.com/<br></div>  <div style="font-size: 10pt; font-family: 'lucida console', sans-serif; "> <div style="font-size: 12pt; font-family: 'times new roman', 'new york', times, serif; "> <font size="2" face="Arial"> <hr size="1">  <b><span style="font-weight:bold;">From:</span></b> Aykut Caglayan &lt;aykut_caglayan@yahoo.com&gt;<br> <b><span
 style="font-weight: bold;">To:</span></b> "cmdist@ccrma.Stanford.EDU" &lt;cmdist@ccrma.Stanford.EDU&gt; <br><b><span style="font-weight: bold;">Cc:</span></b> "halimbeere@gmail.com" &lt;halimbeere@gmail.com&gt; <br> <b><span style="font-weight: bold;">Sent:</span></b> Wednesday, November 23, 2011 1:01 AM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: metronomes and live coding<br> </font> <br><div id="yiv820766509"><div><div style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-size: 10pt; font-family: 'lucida console', sans-serif; "><div style="font-family: sans-serif; "><div style="font-family: times, serif; ">Many thanks to Halim for his effort in making it possible to use CommonMusic as a live-coding language.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">While I was reading the metro.sal documantation, I transcribed it into the S7
 Scheme.&nbsp;</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">I have pasted the whole document below.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">PS: i may read/transcribe the livecoding doc in a few days too.<br></div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077"><span class="yiv820766509Apple-style-span" style="font-size: 13px; font-family: sans-serif; ">--</span><br style="font-size: 13px; font-family: sans-serif; "><span class="yiv820766509Apple-style-span" style="font-size: 13px; font-family: sans-serif; ">Aykut Caglayan (PhD)</span><br style="font-size: 13px; font-family: sans-serif; "><span class="yiv820766509Apple-style-span" style="font-size: 13px; font-family: sans-serif;
 ">http://aykutcaglayan.blogspot.com/</span><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">;;; -*- syntax: Lisp; font-size: 18; theme: "Emacs"; -*-<br></div><div class="yiv820766509yui_3_2_0_26_132199474583077"><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">;</div><div class="yiv820766509yui_3_2_0_26_132199474583077">;; Metronomes &nbsp;(Halim Beere, halimbeere@gmail.com)</div><div class="yiv820766509yui_3_2_0_26_132199474583077">;</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; Metronomes are objects that allow you to change the tempo of running</div><div
 class="yiv820766509yui_3_2_0_26_132199474583077">; processes in real-time. at least one metronome is always active,</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; even if you do not specify a metronome the 'default metronome' will</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; be in use. &nbsp;to access a metronome you use its 'id', the metronom id</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; of the default metronome is always 0:</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; current beat
 time of the default metro</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro-beat 0)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; most metronome functions take an optional 'metro' arg that lets you</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; specify which metronome should be use. if you don't specify this</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; value explicitly you will get whatever metronome is in th global</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; varible *metro*. This variable is intiaily set to 0 (the default</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; metronome) but you can reset it to any metronome that you create.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div
 class="yiv820766509yui_3_2_0_26_132199474583077">; if no metro is specified the metronome in *metro* will be used:</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro-beat )</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; use 'make-metro' to create a new metronome with some initial</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; starting tempo. make-metro returns the new metronome's id as its</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; value that you save in a variable for referenceing that metro</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(define mymetro (make-metro 100))</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div
 class="yiv820766509yui_3_2_0_26_132199474583077">; you can ask if there is a metro with a given id:</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro? mymetro)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro? 0)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; you can get the current tempo and beat value of your metronome</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro-tempo mymetro)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; get the tempo of the default metronome:</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div
 class="yiv820766509yui_3_2_0_26_132199474583077">(metro-tempo )</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; you can get a list of all the ids of all the metronomes</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metros )</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; if you dont want to include the default metro in the
 list&nbsp;</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metros #t)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; the default will always be the first in the list so you could also</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; do</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(rest (metros ))</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; you can delete a metronome when you are done with it</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(delete-metro mymetro)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div
 class="yiv820766509yui_3_2_0_26_132199474583077">(metro? mymetro)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metros
 )</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">;</div><div class="yiv820766509yui_3_2_0_26_132199474583077">;; Using Metronomes With Processes&nbsp;</div><div class="yiv820766509yui_3_2_0_26_132199474583077">;</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; let's first create a process of running sixteenths, i.e. &nbsp;it waits</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; one-quarter of a beat after playing each note:</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(define (dvorak )</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; (process&nbsp;</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; with mel = (key '(a4 bf4 a4 g4 f4 e4 d4 bf2 d3 f4 e4 f4 d4 g2
 d3&nbsp;</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; f4 e4 d4 e4 a2
 e4 f4 e4 f4 d4 d3 a3 d4 f4 g4))</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; with pat = (make-cycle (concat mel mel (plus 12 mel) (plus 12 mel)))&nbsp;</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; with dur</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; for k = (next pat)</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; do</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; (set! dur (if (&lt; k 62) 1 1/4))</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; (send "mp:midi" :key k :dur dur)</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; (wait 1/4)))</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp;&nbsp;</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div
 class="yiv820766509yui_3_2_0_26_132199474583077">; sprout the process to start it playing</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(sprout (dvorak))</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; the 'metro' function adjusts the tempo of a metronome in real-time:</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; metro(tempo,time,metro) the frist arg is the new bpm value for the</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; metromome, the second arg is the number of seconds for the metronome</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; to move from its current tempo to the new tempo. &nbsp;the optional third</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; arg is the metronome to use, and defaults to the default metronome.</div><div
 class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; lets move the reich process from bpm 60 to bpm 90 over 3 seconds:</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro 90 3)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; now move to bpm 400 in 6 seconds</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro 400 6)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; move back to 60 immediately</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro 60 0)</div><div
 class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; if a time is not specified, the default is to move the tempo in 0</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; seconds. the following will move to bpm 40 immediately. you can</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; also specify seconds with the keyword secs:</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro 40)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro 40 :secs 0)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; you can also specify moving to a new tempo over a certain number</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; of beats. that is, a linear
 tempo change will occur such that 10</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; beats later we will arrive at the new tempo.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro 90 :beats 10)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; one can sprout a process as many times as one likes, and&nbsp;</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; each one will be independent from the
 others. &nbsp;sprout</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; piano-phase() again, and even though the speed of the process is</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; dictated by the metronome tempo, the processes will not be aligned.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; execute the next line several times</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(sprout (dvorak ))</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; setting the tempo will still affect all running processes</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro 10 :secs 4)</div><div
 class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro 90)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; stop all processes</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(stop )</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">;</div><div class="yiv820766509yui_3_2_0_26_132199474583077">;; Syncing Processes With Metronomes</div><div class="yiv820766509yui_3_2_0_26_132199474583077">;</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div
 class="yiv820766509yui_3_2_0_26_132199474583077">; when a process is sprouted, it begins playing at the moment sprout()</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; is evaluated. however, this will likely be at some fraction of the</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; beat. the same happens when we ask for the current beat. the</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; liklihood that we will get a round, integer number is slim. Try it:</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro-beat )</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; You got something like 888.74775660822. That would mean that you</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; were presently at the 888th beat, and almost 3/4's of the way&nbsp;</div><div
 class="yiv820766509yui_3_2_0_26_132199474583077">; through it. if you had sprouted a process then, it would</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; have started at that point.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; in order to ensure that a process starts on a beat, you need to&nbsp;</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; pass a special function as the ahead value to the sprout.
 recall</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; that sprout has an ahead parameter, which delays the sprouting of</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; the process until the indicated time elapses.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; first, let's make a new process</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(define (downbeats )</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; (process</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; with Cm = (make-heap '(c4 ef4 g4))</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; with chrom = (make-heap '(cs4 d4 e4 f4 fs4 gs4 a4 as4 b4) :for 1)</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; with pat = (make-cycle (list
 Cm chrom))</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; with dur</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; for k = (key (next pat))</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; do</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; (if (odds .1)</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; &nbsp; (begin (set! dur 3)</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(send "mp:midi" :key (- k 12) :dur dur))</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; &nbsp; (begin (set! dur 1)</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(send "mp:midi" :key (+ k (pick 0 12)) :dur dur)))</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; (wait dur)))</div><div
 class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; now let's sprout our new process 2 beats in the future.</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; however, it
 you execute the below at beat 232.7, then the process</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; will start at 234.7! &nbsp;</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(sprout (downbeats) 2)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(stop )</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; to ensure that the process starts on a downbeat, pass in sync()</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; as your ahead value. This way the process will start on a round</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; beat number, such as 235.0.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(sprout (downbeats )
 (sync ))</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; sprout it again, and
 you will see that both processes are aligned</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; with the downbeat.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(sprout (downbeats ) (sync ))</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; sync() itself can take an ahead argument. &nbsp;The default value is 1,</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; which means the process will start at the NEXT downbeat. &nbsp;The above</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; sprouts are equivalent to:</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(sprout (downbeats ) (sync 1))</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div
 class="yiv820766509yui_3_2_0_26_132199474583077">; if you give sync() a value of .5, it will start your process on the</div><div class="yiv820766509yui_3_2_0_26_132199474583077">;
 nearest offbeat. &nbsp;If you call sprout() at beat 102.23 for example,</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; then your process will start at 102.5. &nbsp;Calling sprout() at 102.59</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; with sync(.5) will start your process at 103.5.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(sprout (downbeats ) (sync 0.5))</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; give sync() a value of 1.75, and it will wait until the next beat</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; arrives, then it will start your process at .75 of that beat.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(sprout (downbeats ) (sync 1.75))</div><div
 class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; stop the above
 processes</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(stop )</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; now sync them to a different metronome</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(define mymetro (make-metro 100))</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(sprout (downbeats ) (sync :metro mymetro))</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(sprout (downbeats ) (sync 1/3 :metro mymetro))</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(sprout (downbeats ) (sync 2/3 :metro
 mymetro))</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; stop all processes.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(stop )</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">;</div><div class="yiv820766509yui_3_2_0_26_132199474583077">;; Accouting For Durations With Metronomes</div><div class="yiv820766509yui_3_2_0_26_132199474583077">;</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; While attack times for all events remain accurate, even while</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; changing tempos,
 the duration values when sending midi data</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; are in absolute seconds, not beats.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; Notice that even though the downbeats() process is waiting to
 play&nbsp;</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; every beat (at bpm 120), the durations are longer than they should&nbsp;</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; be, because "dur: 1" refers to seconds, not beats.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro 120)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(sprout (downbeats ) (sync ))</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(stop )</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; here is a new process. notice we have the same problem.</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; even though our durations and wait values are the
 same, the dur:</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; is in seconds, while wait is in beats.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(define (pathetic )</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; (process&nbsp;</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; with mel-pat = (make-cycle&nbsp;</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (key '(b3 cs4 d cs b3 e4 d b3 d4 cs fs e e e&nbsp;</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; g fs fs fs b3 as as as cs4 b3 b b fs e e e g</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fs fs e d e d cs b2 as fs fs3)))</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; with rhy-pat = (make-cycle '(.5 .5 1 2 .25 .25 .25 .25 1 2</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .25 .25 .25 .25 .25 .25 .25 .25</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .25 .25 .25 .25 .25 .25 .25 .25</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .25 .25 .25 .25 .25 .25 .25 .25</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .25 .25 .25 .25 .25 .25 .25 .25))</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; for k = (next mel-pat)</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; for d =
 (next rhy-pat)</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; do</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; (send "mp:midi" :key k :dur d)</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; (wait d)))</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; sprout it and notice how long the notes sustain.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(sprout (pathetic ) (sync ))</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(stop )</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; To correct for this we will use
 metro-dur() when indicating</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; the durations of midi notes.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(define* (pathetic (m *metro*) )</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; (process&nbsp;</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; with mel-pat = (make-cycle&nbsp;</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (key '(b3 cs4 d cs b3 e4 d b3 d4 cs fs e e e&nbsp;</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; g fs fs fs b3 as as as cs4 b3 b b fs e e e g</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fs fs e d e d cs b2 as fs fs3)))</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; with rhy-pat = (make-cycle '(.5 .5 1 2 .25 .25 .25 .25 1 2</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .25 .25 .25 .25 .25 .25 .25 .25</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .25 .25 .25 .25 .25 .25 .25 .25</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .25 .25 .25 .25 .25 .25 .25 .25</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .25 .25 .25 .25 .25 .25 .25 .25))</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; for k = (next mel-pat)</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; for d =
 (next rhy-pat)</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; ;for m = (make-metro m)</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; do</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; (send "mp:midi" :key k :dur (metro-dur 0.5 m))</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; (wait d)))</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; now try sprouting it. Notice this corrects the issue.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(sprout (pathetic ) (sync ))</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; Even if we make the tempo faster, the durations will become shorter</div><div
 class="yiv820766509yui_3_2_0_26_132199474583077">; to accomodate the tempo.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro 200)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; or longer durations at a slower tempo</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro 20 4)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; metro-dur() simply returns the amount of time in seconds that it will</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; take for a beat amount under the current metronome. at bpm = 20,</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; one beat should take 3 seconds.</div><div
 class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro-dur 1)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; of course, you can pass in a custom metronome</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro-dur 1 mymetro)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(stop )</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; the same adjustments must be made if you take advantage of the</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; "time" ahead parameter when sending a midi event. &nbsp;Recall . . .</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; this will
 trigger a midi event immediately.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(send "mp:midi" :key 60)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; and this will trigger it 1 second from now</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(send
 "mp:midi" :time 1 :key 60)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; Thus, if you use the "time" midi parameter inside of a process,</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; it will only work as expected if your metronome is at bpm = 60.</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; This is because this is the tempo at which 1 beat is equal to 1</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; second, and "time" (for mp:midi) is in seconds, not beats.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; here is a process that uses the "time" argument. Define it below.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(define (time-user )</div><div
 class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; (process&nbsp;</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; with pat = (make-cycle
 '(2 1 .5 .25 .25))</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; for rhy = (next pat)</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; for off = (pick '(.25 .5 .75))</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; do</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; (send "mp:midi" :key (- 60 24) :dur rhy)</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; (send "mp:midi" :key (- (pick '(67 68 70 72)) 12) :dur rhy)</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; (send "mp:midi" :time off :key 63 :dur 1)</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; (send "mp:midi" :time off :key (pick '(67 68 70 72)) :dur 1)</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; (wait rhy)))</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div
 class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; first set the tempo to bpm = 60,
 then sprout it. &nbsp;It should sound</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; as expected.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro 60)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(sprout (time-user ) (sync ))</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; however, if we change the tempo to bpm = 90, the rhythm sounds off.</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; This is because of the issue described above.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro 90)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; set the
 tempo back to 60</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro 60)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(stop )</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; let's redefine our process to use metro-dur() and fix this</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(define* (time-user (m *metro*))</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; (process&nbsp;</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; with pat = (make-cycle '(2 1 .5 .25 .25))</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; for rhy = (next pat)</div><div
 class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; for off = (pick '(.25 .5 .75))</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; do</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; (send "mp:midi" :key (- 60 24) :dur (metro-dur rhy m))</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; (send "mp:midi" :key (- (pick '(67 68 70 72)) 12) :dur (metro-dur rhy m))</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; (send "mp:midi" :time off :key 63 :dur (metro-dur 1))</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; (send "mp:midi" :time off :key (pick '(67 68 70 72)) :dur (metro-dur 1))</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; (wait rhy)))</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; try sprouting now</div><div
 class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(sprout (time-user ) (sync ))</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; and change the tempo</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro 90)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro 40 5)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(stop )</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">;</div><div class="yiv820766509yui_3_2_0_26_132199474583077">;; Using Multiple Metronomes</div><div class="yiv820766509yui_3_2_0_26_132199474583077">;</div><div
 class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; let's use two different processes while using two different metros</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; we'll redefine our dvorak() process with a few slight adjustments,</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; including the use of metro-dur()</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(define* (dvorak (m *metro*))</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; (process&nbsp;</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; with mel = (plus (key '(a4 bf4 a4 g4 f4 e4 d4 bf2 d3 f4 e4 f4 d4 g2 d3&nbsp;</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;f4 e4 d4
 e4 a2 e4 f4 e4 f4 d4 d3 a3 d4 f4 g4)) 9)</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; with pat = (make-cycle (concat mel mel (plus 12 mel) (plus 12 mel)))&nbsp;</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; with dur</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; for k = (next pat)</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; do</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; (send "mp:midi" :key k :dur (metro-dur 1/4 m))</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; (wait 1/4)))</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; Check that we already have a custom metronome existing</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div
 class="yiv820766509yui_3_2_0_26_132199474583077">(metro? mymetro)</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; or</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metros )</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; set the default metro and sprout our pathetic() process</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro 80)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(sprout (pathetic ) (sync ))</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; now, set mymetro to the same tempo</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div
 class="yiv820766509yui_3_2_0_26_132199474583077">(metro 80 :metro mymetro)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; sprout our dvorak() process using this metronome</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(sprout (dvorak mymetro) (sync :metro mymetro))</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; notice that the two metronomes are not aligned. &nbsp;We created them at</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; different times, and set their tempos at different times, so we</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; can't expect them to be in sync.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; we
 can SYNC these two metronomes by calling metro-sync().</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro-sync mymetro)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; metro-sync() takes a metronome that will be pushed or pulled in order</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; to align a beat with another master-metronome. the master-metro is</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; by default the global *metro*.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; force the metronomes out of sync for a moment.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro 20 :metro mymetro)</div><div
 class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro 80 :metro mymetro)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; now we'll sync them again.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro-sync mymetro 10 :master-metro *metro*)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; above, you can see how I indicated the master-metro. if you want to</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; sync to a metro other than the global, this is how you indicate it.</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; the second number (10) means that the two metronomes will complete</div><div
 class="yiv820766509yui_3_2_0_26_132199474583077">; the sync 10 beats later (10 beats according to the master-metro).</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">;</div><div class="yiv820766509yui_3_2_0_26_132199474583077">;; Change Tempo while maintaining alignment</div><div class="yiv820766509yui_3_2_0_26_132199474583077">;</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; Notice that changing the tempo normally will cause the</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; metronome to go out of alignment with the other metro. &nbsp;See here:</div><div class="yiv820766509yui_3_2_0_26_132199474583077">.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro 40 2 :metro mymetro)</div><div
 class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; bring the tempo back up</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro 80 2 :metro mymetro)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; If we change the tempo using the "tempo:" keyword in metro-sync(),</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; we can
 prevent the metronomes from going out of alignment. This will</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; guarantee that by the time mymetro has reached its goal tempo, its</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; beats will still align with the master metronome. this slowdown will</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; take place over 5 beats</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro-sync mymetro 5 :tempo 40 :master-metro *metro*)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; now we can speed up mymetro back to normal tempo and still</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; maintain alignment with the other metro. This speed up take</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; place over 2
 beats.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro-sync mymetro 2 :tempo 80)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; note that if we want to alter the global metronome, we should</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; indicate what the master metronome will be. &nbsp;If we do NOT indicate</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; the master metronome, metro-sync() will automatically choose the</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; first created user metronome as master. While this may seem strange,</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; if we only have two metronomes (the user metronome, and the global),</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; then it will correctly choose the
 only existing user metro.</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; notice:</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro-sync *metro* :tempo 40)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; Note that the transistion time for the above tempo change and sync</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; was over the course of 1 beat. &nbsp;1 is the default value if none is</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; specified.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; But to be clear, you will probably want to explicitly indicate</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; the master-metro if *metro* is the one to be altered.</div><div
 class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro-sync *metro* :tempo 80 :master-metro mymetro)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; beats can be indicated by
 keyword</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro-sync *metro* :beats 4 :tempo 40)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; one can indicate seconds instead, if desired</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro-sync *metro* :secs 2 :tempo 80)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; metro-sync makes no presumption that the tempos of the two</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; metronomes are equal, or are related by being twice as fast or slow.</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; The tempos can be completely unrelated. &nbsp;all that this function</div><div
 class="yiv820766509yui_3_2_0_26_132199474583077">; ensures is that after a certain number of beats, there will be</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; a coinciding beat between the two metros. &nbsp;</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; for example, we know that the global metro is at bpm = 80. &nbsp;if</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; we set mymetro to bpm = 80 / 3, and sync them over 1 beat, then</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; 1 beat later BOTH metros will align AT LEAST for that beat, then</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; they will continue on with their respective tempos.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro-sync mymetro :tempo (/ 80 3))</div><div
 class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; but of course, once these metros align, they are in a 1 to 3</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; relationship. &nbsp;Let's try
 another tempo ratio:</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro-sync mymetro :tempo (* 80 2/3))</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(stop )</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; Note that metro-sync(), as well as metro-phase() explained below,</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; both return #t when evaluated, as displayed in your console</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; window. Both functions will return #f if they have decided</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; to do nothing. This will happen if you try to execute phases</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; or syncs rapidly in succession. trying
 to sync two metronomes</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; before a previous sync was completed will
 result in no action</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; being taken, and #f being returned by the function.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; #f will also be return by metro-sync() if the metronomes are</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; already in sync and no adjustment is necessary.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">;</div><div class="yiv820766509yui_3_2_0_26_132199474583077">;; Playing Reich's Piano Phase Manually</div><div class="yiv820766509yui_3_2_0_26_132199474583077">;</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">;
 let's define Reich's piano-phase to take advantage of metro-dur().</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; we'll also pass in the
 metronome we're using as an argument</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; so that metro-dur() is using the correct metronome</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(define* (piano-phase (m *metro*)) ;(&amp;optkey m = *metro*)</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; (process&nbsp;</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; with pat = (make-cycle '(e4 fs4 b4 cs5 d5 fs4 e4 cs5 b4 fs4 d5 cs5))</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; for k = (key (next pat))</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; do</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; (send "mp:midi" :key k :dur (metro-dur 1/4 m))</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; &nbsp; (wait 1/4)))</div><div
 class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; first, let's start the processes at the same tempo, and in sync.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro 100)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro-sync mymetro :tempo 100)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(begin</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; (sprout (piano-phase ) (sync ))</div><div class="yiv820766509yui_3_2_0_26_132199474583077">&nbsp; (sprout (piano-phase mymetro) (sync :metro mymetro)))</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div
 class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; one can play Reich's piano phase manually by using</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; metro-phase(). &nbsp;metro-phase() takes two beat values -&gt;
 the second</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; value is the number of beats that would normally occur. this is the</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; space into which you will fit a different number of beats as</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; indicated by the first value.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; for example. &nbsp;metro-phase(5.25, 5, *metro*), means to take the</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; global metronome and over what would normally be the next 5 beats,</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; speed up the tempo slightly so that 5.25 beats occur instead.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro-phase 5.25 5)</div><div
 class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; *metro* is the default metronome,
 as usual.</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; Here we cause the metronome to slow down slightly, so that fewer</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; beats occur (4.75) in the space of 5 beats.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro-phase 4.75 5)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; this transition take twice as long, and is more gradual.</div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro-phase 10.25 10 mymetro)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; this transition is rather sudden</div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro-phase 1.25 1 :metro mymetro)</div><div
 class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; of course, you can "phase" by any amount you want</div><div class="yiv820766509yui_3_2_0_26_132199474583077">(metro-phase 32 30 :metro mymetro)</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">; remember to watch your console window. if you start a phase that</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; will take a long time, and you try to phase before the first phase</div><div class="yiv820766509yui_3_2_0_26_132199474583077">; is completed, the console window will display #f -&gt; false.</div><div class="yiv820766509yui_3_2_0_26_132199474583077"><br></div><div class="yiv820766509yui_3_2_0_26_132199474583077">(stop )</div></div> </div>  </div></div></div><br><br> </div> </div>  </div></body></html>