Csound Csound-dev Csound-tekno Search About

[Cs-dev] Fw: Re: CsoundAV5 and OpenGL (was: vst4cs on linux)

Date2007-04-17 18:31
FromMichael Gogins
Subject[Cs-dev] Fw: Re: CsoundAV5 and OpenGL (was: vst4cs on linux)

-----Forwarded Message-----
>From: Michael Gogins 
>Sent: Apr 17, 2007 1:30 PM
>To: g.maldonado@tiscali.it
>Subject: Re: [Cs-dev]  CsoundAV5 and OpenGL (was: vst4cs on linux)
>
>OK, then perhaps the OpenGL calls can be enqueued, as lambdas or functors, from the Csound performance thread, then dequeued in the OpenGL event loop for execution.  Of course this is a variation on your space copying functions, but this code is all localized within the opcode itself. In other words:
>
>In Csound code:
>
>instr 1
>
>myOpenGlOpcde p4, p5, p6
>
>endin
>
>In the myOpenGlOpcode code:
>
>class MyOpenGLOpcode : public OpcodeBase
>{
>  MYFLT *kx;
>  MYFLT *ky;
>  MYFLT *kz;
>
>std::list< std::vector< boost::any > > openGLCallQueue;
>
>virtual MyOpenGlOpcode::kontrol(CSOUND *csound)
>{
>  std::vector frame;
>  frame.push_back(*kx);
>  frame.push_back(*ky);
>  frame.push_back(*kz);
>  openGLCallQueue.push_back(frame);
>  return OK;
>
>}
>};
>
>And the openGL loop, which can certainly be in another thread, something like:
>
>for(;;) 
>{
>  if (openGLCallQueue.size())
>  {
>    std::vector frame = openGLCallQueue.pop_front();
>    switch(boost::any_cast(frame[0])
>    {
>      case OPEN_GL_CALL_TYPE_A:
>         status = glXXX(boost::any_cast(frame[1]), boost::any_cast(frame[2]));
>         break;
>    }
>  }
>  // Whatever OpenGL does to dispatch events goes here...
>}
>
>And so on. Does this make any sense? One mutex would actually be required, to protect the event queue while pushing and popping; that of course happens extremely fast.
>
>Regards,
>Mike
>
>-----Original Message-----
>>From: Gabriel Maldonado 
>>Sent: Apr 17, 2007 10:41 AM
>>To: Michael Gogins 
>>Cc: Developer discussions 
>>Subject: Re: [Cs-dev]  CsoundAV5 and OpenGL (was: vst4cs on linux)
>>
>>It is not possible to call OpenGL functions from the k-rate loop, at 
>>least under Win32, because they seem not to update the screen when 
>>called from an external thread. The opengl functions are called during 
>>the GLwindow update stage which is done, in its turn, by the draw() 
>>member function of the OpenGL window (FLTK widget thread).
>>
>>I already tested a k-rate thread which copies the opcode arguments into 
>>a safe place of the opcode structure.
>>
>>It works, but introduces an overhead (I have to add the k-rate stage 
>>besides the i-rate and frame-rate calls), and moreover, it forces me to 
>>write a huge amount of additional code (the OpenGL opcodes are quite a lot).
>>
>>Regards
>>
>>Gabriel
>>
>>Michael Gogins ha scritto:
>>> Other solutions might be:
>>>
>>> 1. Protect the formula space using a mutex.
>>> 2. Drive the openGL event loop from the Csound krate loop.
>>>
>>> Have you considered any of these?
>>>
>>> Regards,
>>> Mike
>>>
>>> -----Original Message-----
>>>   
>>>> From: Gabriel Maldonado 
>>>> Sent: Apr 16, 2007 3:56 AM
>>>> To: Developer discussions 
>>>> Subject: [Cs-dev]  CsoundAV5 and OpenGL (was: vst4cs on linux)
>>>>
>>>> It seems that the inserter engine of Csound5 uses the same address for 
>>>> different formulas, overwriting the contents of the address space of the 
>>>> input arguments of opcodes. Since the OpenGL graphic opcodes accesses 
>>>> these addresses at moments different than k-cycles (i.e. at its own 
>>>> frame-rate), their contents  result corrupted using Csound5, giving 
>>>> bogus values.
>>>> In the older versions of  canonical Csound this didn't happen, leaving 
>>>> the opcode argumens space untouched even at moments different than 
>>>> k-cycles, allowing to run openGL without a special space-copying k-rate 
>>>> functions for opcode, which would add a lot of overhead..
>>>> So what I need is to restore the old behavior in Csound5 (at least for 
>>>> an OpenGL compliant csound build, eventually inserting preprocessor 
>>>> conditionals).
>>>>
>>>> I didn't find the code that treats this so far. Any suggestion on where 
>>>> to find this code?
>>>>
>>>> thanks
>>>>
>>>> Gabriel
>>>>
>>>> Michael Gogins ha scritto:
>>>>     
>>>>> What changes to csound5 are required? Can we begin discussing them?
>>>>>
>>>>> Regards,
>>>>> Mike
>>>>>
>>>>> ----- Original Message ----- 
>>>>> From: "Gabriel Maldonado" 
>>>>> To: "Developer discussions" 
>>>>> Sent: Sunday, April 15, 2007 3:42 PM
>>>>> Subject: Re: [Cs-dev] vst4cs on linux
>>>>>
>>>>>
>>>>>   
>>>>>       
>>>>>> My intention is to do that. But  some (small) modifications and
>>>>>> additions to the core of Csound5 are needed .
>>>>>> Also, the syntax of the openGL opcodes needs to be changed, making the
>>>>>> old .csd incompatible, but adaptable to CsoundAV5 with small 
>>>>>> modifications.
>>>>>>
>>>>>> Gabriel
>>>>>>
>>>>>> Victor Lazzarini ha scritto:
>>>>>>     
>>>>>>         
>>>>>>> Now, what about instead of converting CsoundAV,
>>>>>>> integrating/merging its features with the
>>>>>>> Canonical?
>>>>>>>
>>>>>>> Victor
>>>>>>>
>>>>>>>
>>>>>>>       
>>>>>>>           
>>>>>>>> Thanks a lot Andres!...
>>>>>>>> I'm going to convert (most of) CsoundAV to Csound5.
>>>>>>>> Hope it will work in other platforms with small
>>>>>>>> modifications...
>>>>>>>>
>>>>>>>> I will make the sources public when I will reach a stable
>>>>>>>> version on Win32.
>>>>>>>>
>>>>>>>> best
>>>>>>>>
>>>>>>>> Gabriel
>>>>>>>>
>>>>>>>> ----------------------------------------------------------
>>>>>>>> --------------- This SF.net email is sponsored by DB2
>>>>>>>> Express Download DB2 Express C - the FREE version of DB2
>>>>>>>> express and take control of your XML. No limits. Just
>>>>>>>> data. Click to get it now.
>>>>>>>> http://sourceforge.net/powerbar/db2/
>>>>>>>> _______________________________________________
>>>>>>>> Csound-devel mailing list
>>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>>>
>>>>>>>>         
>>>>>>>>             
>>>>>>>       
>>>>>>>           
>>>>>> -------------------------------------------------------------------------
>>>>>> This SF.net email is sponsored by DB2 Express
>>>>>> Download DB2 Express C - the FREE version of DB2 express and take
>>>>>> control of your XML. No limits. Just data. Click to get it now.
>>>>>> http://sourceforge.net/powerbar/db2/
>>>>>> _______________________________________________
>>>>>> Csound-devel mailing list
>>>>>> Csound-devel@lists.sourceforge.net
>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel 
>>>>>>     
>>>>>>         
>>>>> -------------------------------------------------------------------------
>>>>> This SF.net email is sponsored by DB2 Express
>>>>> Download DB2 Express C - the FREE version of DB2 express and take
>>>>> control of your XML. No limits. Just data. Click to get it now.
>>>>> http://sourceforge.net/powerbar/db2/
>>>>> _______________________________________________
>>>>> Csound-devel mailing list
>>>>> Csound-devel@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>
>>>>>   
>>>>>       
>>>> -------------------------------------------------------------------------
>>>> This SF.net email is sponsored by DB2 Express
>>>> Download DB2 Express C - the FREE version of DB2 express and take
>>>> control of your XML. No limits. Just data. Click to get it now.
>>>> http://sourceforge.net/powerbar/db2/
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>     
>>>
>>>
>>>
>>>
>>>   
>
>




-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net