<?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[External i2c data reader leads to clicks, standalone version works better]]></title><description><![CDATA[<p>Hi there,</p>
<p>I'm running Pd on a cubieboard 2 (armf), together with jack in realtime mode.  In order to access an adc with i2c within Pd I created externals and it worked, but I couldn't find a way to get rid of clicks and pops when reading values in my audio patches with this setup..<br />
Then I made a standalone version of one of them to be launched in regular terminal, and got its output redirected to pdsend application (standalone, part of the pd package on linux platforms).  This saved my day, no more clicks, data is sampled from the standalone application and sent via TCP to pd, that retreives it with a [netreceive] object.  Next step will be integrating the pdsend program within my program, as advised by the authors.</p>
<p>My guess is that as I launch PD with a fairly high rt priority, the externals loaded in a patch do run with the same rt priority, leading to problems as my i2c port may have a significantly lower rt priority.  The point is that I want audio to be clean at all costs, but really don't need to read i2c data with such a time accuracy.</p>
<p>What do you think about it ?  Could my guess be right ?  I don't have an arduino, but I heard there are pd objects that do the job, is everything good ?  No cracks and pops I suppose ?</p>
<p>Note : it's not a matter of putting &quot;line&quot; objects in order to smooth out the commands here, really <img class="emoji emoji-extended" src="http://forum.pdpatchrepo.info/plugins/nodebb-plugin-emoji-extended/images/wink.png" title=";-)" alt=";-)" /></p>
<p>Thanx,</p>
<p>Nau</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/9489/external-i2c-data-reader-leads-to-clicks-standalone-version-works-better</link><generator>RSS for Node</generator><lastBuildDate>Sat, 13 Jun 2026 18:12:32 GMT</lastBuildDate><atom:link href="http://forum.pdpatchrepo.info/topic/9489.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 07 Sep 2015 21:48:50 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to External i2c data reader leads to clicks, standalone version works better on Mon, 07 Sep 2015 21:50:37 GMT]]></title><description><![CDATA[<p>Hi there,</p>
<p>I'm running Pd on a cubieboard 2 (armf), together with jack in realtime mode.  In order to access an adc with i2c within Pd I created externals and it worked, but I couldn't find a way to get rid of clicks and pops when reading values in my audio patches with this setup..<br />
Then I made a standalone version of one of them to be launched in regular terminal, and got its output redirected to pdsend application (standalone, part of the pd package on linux platforms).  This saved my day, no more clicks, data is sampled from the standalone application and sent via TCP to pd, that retreives it with a [netreceive] object.  Next step will be integrating the pdsend program within my program, as advised by the authors.</p>
<p>My guess is that as I launch PD with a fairly high rt priority, the externals loaded in a patch do run with the same rt priority, leading to problems as my i2c port may have a significantly lower rt priority.  The point is that I want audio to be clean at all costs, but really don't need to read i2c data with such a time accuracy.</p>
<p>What do you think about it ?  Could my guess be right ?  I don't have an arduino, but I heard there are pd objects that do the job, is everything good ?  No cracks and pops I suppose ?</p>
<p>Note : it's not a matter of putting &quot;line&quot; objects in order to smooth out the commands here, really <img class="emoji emoji-extended" src="http://forum.pdpatchrepo.info/plugins/nodebb-plugin-emoji-extended/images/wink.png" title=";-)" alt=";-)" /></p>
<p>Thanx,</p>
<p>Nau</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/9489/external-i2c-data-reader-leads-to-clicks-standalone-version-works-better</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/9489/external-i2c-data-reader-leads-to-clicks-standalone-version-works-better</guid><dc:creator><![CDATA[nau]]></dc:creator><pubDate>Mon, 07 Sep 2015 21:50:37 GMT</pubDate></item><item><title><![CDATA[Reply to External i2c data reader leads to clicks, standalone version works better on Tue, 08 Sep 2015 14:57:49 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-a" href="http://forum.pdpatchrepo.info/user/nau">@nau</a> How about using a thread in your external? Here's an external + thread template that I did a long time ago:<br />
<a href="http://www.workinprogress.ca/pure-data-external-pthread-template/" rel="nofollow">http://www.workinprogress.ca/pure-data-external-pthread-template/</a></p>
<p>Cheers~</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/9489/external-i2c-data-reader-leads-to-clicks-standalone-version-works-better/2</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/9489/external-i2c-data-reader-leads-to-clicks-standalone-version-works-better/2</guid><dc:creator><![CDATA[EEight]]></dc:creator><pubDate>Tue, 08 Sep 2015 14:57:49 GMT</pubDate></item><item><title><![CDATA[Reply to External i2c data reader leads to clicks, standalone version works better on Tue, 08 Sep 2015 20:35:37 GMT]]></title><description><![CDATA[<p>Thanks EEight,</p>
<p>this looks like exactly what I needed.  I'm gonna try it soon !</p>
<p>Nau</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/9489/external-i2c-data-reader-leads-to-clicks-standalone-version-works-better/3</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/9489/external-i2c-data-reader-leads-to-clicks-standalone-version-works-better/3</guid><dc:creator><![CDATA[nau]]></dc:creator><pubDate>Tue, 08 Sep 2015 20:35:37 GMT</pubDate></item><item><title><![CDATA[Reply to External i2c data reader leads to clicks, standalone version works better on Wed, 09 Sep 2015 18:02:10 GMT]]></title><description><![CDATA[<p>I think I'm gonna make it, but strangely enough I can't fin info about sys_lock() and sys_unlock() functions with search engines... can you tell me more about them ?<br />
Thank you again</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/9489/external-i2c-data-reader-leads-to-clicks-standalone-version-works-better/4</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/9489/external-i2c-data-reader-leads-to-clicks-standalone-version-works-better/4</guid><dc:creator><![CDATA[nau]]></dc:creator><pubDate>Wed, 09 Sep 2015 18:02:10 GMT</pubDate></item><item><title><![CDATA[Reply to External i2c data reader leads to clicks, standalone version works better on Wed, 09 Sep 2015 19:02:37 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-a" href="http://forum.pdpatchrepo.info/user/nau">@nau</a> The main idea is:</p>
<blockquote>
<p>The point is that in your secondary thread you are locking PD with sys_lock<br />
whenever you want to use PD API functions (like getbytes or outlet<br />
functions) and unlock it with sys_unlock when done. Clearly this time should<br />
be as short as possible. This ensures that your calls into PD happen when PD<br />
itself doesn't do that (as it is in &quot;idle&quot; state).</p>
</blockquote>
<p>From:<br />
<a href="http://markmail.org/search/?q=sys_lock&amp;q=list%3Aat.iem.pd-list#query:sys_lock%20list%3Aat.iem.pd-list+page:2+mid:xyejpscgjtqclasg+state:results" rel="nofollow">http://markmail.org/search/?q=sys_lock&amp;q=list%3Aat.iem.pd-list#query:sys_lock list%3Aat.iem.pd-list+page:2+mid:xyejpscgjtqclasg+state:results</a></p>
<p>Here's another external thread implementation: <a href="http://sourceforge.net/p/pure-data/svn/HEAD/tree/trunk/externals/bbogart/gphoto/" rel="nofollow">http://sourceforge.net/p/pure-data/svn/HEAD/tree/trunk/externals/bbogart/gphoto/</a></p>
<p>Cheers~</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/9489/external-i2c-data-reader-leads-to-clicks-standalone-version-works-better/5</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/9489/external-i2c-data-reader-leads-to-clicks-standalone-version-works-better/5</guid><dc:creator><![CDATA[EEight]]></dc:creator><pubDate>Wed, 09 Sep 2015 19:02:37 GMT</pubDate></item><item><title><![CDATA[Reply to External i2c data reader leads to clicks, standalone version works better on Wed, 09 Sep 2015 23:13:20 GMT]]></title><description><![CDATA[<p>Thank you.</p>
<p>I tried to compile it and got these lines :</p>
<pre><code>nau@labo:~/Bureau/threadtemplate$ make pd_linux 
cc -DPD -O2 -funroll-loops -fomit-frame-pointer -fPIC -Wall -W -Wshadow -Wstrict-prototypes -Wno-unused -Wno-parentheses -Wno-switch -I/usr/include -o threadtemplate.o -c threadtemplate.c
threadtemplate.c: In function ‘thread_read’:
threadtemplate.c:57:1: warning: no return statement in function returning non-void [-Wreturn-type]
ld -export_dynamic  -shared -o threadtemplate.pd_linux threadtemplate.o -lc -lpthread
ld: warning: cannot find entry symbol xport_dynamic; defaulting to 0000000000000740
strip --strip-unneeded threadtemplate.pd_linux
rm threadtemplate.o
</code></pre>
<p>and trying to create the object leads to a frozen pd (&quot;signalling pd....&quot; in console), same behaviour on a PC and on the cubie.<br />
I put a usleep(1000000); at line 55, this lowered the cpu but froze pd the same.</p>
<p>Any hint ?<br />
Thanks,</p>
<p>Nau</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/9489/external-i2c-data-reader-leads-to-clicks-standalone-version-works-better/6</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/9489/external-i2c-data-reader-leads-to-clicks-standalone-version-works-better/6</guid><dc:creator><![CDATA[nau]]></dc:creator><pubDate>Wed, 09 Sep 2015 23:13:20 GMT</pubDate></item><item><title><![CDATA[Reply to External i2c data reader leads to clicks, standalone version works better on Thu, 10 Sep 2015 12:34:09 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-a" href="http://forum.pdpatchrepo.info/user/nau">@nau</a> It is working on my box (linux, pd-extended). Some modifications to get rid of the warning and compilation problem.</p>
<pre><code>Makefile (line 79)
    ld --export-dynamic -shared -o $*.pd_linux $*.o -lc -lpthread
</code></pre>
<pre><code>threadtemplate.c (line 49)
void *thread_read(void *w)
</code></pre>
<p>This external will eat 100% of a core because the while(1) doesn't do any real work. So yes you could add a clock_interval or a simple uspleep.</p>
<p>You should see in the console something like:</p>
<pre><code>threadtemplate version 0.1
threadtemplate: thread 226944768 launched
</code></pre>
<p>Cheers~</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/9489/external-i2c-data-reader-leads-to-clicks-standalone-version-works-better/7</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/9489/external-i2c-data-reader-leads-to-clicks-standalone-version-works-better/7</guid><dc:creator><![CDATA[EEight]]></dc:creator><pubDate>Thu, 10 Sep 2015 12:34:09 GMT</pubDate></item><item><title><![CDATA[Reply to External i2c data reader leads to clicks, standalone version works better on Thu, 10 Sep 2015 06:59:29 GMT]]></title><description><![CDATA[<p>Thank you, can't wait to test that !</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/9489/external-i2c-data-reader-leads-to-clicks-standalone-version-works-better/8</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/9489/external-i2c-data-reader-leads-to-clicks-standalone-version-works-better/8</guid><dc:creator><![CDATA[nau]]></dc:creator><pubDate>Thu, 10 Sep 2015 06:59:29 GMT</pubDate></item><item><title><![CDATA[Reply to External i2c data reader leads to clicks, standalone version works better on Thu, 10 Sep 2015 23:22:00 GMT]]></title><description><![CDATA[<p>Sorry EEight,</p>
<p>this didn't work.  I got these lines : <img src="/uploads/files/1441922169816-selection_004.png" alt="Selection_004.png" class="img-responsive img-markdown" /> ,<br />
but the behaviour when creating a threadtemplate object in pd is the same, a freeze...<br />
As I don't see any error I don't know from where to start.</p>
<p>edit : the sys_lock() and sys_unlock() calls are what freezes everything.  Removing only the two of them framing the &quot;thread blablah launched&quot; post leads to a working external.  But I guess I lost exactly what I was looking for at the same time!</p>
<p>Nau</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/9489/external-i2c-data-reader-leads-to-clicks-standalone-version-works-better/9</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/9489/external-i2c-data-reader-leads-to-clicks-standalone-version-works-better/9</guid><dc:creator><![CDATA[nau]]></dc:creator><pubDate>Thu, 10 Sep 2015 23:22:00 GMT</pubDate></item><item><title><![CDATA[Reply to External i2c data reader leads to clicks, standalone version works better on Fri, 11 Sep 2015 01:14:01 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-a" href="http://forum.pdpatchrepo.info/user/nau">@nau</a> I am not an expert in threading, but maybe you do need multiple core after all?! If I have the time, I will try to run this external in my raspberry pi. Will get back to you.</p>
<p>Cheers~</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/9489/external-i2c-data-reader-leads-to-clicks-standalone-version-works-better/10</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/9489/external-i2c-data-reader-leads-to-clicks-standalone-version-works-better/10</guid><dc:creator><![CDATA[EEight]]></dc:creator><pubDate>Fri, 11 Sep 2015 01:14:01 GMT</pubDate></item><item><title><![CDATA[Reply to External i2c data reader leads to clicks, standalone version works better on Fri, 11 Sep 2015 07:16:55 GMT]]></title><description><![CDATA[<p>Cubieboard is dualcore, but maybe is it a matter of kernel ?  I'm not an expert neither.</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/9489/external-i2c-data-reader-leads-to-clicks-standalone-version-works-better/11</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/9489/external-i2c-data-reader-leads-to-clicks-standalone-version-works-better/11</guid><dc:creator><![CDATA[nau]]></dc:creator><pubDate>Fri, 11 Sep 2015 07:16:55 GMT</pubDate></item><item><title><![CDATA[Reply to External i2c data reader leads to clicks, standalone version works better on Tue, 15 Sep 2015 19:01:40 GMT]]></title><description><![CDATA[<p>Ok, I finally found the time to go ahead.</p>
<p>The threaded version of my i2c reading external seems to work very well (it seems that in my case there's no need for any sys_lock() sys_unlock() ).</p>
<p>The previous version of the external was written with a method for incoming bangs, and was meant to output 4 values each time it was banged. The higher the frequency of the connected metro, the higher the &quot;density&quot; of clicks'n pops.  This lead me to try a non-threaded version with no need of continuous banging... a single bang triggering  a while(1) loop, just to see if the threading was really needed.  But I never managed to do this...(signaling pd... again and again)  Maybe the thread is exactly what one needs in order to create externals based on the infinite loop principle...</p>
<p>Now I'll have to find a way to adapt the external used to write thing onto my lcd (every letter written makes noises in the audio).  As I read that opening/closing threads repeatedly is not very good I'll have to find a way to keep a thread open but still receive messages and bring them to the thread for writing characters, change position, cursor on/off etc.<br />
Should be easy for a coder...which I am not <img class="emoji emoji-extended" src="http://forum.pdpatchrepo.info/plugins/nodebb-plugin-emoji-extended/images/wink.png" title=";-)" alt=";-)" /></p>
<p>Thank you again,</p>
<p>Nau</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/9489/external-i2c-data-reader-leads-to-clicks-standalone-version-works-better/12</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/9489/external-i2c-data-reader-leads-to-clicks-standalone-version-works-better/12</guid><dc:creator><![CDATA[nau]]></dc:creator><pubDate>Tue, 15 Sep 2015 19:01:40 GMT</pubDate></item></channel></rss>