<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 <<a href="mailto:heuermh@gmail.com">heuermh@gmail.com</a>> 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 => 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 => now;</div>
<div class="">42 => centralpos;</div>
<div class=""><br class="">
</div>
<div class="">2::second => now;</div>
<div class="">0 => centralpos;</div>
<div class=""><br class="">
</div>
<div class=""><<<"done">>>;</div>
<div class=""><br class="">
</div>
<div class="">fun void doSomething()</div>
<div class="">{</div>
<div class=""> while (true)</div>
<div class=""> {</div>
<div class=""> if (centralpos == 42)</div>
<div class=""> {</div>
<div class=""> <<<"hello from doSomething!">>>;</div>
<div class=""> }</div>
<div class=""> 250::ms => now;</div>
<div class=""> }</div>
<div class="">}</div>
<div class=""><br class="">
</div>
<div class="">fun void doSomethingElse()</div>
<div class="">{</div>
<div class=""> while (true)</div>
<div class=""> {</div>
<div class=""> if (centralpos == 42)</div>
<div class=""> {</div>
<div class=""> <<<"hello from doSomethingElse!">>>;</div>
<div class=""> }</div>
<div class=""> 500::ms => now;</div>
<div class=""> }</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=""> 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 <<a href="mailto:hverb54@hotmail.com" class="">hverb54@hotmail.com</a>> 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 ("70000")to buf.pos as a central position in my soundbuffer and i let my function LFOtoPOS circle around
it. </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 "spork" instruction has started the process i can't figure out how to addresss the argument "centralpos" to change it on the fly or by another function or parameter. 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="">
<span class="">me.sourceDir() + "sound.wav" => string filename;<br class="">
</span>
<div class="">if( me.args() ) me.arg(0) => filename;<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">SndBuf buf => dac;<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">filename => buf.read;<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">1 => buf.pos;<br class="">
</div>
<div class="">.5 => 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=""> TriOsc lfo => blackhole;<br class="">
</div>
<div class=""> 1 => lfo.freq;<br class="">
</div>
<div class=""> centralpos => buf.pos;<br class="">
</div>
<div class=""> while (true)<br class="">
</div>
<div class=""> {<br class="">
</div>
<div class=""> 1::samp => now;<br class="">
</div>
<div class=""> (10000*lfo.last())$ int => buf.pos;<br class="">
</div>
<div class=""> }<br class="">
</div>
<div class="">}<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">// time loop <span class="Apple-converted-space"> </span><br class="">
</div>
<div class="">while( true )<br class="">
</div>
<div class="">{ <br class="">
</div>
<div class=""> 1000::ms => 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>