[Stk] Segfault in SineWave.h

Janosch.rux janosch.rux at web.de
Mon Jan 10 06:39:28 PST 2011


Thats the whole main.cpp:

    http://pastebin.com/aeGsNz06

Regards

On 10.01.2011 01:15, Tristan Matthews wrote:
> 2011/1/7 Janosch.rux <janosch.rux at web.de <mailto:janosch.rux at web.de>>
>
>     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't know how I could solve this in a
>     more elegant way.
>
>     Thanks for your reply
>
>     Janosch Rux
>
>     See also: http://pastebin.com/7smzrQ02
>
>     ###### Definition of args_struct
>
>     struct args_struct {
>             stk::SineWave *sine;
>             XnVPointDrawer *point;
>     };
>
>
>     #######Call in main.cpp:
>
>             args_stk.point = g_pDrawer;
>
>             //sound init get pointer to drawer
>             status = pthread_create(&sig, NULL, audio, (void *)&args_stk);
>             if(status != 0) {
>                     printf("Can't create thread\n");
>                     exit(EXIT_FAILURE);
>             }
>
>             pthread_detach(sig);
>
>
>
> Could you show the rest of main.cpp? It's possible that args_stk is
> going out of scope.
>
> -t
>  
>
>
>     ######## the thread function to init the stk
>
>     void *audio(void *arg) {
>
>       RtAudio dac;
>      struct args_struct *fuckit = (args_struct *) arg;
>       fuckit->sine = new SineWave;
>
>       // Figure out how many bytes in an StkFloat and setup the
>     RtAudio stream.
>       RtAudio::StreamParameters parameters;
>       parameters.deviceId = dac.getDefaultOutputDevice();
>       parameters.nChannels = 1;
>       RtAudioFormat format = ( sizeof(StkFloat) == 8 ) ?
>     RTAUDIO_FLOAT64 : RTAUDIO_FLOAT32;
>       unsigned int bufferFrames = RT_BUFFER_SIZE;
>
>
>       try {
>         dac.openStream( &parameters, NULL, format, (unsigned
>     int)Stk::sampleRate(), &bufferFrames, &tick, (void *)fuckit);
>       }
>       catch ( RtError &error ) {
>         error.printMessage();
>         exit(EXIT_FAILURE);
>       }
>
>       fuckit->sine->setFrequency(440.0);
>
>       try {
>         dac.startStream();
>       }
>       catch ( RtError &error ) {
>         error.printMessage();
>         exit(EXIT_FAILURE);
>       }
>
>             while(1) {}
>
>             return 0;
>     }
>
>     ###### the tick() function
>
>     int tick( void *outputBuffer, void *inputBuffer, unsigned int
>     nBufferFrames,
>      double streamTime, RtAudioStreamStatus status, void *dataPointer )
>     {
>
>     struct args_struct *fuckit = (args_struct *)dataPointer;
>     register StkFloat *samples = (StkFloat *) outputBuffer;
>     fuckit->sine->setFrequency(fuckit->point->get_stk_freq());
>
>     //printf("Freq: %i\n", fuckit->point->get_stk_freq());
>
>       for ( unsigned int i=0; i<nBufferFrames; i++ ) {
>                     *samples++ = fuckit->sine->tick();
>             }
>
>       return 0;
>
>     }
>
>
>     On 07.01.2011 20:47, Tristan Matthews wrote:
>>     2011/1/7 Janosch.rux <janosch.rux at web.de <mailto:janosch.rux at web.de>>
>>
>>         Hi,
>>
>>         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->tick() as in the example
>>         (https://ccrma.stanford.edu/software/stk/crealtime.html) on
>>         the web page I get a segfault on line 116 in SineWave.h.
>>
>>         Im not quite sure whether this is a bug or mistake on my side.
>>
>>
>>     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.
>>
>>     -t
>>      
>>
>>
>>         Thanks for any suggestions.
>>
>>         Regards
>>
>>         Janosch Rux
>>
>>         _______________________________________________
>>         Stk mailing list
>>         Stk at ccrma.stanford.edu <mailto:Stk at ccrma.stanford.edu>
>>         http://ccrma-mail.stanford.edu/mailman/listinfo/stk
>>
>>
>>
>>
>>     -- 
>>     Tristan Matthews
>>     email: tristan at sat.qc.ca <mailto:tristan at sat.qc.ca>
>>     web: http://tristanswork.blogspot.com
>
>
>     _______________________________________________
>     Stk mailing list
>     Stk at ccrma.stanford.edu <mailto:Stk at ccrma.stanford.edu>
>     http://ccrma-mail.stanford.edu/mailman/listinfo/stk
>
>
>
>
> -- 
> Tristan Matthews
> email: tristan at sat.qc.ca <mailto:tristan at sat.qc.ca>
> web: http://tristanswork.blogspot.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://ccrma-mail.stanford.edu/pipermail/stk/attachments/20110110/7a17eca7/attachment.html 


More information about the Stk mailing list