<div>Hi Gary, Antoine, and any lurkers. I&#39;m hoping to do the exact same audio gen in an adaptation of the crtsine.cpp example in the stk and with Antoine&#39;s py example so I can figure out just how much penalty doing it python incurs. Unfortunately, I must be missing something, because in the cpp example I get silence. If anyone can see my error, or knows why it wouldn&#39;t work the same way, that would be helpful. Thanks!</div>
<div><br></div><div>Here is the audio gen code from the PyRtAudio examp:</div><div><br></div><div>    def __call__(self):<br>         self.idx += 1<br>           # deleted the ascending scale code               <br>         return 0.5 * cos( 2. * 3.1416 * self.freq * self.idx / SAMPLE_RATE )<br>
</div><div><br></div><div>And here is my attempt to do it in C++, not getting any sound:</div><div><br></div><div>int tick( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,<br>         double streamTime, RtAudioStreamStatus status, void *dataPointer )<br>
{<br>    // buffer to fill<br>    register StkFloat *samples = (StkFloat *) outputBuffer;<br>    int freq = 440;<br><br>   // loop through the number of samples we need to fill, filling the output buffer<br>   // samp_index is a global int counter<br>
   for ( unsigned int i=0; i&lt;nBufferFrames; i++, samp_index++ ){<br>       *samples++ = ( 0.5 * cos( 2.0 * 3.1416 * freq) * samp_index / SAMPLE_RATE );<br>   }<br><br>   return 0;<br>}<br><br><br></div><br><div class="gmail_quote">
On Wed, Nov 2, 2011 at 1:02 PM, Iain Duncan <span dir="ltr">&lt;<a href="mailto:iainduncanlists@gmail.com">iainduncanlists@gmail.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>Preliminary tests seem to imply this works really well actually. I&#39;m pleasantly surprised, I was able to put some pointless number crunching in the non-audio thread and spit to the screen, sending my python process up to 30-40% Cpu use and gnome -terminal up to about 50% ( on a quad core chip mind you ) without noticing any underruns. Mind you, I have no idea what the real latency is, I have my buffer set at 64, but dac.getStreamLatency() is reporting 0.00 so I might have to benchmark.<br>

</div><div><br></div><div>Wondering if either of you would happen to have an idea of how I could easily make the audio gen really audio heavy? </div><div><br></div><div>An ideal benchmark I think would be to get some audio-in, process it, and spit it out, but that may take a while.</div>

<div><br></div><div>The gen as is now:</div><div><br></div><div>0.5 * cos( 2. * 3.1416 * self.freq * self.idx / SAMPLE_RATE )</div><div><br></div><div>perhaps making a matrix of a whole bunch of those would do it.</div><div>

<br></div><div>thanks</div><div>Iain</div><div><div class="h5"><div><br></div><div><br></div>
<br><div class="gmail_quote">On Wed, Nov 2, 2011 at 12:52 PM, Iain Duncan <span dir="ltr">&lt;<a href="mailto:iainduncanlists@gmail.com" target="_blank">iainduncanlists@gmail.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>Thanks Gary, I got in touch with Antoine and will be helping to extend that example. <br></div><div><br></div><div>thanks</div><div>iain</div><div><div><br><div class="gmail_quote">On Wed, Nov 2, 2011 at 10:58 AM, Iain Duncan <span dir="ltr">&lt;<a href="mailto:iainduncanlists@gmail.com" target="_blank">iainduncanlists@gmail.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>Well it works, and it seems to be running ok on my box ( some clicking, but the sine sounds clean ). <br></div><div>



<br></div><div>I noticed the python file has a mixture of spaces and tabs, so it opened up looking funny in my editor, I&#39;m converting that. I emailed Antoine to see if he&#39;s still working on this or what the status is. I&#39;ll definitely play around with it. I assume none of the other stk stuff has been ported given that Python is not really appropriate for real time dsp eh?</div>




<div><br></div><div>Looking over my notes I realized I got busy and never tested the crtsine example on my firepod for you, I&#39;ll get to that to.</div><div><br></div><div>thanks</div><div>Iain</div><font color="#888888"><br>



</font><div class="gmail_quote"><div>
On Wed, Nov 2, 2011 at 7:24 AM, Gary Scavone <span dir="ltr">&lt;<a href="mailto:gary@ccrma.stanford.edu" target="_blank">gary@ccrma.stanford.edu</a>&gt;</span> wrote:<br></div><div><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




Hi Iain,<br>
<br>
If it helps, there is a python wrapper for RtAudio in the latest release of RtAudio (look in the &quot;contrib/python/&quot; directory).<br>
<br>
--gary<br>
<div><div><br>
On 2011-11-02, at 12:22 AM, Iain Duncan wrote:<br>
<br>
&gt; Hi, I&#39;m working on an a project that I intend to do using the STK, but am hoping I can prototype the architecture in python until I&#39;ve figured out the various components and their responsibilities and dependencies. Does anyone know of any kind of python library ( or method? ) that would let me simulate the way callback based STK apps using RTAudio work? IE I want to have a python master callable that gets called once per audio sample and has a way of sending out it&#39;s results.<br>





&gt;<br>
&gt; I&#39;ve found a bunch of python audio libs but it doesn&#39;t seem like they work that way, maybe I&#39;m missing something?<br>
&gt;<br>
&gt; thanks!<br>
&gt; Iain<br>
</div></div>&gt; _______________________________________________<br>
&gt; Stk mailing list<br>
&gt; <a href="mailto:Stk@ccrma.stanford.edu" target="_blank">Stk@ccrma.stanford.edu</a><br>
&gt; <a href="http://ccrma-mail.stanford.edu/mailman/listinfo/stk" target="_blank">http://ccrma-mail.stanford.edu/mailman/listinfo/stk</a><br>
<br>
</blockquote></div></div></div><br>
</blockquote></div><br>
</div></div></blockquote></div><br>
</div></div></blockquote></div><br>