<div dir="ltr"><div class="gmail_quote"><div> <span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">My sonification project is done! You can hear the results at <a href="https://soundcloud.com/fcahoon/shumann-resonance-at-tomsk">https://soundcloud.com/fcahoon/shumann-resonance-at-tomsk</a> .</span></div><div><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br></span></div><div><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">I&#39;ve been manipulating the data a lot, so it was simple to switch to tab-separated instead of comma-separated values, which </span></div><div><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">ChucK reads without issue. The first few lines of my data looks like</span></div><div><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br></span></div>7.8975 6.0000 13.6870 4.6500 19.0720 4.7200 25.5000 2.6200<br>7.9165 6.0000 13.6030 4.6500 19.0300 4.7200 25.5500 2.6200<br>7.9355 7.2000 13.5400 4.1200 18.9670 4.3800 25.6000 2.6200<br>7.9640 7.2000 13.4980 4.1200 18.9250 4.3800 25.6250 2.6200<br>...<br>These are four frequency/amplitude pairs on each line.</div><div class="gmail_quote"><br></div><div class="gmail_quote">I still did my interpolation sample-by-sample, but was not too difficult. Here is my ChucK code (it seems short enough to post):</div><div class="gmail_quote"><br></div><div class="gmail_quote">




<span></span>





16.0 =&gt; float FREQ_MULT;<br>0.008 =&gt; float GAIN_MULT;<br>441 =&gt; int SAMPLES_PER_DATAPOINT;<br><br>SinOsc sig[4];<br><br>for ( 0 =&gt; int i ; i &lt; sig.cap() ; i++) {<br>    sig[i] =&gt; dac;<br>    sig[i].gain(0);<br>}<br>// open file<br>me.sourceDir() + &quot;tomsk_2017-05-10_000.dat&quot; =&gt; string fname;<br>FileIO fio;<br>fio.open(fname, FileIO.READ);<br>if( !fio.good() )<br>{<br>    cherr &lt;= &quot;can&#39;t open file: &quot; &lt;= fname &lt;= &quot; for reading...&quot;<br>    &lt;= IO.newline();<br>    me.exit();<br>}
float old_freq[4];<br>float old_gain[4];<br>float new_freq[4];<br>float new_gain[4];<br>float freq_incr[4];<br>float gain_incr[4];<br><br>// read first line<br>for (0 =&gt; int i; i &lt; 4; i++) {<br>    fio =&gt; old_freq[i];<br>    fio =&gt; old_gain[i];<br>}<br><br>while (fio.more()) {<br>    // read next line<br>    for (0 =&gt; int i; i &lt; 4; i++) {<br>        fio =&gt; new_freq[i];<br>        fio =&gt; new_gain[i];<br>    }<br><br>    // calculate linear interpolation increments<br>    for (0 =&gt; int i; i &lt; 4; i++) {<br>        (new_freq[i] - old_freq[i])/SAMPLES_PER_DATAPOINT =&gt; freq_incr[i];<br>        (new_gain[i] - old_gain[i])/SAMPLES_PER_DATAPOINT =&gt; gain_incr[i];<br>    }<br>    // Interpolate all samples between datapoints:<br>    for (0 =&gt; int step; step &lt; SAMPLES_PER_DATAPOINT; step++) {<br>        // calculate interpolated freqs and gains for this sample<br>        for (0 =&gt; int i; i &lt; 4; i++) {<br>            (old_freq[i] + (step*freq_incr[i])) * FREQ_MULT =&gt; sig[i].freq;<br>            (old_gain[i] + (step*gain_incr[i])) * GAIN_MULT =&gt; sig[i].gain;<br>        }<br>        //render the sample<br>        1::samp =&gt; now;<br>    }<br>    // save last datapoint values read as &quot;old&quot; in preparation for <br>    // reading the next set of &quot;new&quot; datapoint values<br>    for (0 =&gt; int i; i &lt; 4; i++) {<br>        new_freq[i] =&gt; old_freq[i];<br>        new_gain[i] =&gt; old_gain[i];<br>    }<br>}</div><div class="gmail_quote"><div> </div><div>I&#39;m sure my code must have some non-idiomatic or inefficient things in it; it is my first real ChucK program. Any advice would be appreciated.</div></div></div>