2008/5/22 Peter Todd &lt;<a href="mailto:chuck@xinaesthetic.net">chuck@xinaesthetic.net</a>&gt;:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I&#39;d suggest it can even be generalised a little more than Kassen has
described; grains may be purely synthesised, rather than using a signal
in a buffer. </blockquote><div><br>Yes! Shakers are great for this.<br><br>The following simple example uses a set of parallel shakers. Each is playing a random harmonic of the current note and is retriggered after a amount of time that&#39;s a sub-harmonic of the current pitch. The result is a sort of random-ish noise that still conveys a hint of melody. I added some volume modulation to spice it up. To demonstrate how different sounds can still get a perception of pitch across the sounds used are randomised every time the code is run.<br>
<br>No waranties, no refunds.<br>Please copy, please remix.<br><br>====================<br>8 =&gt; int grains;<br><br>64 =&gt; int root;<br>root =&gt; int note;<br>[0, 3, 9, 5, 7] @=&gt; int melody[];<br><br>//a different sound every time we play it!<br>
Std.rand2(0,22) =&gt; int offset;<br>now =&gt; time start;<br><br><br><br>repeat(grains) spork ~synth();<br>me.yield();<br><br><br>while(1)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; for ( 0=&gt; int n; n &lt; melody.cap(); n++)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; root + melody[n] =&gt; note;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 4::second =&gt; now;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; }<br><br><br>fun void synth()<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; Shakers s =&gt; dac;<br>&nbsp;&nbsp;&nbsp; <a href="http://me.id">me.id</a>() + offset =&gt; s.preset;<br><br>&nbsp;&nbsp;&nbsp; while(9)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //the &quot;*1.0&quot; is just to force the fraction into becoming a float<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Std.mtof(note) * (&nbsp; (Std.rand2(1,3)* 1.0) / Std.rand2(1, 2) )=&gt; s.freq;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //add volume modulation<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; s.noteOn( ((now - start)% second) /second);<br><br>&nbsp;&nbsp;&nbsp;&nbsp; //the time betwee triggers affects the perception of pitch<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Std.rand2(8, 16)::second / Std.mtof(note) =&gt; now;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; }<br></div></div>========================<br><br>Cheers,<br>Kas.<br>