<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Puredata external - sending messages and setting variables]]></title><description><![CDATA[<p>Every once in a while, I come to having to program an external which ends up having some specific variables, which I'd prefer being set &quot;internally&quot; instead of exposing them through outlets, mostly to reduce clutter. And unfortunately, that is usually not easily visible in <a href="https://github.com/pure-data/externals-howto" rel="nofollow">https://github.com/pure-data/externals-howto</a> ...</p>
<p>So, I'm not really sure if the below is the &quot;correct&quot; thing - I just managed to patch it together by reading from the PD source.</p>
<p>You can find the code in:</p>
<ul>
<li><a href="https://sourceforge.net/p/sdaaubckp/code/HEAD/tree/xtra/puredata/external-sendtest/" rel="nofollow">https://sourceforge.net/p/sdaaubckp/code/HEAD/tree/xtra/puredata/external-sendtest/</a></li>
</ul>
<p>The help patch looks like this:</p>
<p><img src="/uploads/files/1543139561980-sendtest-help.png" alt="sendtest-help.png" class="img-responsive img-markdown" /></p>
<p>Basically, this is a copy of <code>[send]</code>, which when banged, triggers <code>r AHA</code> and <code>r EHE</code> - even if there aren't corresponding send objects. It turns out, there must be a <code>pd_bind</code> in order for this to work, and for a long time I thought the object argument there is the sender object - but actually it seems to be the <em>receiving</em> object reference. So this objects includes an additional &quot;dummy&quot; receiver class, a copy of <code>[receive]</code>, which is there simply to initialize this binding, once this is done, other normal <code>[receive]</code> objects begin reacting on messages too.</p>
<p>Now I noticed I don't actually have the code for setting <code>[value]</code> variables there, but it is easier - you simply declare a symbol, and then you call PD functions on it:</p>
<pre><code>  t_symbol* s_mysimbol;
  ...
  x-&gt;s_mysimbol    = gensym(&quot;myvar&quot;);
  ...
  // initialize/instantiate the [value] variables (reading is with value_getfloat)
  // note - via value_get, these will also gain non-null -&gt;s_thing property
  value_get(x-&gt;s_mysimbol);
  ...
  value_setfloat(x-&gt;s_mysimbol, 42);
  ...
  value_release(x-&gt;s_mysimbol);
</code></pre>
]]></description><link>http://forum.pdpatchrepo.info/topic/11779/puredata-external-sending-messages-and-setting-variables</link><generator>RSS for Node</generator><lastBuildDate>Wed, 09 Sep 2026 06:15:37 GMT</lastBuildDate><atom:link href="http://forum.pdpatchrepo.info/topic/11779.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 25 Nov 2018 10:01:08 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Puredata external - sending messages and setting variables on Sun, 25 Nov 2018 10:02:05 GMT]]></title><description><![CDATA[<p>Every once in a while, I come to having to program an external which ends up having some specific variables, which I'd prefer being set &quot;internally&quot; instead of exposing them through outlets, mostly to reduce clutter. And unfortunately, that is usually not easily visible in <a href="https://github.com/pure-data/externals-howto" rel="nofollow">https://github.com/pure-data/externals-howto</a> ...</p>
<p>So, I'm not really sure if the below is the &quot;correct&quot; thing - I just managed to patch it together by reading from the PD source.</p>
<p>You can find the code in:</p>
<ul>
<li><a href="https://sourceforge.net/p/sdaaubckp/code/HEAD/tree/xtra/puredata/external-sendtest/" rel="nofollow">https://sourceforge.net/p/sdaaubckp/code/HEAD/tree/xtra/puredata/external-sendtest/</a></li>
</ul>
<p>The help patch looks like this:</p>
<p><img src="/uploads/files/1543139561980-sendtest-help.png" alt="sendtest-help.png" class="img-responsive img-markdown" /></p>
<p>Basically, this is a copy of <code>[send]</code>, which when banged, triggers <code>r AHA</code> and <code>r EHE</code> - even if there aren't corresponding send objects. It turns out, there must be a <code>pd_bind</code> in order for this to work, and for a long time I thought the object argument there is the sender object - but actually it seems to be the <em>receiving</em> object reference. So this objects includes an additional &quot;dummy&quot; receiver class, a copy of <code>[receive]</code>, which is there simply to initialize this binding, once this is done, other normal <code>[receive]</code> objects begin reacting on messages too.</p>
<p>Now I noticed I don't actually have the code for setting <code>[value]</code> variables there, but it is easier - you simply declare a symbol, and then you call PD functions on it:</p>
<pre><code>  t_symbol* s_mysimbol;
  ...
  x-&gt;s_mysimbol    = gensym(&quot;myvar&quot;);
  ...
  // initialize/instantiate the [value] variables (reading is with value_getfloat)
  // note - via value_get, these will also gain non-null -&gt;s_thing property
  value_get(x-&gt;s_mysimbol);
  ...
  value_setfloat(x-&gt;s_mysimbol, 42);
  ...
  value_release(x-&gt;s_mysimbol);
</code></pre>
]]></description><link>http://forum.pdpatchrepo.info/topic/11779/puredata-external-sending-messages-and-setting-variables</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/11779/puredata-external-sending-messages-and-setting-variables</guid><dc:creator><![CDATA[sdaau_ml]]></dc:creator><pubDate>Sun, 25 Nov 2018 10:02:05 GMT</pubDate></item></channel></rss>