<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body dir="auto">
Thanks Michael, your example is very clarifying!
<div><br>
<br>
<div id="AppleMailSignature" dir="ltr">Verstuurd vanaf mijn iPad</div>
<div dir="ltr"><br>
Op 24 feb. 2020 om 05:14 heeft Michael Heuer &lt;<a href="mailto:heuermh@gmail.com">heuermh@gmail.com</a>&gt; het volgende geschreven:<br>
<br>
</div>
<blockquote type="cite">
<div dir="ltr">Hello Herman,
<div class=""><br class="">
</div>
<div class="">I don't think you need to pass values to the sporked functions.</div>
<div class=""><br class="">
</div>
<div class="">Scoping rules allow the sporked functions to access variables declared in their enclosing class, e.g.</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">0 =&gt; int centralpos;</div>
<div class=""><br class="">
</div>
<div class="">spork ~ doSomething();</div>
<div class="">spork ~ doSomethingElse();</div>
<div class=""><br class="">
</div>
<div class="">2::second =&gt; now;</div>
<div class="">42 =&gt; centralpos;</div>
<div class=""><br class="">
</div>
<div class="">2::second =&gt; now;</div>
<div class="">0 =&gt; centralpos;</div>
<div class=""><br class="">
</div>
<div class="">&lt;&lt;&lt;&quot;done&quot;&gt;&gt;&gt;;</div>
<div class=""><br class="">
</div>
<div class="">fun void doSomething()</div>
<div class="">{</div>
<div class="">&nbsp; while (true)</div>
<div class="">&nbsp; {</div>
<div class="">&nbsp; &nbsp; if (centralpos == 42)</div>
<div class="">&nbsp; &nbsp; {</div>
<div class="">&nbsp; &nbsp; &nbsp; &lt;&lt;&lt;&quot;hello from doSomething!&quot;&gt;&gt;&gt;;</div>
<div class="">&nbsp; &nbsp; }</div>
<div class="">&nbsp; &nbsp; 250::ms =&gt; now;</div>
<div class="">&nbsp; }</div>
<div class="">}</div>
<div class=""><br class="">
</div>
<div class="">fun void doSomethingElse()</div>
<div class="">{</div>
<div class="">&nbsp; while (true)</div>
<div class="">&nbsp; {</div>
<div class="">&nbsp; &nbsp; if (centralpos == 42)</div>
<div class="">&nbsp; &nbsp; {</div>
<div class="">&nbsp; &nbsp; &nbsp; &lt;&lt;&lt;&quot;hello from doSomethingElse!&quot;&gt;&gt;&gt;;</div>
<div class="">&nbsp; &nbsp; }</div>
<div class="">&nbsp; &nbsp; 500::ms =&gt; now;</div>
<div class="">&nbsp; }</div>
<div class="">}</div>
</div>
<div class=""><br class="">
</div>
<div class="">Do remember to advance time everywhere or things won't work correctly.</div>
<div class=""><br class="">
</div>
<div class="">Hope this helps!</div>
<div class=""><br class="">
</div>
<div class="">&nbsp; &nbsp;michael</div>
<div class=""><br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On Feb 21, 2020, at 2:11 AM, herman verbaeten &lt;<a href="mailto:hverb54@hotmail.com" class="">hverb54@hotmail.com</a>&gt; wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class="">
Hi,</div>
<div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class="">
<br class="">
</div>
<div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class="">
I'm in big trouble. I'v been trying for a long time now to change an argument in a running function. As you can see in my script i set a certain central pos (&quot;70000&quot;)to buf.pos&nbsp; as a central position in my soundbuffer and i let my function LFOtoPOS circle around
 it.&nbsp;</div>
<div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class="">
<br class="">
</div>
<div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class="">
Once the &quot;spork&quot; instruction has started the process i can't figure out how to addresss the argument &quot;centralpos&quot; to change it on the fly or by another function or parameter.&nbsp; Some help please ...</div>
<div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class="">
<br class="">
</div>
<div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class="">
Kind regards,</div>
<div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class="">
<br class="">
</div>
<div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class="">
Herman</div>
<div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class="">
----------------------------------------------------------------------------------------------</div>
<div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class="">
<br class="">
</div>
<div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class="">
&nbsp;<span class="">me.sourceDir() &#43; &quot;sound.wav&quot; =&gt; string filename;<br class="">
</span>
<div class="">if( me.args() ) me.arg(0) =&gt; filename;<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">SndBuf buf =&gt; dac;<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">filename =&gt; buf.read;<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">1 =&gt; buf.pos;<br class="">
</div>
<div class="">.5 =&gt; buf.gain;<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">spork ~ LFOtoPOS(70000);<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">fun void LFOtoPOS(int centralpos)<br class="">
</div>
<div class="">{<br class="">
</div>
<div class="">&nbsp; &nbsp; &nbsp;TriOsc lfo =&gt; blackhole;<br class="">
</div>
<div class="">&nbsp; &nbsp; &nbsp;1 =&gt; lfo.freq;<br class="">
</div>
<div class="">&nbsp; &nbsp; &nbsp;centralpos =&gt; buf.pos;<br class="">
</div>
<div class="">&nbsp; &nbsp; &nbsp;while (true)<br class="">
</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp;{<br class="">
</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp;1::samp =&gt; now;<br class="">
</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp;(10000*lfo.last())$ int =&gt; buf.pos;<br class="">
</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp;}<br class="">
</div>
<div class="">}<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">// time loop &nbsp;<span class="Apple-converted-space">&nbsp;</span><br class="">
</div>
<div class="">while( true )<br class="">
</div>
<div class="">{ &nbsp;<br class="">
</div>
<div class="">&nbsp; &nbsp;1000::ms =&gt; now;<br class="">
</div>
<div class="">}<br class="">
</div>
<div class=""><br class="">
</div>
<span class=""></span></div>
<span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">_______________________________________________</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">chuck-users
 mailing list</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<a href="mailto:chuck-users@lists.cs.princeton.edu" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">chuck-users@lists.cs.princeton.edu</a><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a></div>
</blockquote>
</div>
<br class="">
</div>
</div>
</blockquote>
<blockquote type="cite">
<div dir="ltr"><span>_______________________________________________</span><br>
<span>chuck-users mailing list</span><br>
<span><a href="mailto:chuck-users@lists.cs.princeton.edu">chuck-users@lists.cs.princeton.edu</a></span><br>
<span><a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a></span><br>
</div>
</blockquote>
</div>
</body>
</html>