<div dir="ltr"><div><div><div><div>Yes, i'm using the C++ wrapper. I compiled the wrapper with thread support. I was not using the queued layer.  Should I use both (mutex and queued layer)? I made some test now (with mutex, without mutex, with mutex and queued, with mutex and without queued, etc), and there is no difference, the opengl draw is being blocked during the execution of the metronome. I tested the function with a std::thread:<br><br>void BasicGLPane::rightClick(wxMouseEvent& event) {<br>    manager->init();<br>    SLEEP(2000);<br>    std::thread t(&BasicGLPane::start_thread,this);<br>    t.join();<br>}<br><br></div>and made some changes in the thread function:<br><br>void BasicGLPane::start_thread() {<br>    wxGLCanvas::SetCurrent(*m_context);<br>    ctx = CGLGetCurrentContext();<br>    err =  CGLEnable( ctx, kCGLCEMPEngine);<br>    int timer = 0;<br>    manager->play();<br>    while (_object->getCounter()<10) {<br>       if (err==0 && timer<_object->getCounter()) {<br>            std::cout<<"if CGLError: "<<err<<" timer: "<<timer<<std::endl;<br>            glTranslatef(p3->x, p3->y, 0);<br>            timer = _object->getCounter();<br>            Refresh();<br>        }<br>    }<br>    manager->stop();<br>    Refresh();<br>}<br><br></div>There is no context error in the OpenGL draw now (solved with the call wxGLCanvas::SetCurrent(*m_context) but the draw still doesn't works (the object is moved after the manager->stop() and not during the execution) . I still think RtAudio is owning the CPU and blocking the execution of other threads or process. It will be better to do it with PortAudio?<br></div>Regards.<br></div>Luis<br><div><div><div><div><div><div class="gmail_extra"><br><div class="gmail_quote">2016-02-17 19:25 GMT+01:00 Dan Wilcox <span dir="ltr"><<a href="mailto:danomatika@gmail.com" target="_blank">danomatika@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word">It looks like you’re using the C++ wrapper for libpd. Did you build it with thread support and/or are you using the queued layer?<div><br></div><div>There are actually 3 threads here:</div><div><br></div><div>* main application thread</div><div>* audio thread</div><div>* Open GL thread</div><div><br></div><div>libpd will obviously be utilized by the audio thread where you run the libpd process function. If you are *not* using a mutex or the queued layer, you may have resource issues between the audio thread and the other threads.</div><div><br><div>
<div style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word">--------<br>Dan Wilcox<br><a href="https://twitter.com/danomatika" target="_blank">@danomatika</a><br><a href="http://danomatika.com" target="_blank">danomatika.com</a><br><div><a href="http://robotcowboy.com" target="_blank">robotcowboy.com</a></div></div>

</div>
<br><div><blockquote type="cite"><div>On Feb 17, 2016, at 4:00 AM, <a href="mailto:pd-dev-request@lists.iem.at" target="_blank">pd-dev-request@lists.iem.at</a> wrote:</div><br><div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px"><span style="font-family:-webkit-system-font,"Helvetica Neue",Helvetica,sans-serif;color:rgb(127,127,127)"><b>From:<span> </span></b></span><span style="font-family:-webkit-system-font,"Helvetica Neue",Helvetica,sans-serif">0222445 <<a href="mailto:Luis.Valdivia@stud.sbg.ac.at" target="_blank">Luis.Valdivia@stud.sbg.ac.at</a>><br></span></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px"><span style="font-family:-webkit-system-font,"Helvetica Neue",Helvetica,sans-serif;color:rgb(127,127,127)"><b>Subject:<span> </span></b></span><span style="font-family:-webkit-system-font,"Helvetica Neue",Helvetica,sans-serif"><b>[PD-dev] Fwd: Synchronizing OpenGL with libpd (with RtAudio or Port Audio)</b><br></span></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px"><span style="font-family:-webkit-system-font,"Helvetica Neue",Helvetica,sans-serif;color:rgb(127,127,127)"><b>Date:<span> </span></b></span><span style="font-family:-webkit-system-font,"Helvetica Neue",Helvetica,sans-serif">February 16, 2016 at 9:00:30 PM MST<br></span></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px"><span style="font-family:-webkit-system-font,"Helvetica Neue",Helvetica,sans-serif;color:rgb(127,127,127)"><b>To:<span> </span></b></span><span style="font-family:-webkit-system-font,"Helvetica Neue",Helvetica,sans-serif"><a href="mailto:pd-dev@lists.iem.at" target="_blank">pd-dev@lists.iem.at</a><br></span></div><span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div class="gmail_quote"><div dir="ltr"><div><div><div>I have to synchonize a Metronome (wrote with libpd) and OpenGL graphics. I'd like to move some objects parallel with the metronome clicks.<br></div><div>The language is C++, the Gui is made with WxWidgets, Threads with Poco, audio with RtAudio.<br></div>The metronome works, OpenGL graphics too, I have only a problem with the synchronisation. I'm running both things with a Thread, but it actually doesn't works, the metronome run and the graphic is done after the metronome stops (and not parallel). i become  the CGLError 10004 from OpenGL during the execution of the thread (if CLGError is = 0 the draw is going to be done). The object is moved when the thread is completed.</div></div></div></div></div></span></div></blockquote></div><br></div></div></blockquote></div><br></div></div></div></div></div></div></div>