<?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[ReadArray Issue]]></title><description><![CDATA[<p>I'm a bit new to LibPD (and PD in general) so please be gentle on me. I've asked this question in the Create Digital Music forum as well, didn't get much response.</p>
<p>I've built a little test patch to try to grab some fft data from an array and am having some problems. The patch is pretty damn simple and it seems to work as expected in the PD editor. I'm seeing array data show up in the table display, however when I try to grab it from the client side (Java code in this case) the array is filled with 0's.</p>
<p>Here's a shot of the patch I'm using:</p>
<p><img src="/uploads/files/upload-1bc9de93-cc5c-4026-b874-69ce7777430c.JPG" alt="pd_patch.JPG" class="img-responsive img-markdown" /></p>
<p>and the test code in question:</p>
<p>float[] fftData = new float[32];<br />
PdBase.sendBang(&quot;calculateFFT&quot;);<br />
PdBase.readArray(fftData, 0, &quot;fft&quot;, 0, 32);<br />
for(int i = 0; i &lt; fftData.length; i++) {<br />
System.out.println(fftData[i]);<br />
}</p>
<p>Couldn't be simpler, right? This is wired to a button press, so I can arbitrarily fire it whenever. The audio is already loaded and playing fine at this point. Both the bang and the readArray are returning 0 so it appears that all the communication is working fine. However, I end up with an array full of 0's! Am I missing something? Interestingly I do get one chunk of actual data the first time when I keep &quot;save contents&quot; selected in the patch, which seems to be expected. Also, the tabwrite connected bang is definitely working correctly when I run the patch in PD, the &quot;fft&quot; array gets filled with new data every time I press it.</p>
<p>I assume there's something stupid I'm doing wrong here since I'm so new to this.!</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/8797/readarray-issue</link><generator>RSS for Node</generator><lastBuildDate>Sun, 10 May 2026 23:54:17 GMT</lastBuildDate><atom:link href="http://forum.pdpatchrepo.info/topic/8797.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 18 Nov 2014 20:13:08 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to ReadArray Issue on Tue, 18 Nov 2014 20:13:08 GMT]]></title><description><![CDATA[<p>I'm a bit new to LibPD (and PD in general) so please be gentle on me. I've asked this question in the Create Digital Music forum as well, didn't get much response.</p>
<p>I've built a little test patch to try to grab some fft data from an array and am having some problems. The patch is pretty damn simple and it seems to work as expected in the PD editor. I'm seeing array data show up in the table display, however when I try to grab it from the client side (Java code in this case) the array is filled with 0's.</p>
<p>Here's a shot of the patch I'm using:</p>
<p><img src="/uploads/files/upload-1bc9de93-cc5c-4026-b874-69ce7777430c.JPG" alt="pd_patch.JPG" class="img-responsive img-markdown" /></p>
<p>and the test code in question:</p>
<p>float[] fftData = new float[32];<br />
PdBase.sendBang(&quot;calculateFFT&quot;);<br />
PdBase.readArray(fftData, 0, &quot;fft&quot;, 0, 32);<br />
for(int i = 0; i &lt; fftData.length; i++) {<br />
System.out.println(fftData[i]);<br />
}</p>
<p>Couldn't be simpler, right? This is wired to a button press, so I can arbitrarily fire it whenever. The audio is already loaded and playing fine at this point. Both the bang and the readArray are returning 0 so it appears that all the communication is working fine. However, I end up with an array full of 0's! Am I missing something? Interestingly I do get one chunk of actual data the first time when I keep &quot;save contents&quot; selected in the patch, which seems to be expected. Also, the tabwrite connected bang is definitely working correctly when I run the patch in PD, the &quot;fft&quot; array gets filled with new data every time I press it.</p>
<p>I assume there's something stupid I'm doing wrong here since I'm so new to this.!</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/8797/readarray-issue</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/8797/readarray-issue</guid><dc:creator><![CDATA[jfred1979]]></dc:creator><pubDate>Tue, 18 Nov 2014 20:13:08 GMT</pubDate></item><item><title><![CDATA[Reply to ReadArray Issue on Wed, 29 Sep 2021 23:29:39 GMT]]></title><description><![CDATA[<p>I know this is old, but have you found a solution; because I'm having the same problem.</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/8797/readarray-issue/2</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/8797/readarray-issue/2</guid><dc:creator><![CDATA[MDobleZ]]></dc:creator><pubDate>Wed, 29 Sep 2021 23:29:39 GMT</pubDate></item><item><title><![CDATA[Reply to ReadArray Issue on Thu, 30 Sep 2021 00:04:39 GMT]]></title><description><![CDATA[<p>With zero experience in libpd+java i posit that your script is reading the array before it gets written. I assume that the two bang objects are triggered by the same message from your java UI?</p>
<p>In PD [tabwrite~] takes [blocksize~] samples to fill up the array with one block. And [rfft~] will output [blocksize~] samples in the time of exactly one block. If your array is set to the same size as your block, you introduce a similar delay in your java code between triggering the process and reading the array and you should be fine I think....</p>
<p>in other words (warning --&gt; pseudocode ahead</p>
<pre><code>float[] fftData = new float[32];
PdBase.sendBang(&quot;calculateFFT&quot;);
--&gt; get PD's BlockSize and SampleRate
--&gt; wait for BlockSize samples @ SampleRate
PdBase.readArray(fftData, 0, &quot;fft&quot;, 0, 32);
for(int i = 0; i &lt; fftData.length; i++) {
System.out.println(fftData[i]);
</code></pre>
]]></description><link>http://forum.pdpatchrepo.info/topic/8797/readarray-issue/3</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/8797/readarray-issue/3</guid><dc:creator><![CDATA[bocanegra]]></dc:creator><pubDate>Thu, 30 Sep 2021 00:04:39 GMT</pubDate></item><item><title><![CDATA[Reply to ReadArray Issue on Thu, 30 Sep 2021 18:02:10 GMT]]></title><description><![CDATA[<p>In my code, you do have that time difference and and in fact it &quot;sometimes&quot; does read the array. That's the crazy part; sometimes it works and sometimes it gives me a steady (though other than 0) value instead.</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/8797/readarray-issue/4</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/8797/readarray-issue/4</guid><dc:creator><![CDATA[MDobleZ]]></dc:creator><pubDate>Thu, 30 Sep 2021 18:02:10 GMT</pubDate></item><item><title><![CDATA[Reply to ReadArray Issue on Thu, 30 Sep 2021 19:00:06 GMT]]></title><description><![CDATA[<p>Now it's working, I had forgotten to include bangs onResume and onPause.</p>
]]></description><link>http://forum.pdpatchrepo.info/topic/8797/readarray-issue/5</link><guid isPermaLink="true">http://forum.pdpatchrepo.info/topic/8797/readarray-issue/5</guid><dc:creator><![CDATA[MDobleZ]]></dc:creator><pubDate>Thu, 30 Sep 2021 19:00:06 GMT</pubDate></item></channel></rss>