<div dir="ltr">I am guessing that the n float (which is 64 bit, I think) gets downsampled to 16 bit resolution in the WvOut stream, which yields the variance you see (0.5 doesn&#39;t look that neat in base 16). I don&#39;t know an easy way around this, besides increasing the sample resolution or maybe try to chop the float in half and write it twice in the sample?<div>
<br></div><div>I too have been wondering about a simple file interface. One application is note sequences read dynamically from files. A wilder thought is ChucK programs generating new ChucK source code and sporking them. 8) The former can be solved by simply editing ChucK source code, but there may be situations when you want a cleaner file to edit.</div>
<div><br></div><div>/Stefan<br><br><div class="gmail_quote">On Thu, Aug 21, 2008 at 4:38 AM, Joel Matthys <span dir="ltr">&lt;<a href="mailto:jwmatthys@yahoo.com">jwmatthys@yahoo.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">






<div bgcolor="#ffffff">
<div><font face="Arial" size="2">Does ChucK a method of writing and reading ints, 
floats or strings from a file? The documentation</font></div>
<div><font face="Arial" size="2">only includes WvIn and WvOut for file 
I/O.</font></div>
<div><font face="Arial" size="2"></font>&nbsp;</div>
<div><font face="Arial" size="2">I hacked a technique for sending data by scaling it 
to values -1.0 to&nbsp;1.0 and sending it to a sound file:</font></div>
<div><font face="Arial" size="2"></font>&nbsp;</div>
<div><font face="Arial" size="2">//WRITE1.ck//</font></div>
<div><font face="Arial" size="2"></font>&nbsp;</div>
<div><font face="Arial" size="2">// write values to file</font></div>
<div><font face="Arial" size="2">Step x =&gt; WvOut file =&gt; blackhole;<br>&quot;data&quot; 
=&gt; file.sndFilename;<br>float n;<br>for (int ii; ii&lt;20; 
ii++)<br>{<br>&nbsp;ii/20.0 =&gt; n;<br>&nbsp;&lt;&lt;&lt; n 
&gt;&gt;&gt;;<br>&nbsp;n =&gt; x.next;<br>&nbsp;1::samp =&gt; 
now;<br>}</font></div>
<div><font face="Arial" size="2">file.closeFile();</font></div>
<div><font face="Arial" size="2"></font>&nbsp;</div>
<div><font face="Arial" size="2">These values can then be read sequentially with 
WvIn:</font></div>
<div><font face="Arial" size="2"></font>&nbsp;</div>
<div><font face="Arial" size="2">//READ1.ck//</font></div>
<div><font face="Arial" size="2"></font>&nbsp;</div>
<div><font face="Arial" size="2">WvIn w =&gt; blackhole;<br>&quot;data.snd&quot; =&gt; 
w.path;<br>float n;</font></div>
<div><font face="Arial" size="2"></font>&nbsp;</div>
<div><font face="Arial" size="2">repeat(20)<br>{<br>&nbsp;1::samp =&gt; 
now;<br>&nbsp;w.last() =&gt; n;<br>&nbsp;&lt;&lt;&lt; n 
&gt;&gt;&gt;;<br>}</font></div>
<div><font face="Arial" size="2"></font>&nbsp;</div>
<div><font face="Arial" size="2">But I don&#39;t get exactly the same values returned; 
ie, I try to store the value 0.500000 but when </font><font face="Arial" size="2">read,</font></div>
<div><font face="Arial" size="2">I get </font><font face="Arial" size="2">0.500015. 
That&#39;s a significant variance.</font></div>
<div><font face="Arial" size="2"></font>&nbsp;</div>
<div><font face="Arial" size="2">Does anyone know where this variance comes from, or 
how to get around it? And is this the only way</font></div>
<div><font face="Arial" size="2">to store and read data? What about strings from 
files?</font></div>
<div><font face="Arial" size="2"></font>&nbsp;</div><font color="#888888">
<div><font face="Arial" size="2">Joel</font></div></font></div>
<br>_______________________________________________<br>
chuck-users mailing list<br>
<a href="mailto:chuck-users@lists.cs.princeton.edu">chuck-users@lists.cs.princeton.edu</a><br>
<a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Release me, insect, or I will destroy the Cosmos!<br>
</div></div>