2011/1/7 Janosch.rux <span dir="ltr">&lt;<a href="mailto:janosch.rux@web.de">janosch.rux@web.de</a>&gt;</span><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">



  

<div text="#000000" bgcolor="#ffffff">
I tried to extract the relevant parts. The whole code is a hand
tracking example for the kinect device. In my opinion this is really
messy but actually I don&#39;t know how I could solve this in a more
elegant way.<br>
<br>
Thanks for your reply<br>
<br>
Janosch Rux<br>
<br>
See also: <a href="http://pastebin.com/7smzrQ02" target="_blank">http://pastebin.com/7smzrQ02</a><br>
<br>
###### Definition of args_struct<br>
<br>
struct args_struct {<br>
        stk::SineWave *sine;<br>
        XnVPointDrawer *point;<br>
};<br>
<br>
<br>
#######Call in main.cpp:<br>
<br>
        args_stk.point = g_pDrawer;<br>
<br>
        //sound init get pointer to drawer<br>
        status = pthread_create(&amp;sig, NULL, audio, (void
*)&amp;args_stk);<br>
        if(status != 0) {<br>
                printf(&quot;Can&#39;t create thread\n&quot;);<br>
                exit(EXIT_FAILURE);<br>
        }<br>
<br>
        pthread_detach(sig);<br></div></blockquote><div><br><br>Could you show the rest of main.cpp? It&#39;s possible that args_stk is going out of scope.<br><br>-t<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div text="#000000" bgcolor="#ffffff">
<br>
######## the thread function to init the stk<br>
<br>
void *audio(void *arg) {<br>
<br>
  RtAudio dac;<br>
 struct args_struct *fuckit = (args_struct *) arg;<br>
  fuckit-&gt;sine = new SineWave;<br>
<br>
  // Figure out how many bytes in an StkFloat and setup the RtAudio
stream.<br>
  RtAudio::StreamParameters parameters;<br>
  parameters.deviceId = dac.getDefaultOutputDevice();<br>
  parameters.nChannels = 1;<br>
  RtAudioFormat format = ( sizeof(StkFloat) == 8 ) ? RTAUDIO_FLOAT64 :
RTAUDIO_FLOAT32;<br>
  unsigned int bufferFrames = RT_BUFFER_SIZE;<br>
<br>
<br>
  try {<br>
    dac.openStream( &amp;parameters, NULL, format, (unsigned
int)Stk::sampleRate(), &amp;bufferFrames, &amp;tick, (void *)fuckit);<br>
  }<br>
  catch ( RtError &amp;error ) {<br>
    error.printMessage();<br>
    exit(EXIT_FAILURE);<br>
  }<br>
<br>
  fuckit-&gt;sine-&gt;setFrequency(440.0);<br>
<br>
  try {<br>
    dac.startStream();<br>
  }<br>
  catch ( RtError &amp;error ) {<br>
    error.printMessage();<br>
    exit(EXIT_FAILURE);<br>
  }<br>
<br>
        while(1) {}<br>
<br>
        return 0;<br>
}<br>
<br>
###### the tick() function<br>
<br>
int tick( void *outputBuffer, void *inputBuffer, unsigned int
nBufferFrames,<br>
 double streamTime, RtAudioStreamStatus status, void *dataPointer )<br>
{<br>
<br>
struct args_struct *fuckit = (args_struct *)dataPointer;<br>
register StkFloat *samples = (StkFloat *) outputBuffer;<br>
fuckit-&gt;sine-&gt;setFrequency(fuckit-&gt;point-&gt;get_stk_freq());<br>
<br>
//printf(&quot;Freq: %i\n&quot;, fuckit-&gt;point-&gt;get_stk_freq());<br>
<br>
  for ( unsigned int i=0; i&lt;nBufferFrames; i++ ) {<br>
                *samples++ = fuckit-&gt;sine-&gt;tick();<br>
        }<br>
<br>
  return 0;<div><div></div><div class="h5"><br>
}<br>
<br>
<br>
On 07.01.2011 20:47, Tristan Matthews wrote:
<blockquote type="cite">
  <div class="gmail_quote">2011/1/7 Janosch.rux <span dir="ltr">&lt;<a href="mailto:janosch.rux@web.de" target="_blank">janosch.rux@web.de</a>&gt;</span><br>
  <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
    <div text="#000000" bgcolor="#ffffff">Hi,<br>
    <br>
I use stk with callbacks to enhance another piece of software. Stk is
encapsulated in its own thread. If the tick function calls the
sine-&gt;tick() as in the example (<a href="https://ccrma.stanford.edu/software/stk/crealtime.html" target="_blank">https://ccrma.stanford.edu/software/stk/crealtime.html</a>)
on
the web page I get a segfault on line 116 in SineWave.h. <span style="font-weight: lighter; color: rgb(136, 136, 136);"><br>
    </span><br>
Im not quite sure whether this is a bug or mistake on my side.<br>
    </div>
  </blockquote>
  <div><br>
Could you provide your code (or at least the relevant part)? Without
seeing it, we can only hazard a guess as to what is going wrong.<br>
  <br>
-t<br>
 </div>
  <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
    <div text="#000000" bgcolor="#ffffff"><br>
Thanks for any suggestions.<br>
    <br>
Regards<br>
    <br>
Janosch Rux<br>
    </div>
    <br>
_______________________________________________<br>
Stk mailing list<br>
    <a href="mailto:Stk@ccrma.stanford.edu" target="_blank">Stk@ccrma.stanford.edu</a><br>
    <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>
  <br>
  <br clear="all">
  <br>
-- <br>
Tristan Matthews<br>
email: <a href="mailto:tristan@sat.qc.ca" target="_blank">tristan@sat.qc.ca</a><br>
web: <a href="http://tristanswork.blogspot.com" target="_blank">http://tristanswork.blogspot.com</a><br>
</blockquote>
<br>
</div></div></div>

<br>_______________________________________________<br>
Stk mailing list<br>
<a href="mailto:Stk@ccrma.stanford.edu">Stk@ccrma.stanford.edu</a><br>
<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><br><br clear="all"><br>-- <br>Tristan Matthews<br>email: <a href="mailto:tristan@sat.qc.ca">tristan@sat.qc.ca</a><br>web: <a href="http://tristanswork.blogspot.com">http://tristanswork.blogspot.com</a><br>