Thank you very much, tomorrow I'll look at your lines! Really kind<div><br></div><div><br><div class="gmail_quote">On Tue, Sep 25, 2012 at 11:37 PM, Michael Heuer <span dir="ltr"><<a href="mailto:heuermh@gmail.com" target="_blank">heuermh@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">Alberto Alassio wrote:<br>
<br>
> but what if I want to do this with 2 sines?<br>
><br>
> I mean, for example<br>
><br>
> Sineosc s1 that sounds and stop the same freq every 2 second, and another<br>
> Sineosc thats sound at the same freq every 1 second I can use while true and<br>
> put everthing in the bracklets. Right? Is it possible to do the same thing<br>
> also with the For structure you mentioned?<br>
><br>
> And what about<br>
><br>
> sineosc s1  at 220 hz that goes on and off every 2 seconds<br>
> sineosc s2 that has a random frequency ( std.rand2f for example )<br>
> How could I manage this situation with while?  I need while ( true ) to make<br>
> it in an infinite loop but I also need to make the random freq goes on!<br>
<br>
</div></div>If you do this<br>
<br>
SinOsc s1 => dac;<br>
220.0 => s1.freq;<br>
<div class="im">for (0 => int i; i < 10; i++)<br>
{<br>
</div>  0.2 => s1.gain;<br>
  2::second => now;<br>
  0.0 => s1.gain;<br>
  2::second => now;<br>
}<br>
<br>
SinOsc s2 => dac;<br>
<div class="im">for (0 => int i; i < 10; i++)<br>
{<br>
</div>  Std.rand2f(130.0, 440.0) => s2.freq;<br>
  0.2 => s2.gain;<br>
  2::second => now;<br>
  0.0 => s2.gain;<br>
  2::second => now;<br>
}<br>
<br>
then s2 will follow s1.<br>
<br>
If you want them to go simultaneously, then you'll need to put one or<br>
both loops in a function and spork the function call, for example<br>
<br>
SinOsc s1 => dac;<br>
220.0 => s1.freq;<br>
spork ~ loop1();<br>
<br>
SinOsc s2 => dac;<br>
spork ~ loop2();<br>
<br>
<<<"waiting on main shred">>>;<br>
2::minute => now;<br>
<br>
fun void loop1()<br>
{<br>
  <<<"sporked loop1">>>;<br>
<div class="im">  for (0 => int i; i < 10; i++)<br>
  {<br>
</div>    0.2 => s1.gain;<br>
    2::second => now;<br>
    0.0 => s1.gain;<br>
    2::second => now;<br>
  }<br>
  <<<"loop1 done">>>;<br>
}<br>
<br>
fun void loop2()<br>
{<br>
  <<<"sporked loop2">>>;<br>
<div class="im">  for (0 => int i; i < 10; i++)<br>
  {<br>
</div>    Std.rand2f(130.0, 440.0) => s2.freq;<br>
    0.2 => s2.gain;<br>
    2::second => now;<br>
    0.0 => s2.gain;<br>
    2::second => now;<br>
  }<br>
  <<<"loop2 done">>>;<br>
<div class="HOEnZb"><div class="h5">}<br>
<br>
   michael<br>
_______________________________________________<br>
chuck-users mailing list<br>
<a href="mailto:chuck-users@lists.cs.princeton.edu">chuck-users@lists.cs.princeton.edu</a><br>
<a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br>
</div></div></blockquote></div><br></div>