<html><head></head><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px"><div id="yiv0560497119"><div id="yui_3_16_0_ym19_1_1475112559273_5899"><div id="yui_3_16_0_ym19_1_1475112559273_5898" style="color:#000;background-color:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px;"><div id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_16958">> So having a look at the source code I'd say what would happen is that <br clear="none"></div><div id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_17011">> the second block prints the samples of the sound file.</div><div id="yui_3_16_0_ym19_1_1475112559273_5903" class="yiv0560497119qtdSeparateBR"><br clear="none"><br clear="none"></div></div></div></div><div id="yui_3_16_0_ym19_1_1475112559273_5914" class=".yiv0560497119yahoo_quoted"><div id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_16918" style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px;"><div id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_16917" style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px;"><div class="yiv0560497119y_msg_container" id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_17014"><div id="yiv0560497119"><div id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_17013"><div id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_17012" style="color:#000;background-color:#fff;font-family:Helvetica Neue-Light, Helvetica Neue Light, Helvetica Neue, Helvetica, Arial, Lucida Grande, Sans-Serif;font-size:16px;"><div dir="ltr" id="yiv0560497119yui_3_16_0_ym19_1_1474984311787_193354"><br clear="none"></div><div dir="ltr" id="yiv0560497119yui_3_16_0_ym19_1_1474984311787_193354"><div id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_17015">> I guess the point you are trying to make here is that a threaded version <br clear="none"></div><div id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_17016">> of [fft~], the perform routing should block if the samples are not ready in <br clear="none"></div><div id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_17017">> time. That sounds perfectly plausible (and doable) to me.</div></div><div dir="ltr" id="yiv0560497119yui_3_16_0_ym19_1_1474984311787_193354"><div id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_17018">> Or am I missing your point?</div><div><br clear="none"></div><div id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_23028">That's right.  But on the broader scale I'm pointing out how easy it is to <br clear="none"></div><div dir="ltr" id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_23114">overlook determinism in these cases.</div></div><div class="qtdSeparateBR"><br></div><div class="yiv0560497119yqt1455414539" id="yiv0560497119yqtfd41836"><div dir="ltr" id="yiv0560497119yui_3_16_0_ym19_1_1474984311787_193354"><div id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_18316">> I'd add that right now, if the system cannot compute an FFT on time and it <br clear="none"></div><div id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_17041">> causes dropouts, you have to solve that by increasing Pd's delay. With a <br clear="none"></div><div id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_17047">> threaded implementation, you could add a delay for that specific subpatch instead of the whole of Pd.</div></div><div dir="ltr" id="yiv0560497119yui_3_16_0_ym19_1_1474984311787_193354"><div id="yui_3_16_0_ym19_1_1475112559273_7094"><br clear="none"></div><div id="yui_3_16_0_ym19_1_1475112559273_7095">I'm having trouble seeing how that would work in practice.  Would the <br></div><div id="yui_3_16_0_ym19_1_1475112559273_7096" dir="ltr">user specify the delay in ms/blocks as an argument?<br></div><div id="yui_3_16_0_ym19_1_1475112559273_7097"><br clear="none"></div></div><div dir="ltr" id="yiv0560497119yui_3_16_0_ym19_1_1474984311787_193354">> Giulio</div><div class="yiv0560497119qtdSeparateBR" id="yiv0560497119yui_3_16_0_ym19_1_1474984311787_193358"><br clear="none"></div><div class="yiv0560497119yqt1808182356" id="yiv0560497119yqt41866"><div class="yiv0560497119yahoo_quoted" id="yiv0560497119yui_3_16_0_ym19_1_1474984311787_193205" style="display:block;"> <blockquote id="yiv0560497119yui_3_16_0_ym19_1_1474984311787_193204" style="border-left:2px solid rgb(16, 16, 255);margin-left:5px;margin-top:5px;padding-left:5px;"> <div id="yiv0560497119yui_3_16_0_ym19_1_1474984311787_193203" style="font-family:Helvetica Neue-Light, Helvetica Neue Light, Helvetica Neue, Helvetica, Arial, Lucida Grande, Sans-Serif;font-size:16px;"> <div id="yiv0560497119yui_3_16_0_ym19_1_1474984311787_193202" style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, Sans-Serif;font-size:16px;"> <div dir="ltr" id="yiv0560497119yui_3_16_0_ym19_1_1474984311787_193359"> <font id="yiv0560497119yui_3_16_0_ym19_1_1474984311787_193364" face="Arial" size="2"> </font><hr id="yiv0560497119yui_3_16_0_ym19_1_1474984311787_193363" size="1"> <b><span style="font-weight:bold;">From:</span></b> Jonathan Wilkes <jancsika@yahoo.com><br clear="none"> <b><span style="font-weight:bold;">To:</span></b> Giulio Moro <giuliomoro@yahoo.it>; Pd-List <pd-list@lists.iem.at> <br clear="none"> <b><span style="font-weight:bold;">Sent:</span></b> Wednesday, 28 September 2016, 23:00<br clear="none"> <b><span style="font-weight:bold;">Subject:</span></b> Re: [PD] Threading in Pd/libpd<br clear="none">  </div> <div class="yiv0560497119y_msg_container" id="yiv0560497119yui_3_16_0_ym19_1_1474984311787_193201"><br clear="none"><div id="yiv0560497119"><div id="yiv0560497119yui_3_16_0_ym19_1_1474984311787_193200"><div id="yiv0560497119yui_3_16_0_ym19_1_1474984311787_193199" style="color:#000;background-color:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px;"><div id="yiv0560497119"><div id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_3158"><div id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_3157" style="color:#000;background-color:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px;">> Thanks Jonathan.<br clear="none"></div></div></div><div id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_3179"><div id="yiv0560497119yui_3_16_0_ym19_1_1475094593298_4140" style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px;"><div id="yiv0560497119yui_3_16_0_ym19_1_1475094593298_4139" style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px;"><div class="yiv0560497119y_msg_container" id="yiv0560497119yui_3_16_0_ym19_1_1475094593298_4138"><br clear="none">> Also [readsf~] supports threading and so do [udpsend] and [udpreceive], for obvious reasons involving system calls.<br clear="none"><br clear="none">>> Can you guarantee that the revisions you've implemented generate the same output as Pd Vanilla, for all cases?<br clear="none"><br clear="none"><div id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_3225">> I'd rather say it does not, in all cases. At the very least there is going to be a delay involved. But, if this brings to a different behaviour, yet still deterministic, would that be bad? After all, the above mentioned objects are not deterministic themselves, yet they are widely used, with a very high success rate.</div><div id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_4416"><br clear="none"></div><div dir="ltr" id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_4469">udpsend and udpreceive are special cases because the protocol itself rules out the kind of determinism we're discussing. <br clear="none"></div><div dir="ltr" id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_4523"><div id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_4522"><br clear="none"></div><div id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_4668">So let's focus on readsf~ instead.</div></div><div dir="ltr" id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_4318"><br clear="none"></div><div dir="ltr" id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_4697"><div id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_4696">Suppose readsf~ is reading a sound file and outputs 3 blocks-- block 1, block 2, and block 3.  The patch is outputting the sound file to the sound card, so we are <br clear="none"></div><div dir="ltr" id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_4823">listening to the sound file as Pd is running.</div><div dir="ltr" id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_4824"><br clear="none"></div><div dir="ltr" id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_4898">Now, imagine this happens:</div><div dir="ltr" id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_4899"><br clear="none"></div><div dir="ltr" id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_4905">1st block: readsf~ perform routine finishes in time to output a block to the soundcard on schedule.<br clear="none"></div><div dir="ltr" id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_4906">2nd block: perform routine takes longer to compute, and it misses the deadline set for the next block to be delivered to the soundcard.  So we hear a dropout.</div><div dir="ltr" id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_4907">3rd block: perform routine finishes in time to meet the deadline.</div><div dir="ltr" id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_4956"><br clear="none"></div><div dir="ltr" id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_4913">Now, suppose we were debugging our patch by outputting each block of samples <br clear="none"></div><div dir="ltr" id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_4928">to the console.  Here's the question, then: what gets printed for the 2nd block?  <br clear="none"></div><div dir="ltr" id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_4929">Does Pd print out the samples from the sound file that missed the deadline, or <br clear="none"></div><div dir="ltr" id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_4930">does it print out 64 zeroes?</div><div class="yiv0560497119yqt7815282857" id="yiv0560497119yqtfd88128"><div dir="ltr" id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_5013"><br clear="none"></div><div dir="ltr" id="yiv0560497119yui_3_16_0_ym19_1_1475099473348_4932">-Jonathan<br clear="none"></div></div></div></div><div class="yiv0560497119yqt7815282857" id="yiv0560497119yqtfd13149"><div class="yiv0560497119qtdSeparateBR"><br clear="none"><br clear="none"></div><div class="yiv0560497119yqt8853332613" id="yiv0560497119yqtfd99640"> </div></div></div><div class="yiv0560497119yqt7815282857" id="yiv0560497119yqtfd44630"><div class="yiv0560497119yqt8853332613" id="yiv0560497119yqtfd60275"> </div></div></div><div class="yiv0560497119yqt7815282857" id="yiv0560497119yqtfd18028"><div class="yiv0560497119yqt8853332613" id="yiv0560497119yqtfd39008">  </div></div></div></div></div></div><br clear="none"><br clear="none"></div> </div> </div> </blockquote> </div></div></div></div></div></div><div class="yiv0560497119yqt1455414539" id="yiv0560497119yqtfd95615"><br clear="none"><br clear="none"></div></div><div class="yiv0560497119yqt1455414539" id="yiv0560497119yqtfd46423"> </div></div><div class="yiv0560497119yqt1455414539" id="yiv0560497119yqtfd68146"> </div></div><div class="yiv0560497119yqt1455414539" id="yiv0560497119yqtfd09144">  </div></div></div></body></html>