| Actually, in the current code, the PVS bus initialization code has been
moved out of csound.hpp. The fix does not appear to be necessarty for the
current code. What CVS version of csound.hpp were you testing? The current
revision is 1.33.
Regards,
Mike
----- Original Message -----
From: "Carlos Pita"
To: "Developer discussions"
Sent: Tuesday, December 26, 2006 9:05 AM
Subject: Re: [Cs-dev] python swig wrapper (bug fix)
>> Thank you. You obviously were talking about a different bug than I was. I
>> will incorporate this fix -- unless you are a Csound developer?
>
> No, I'm not, so feel free to incorporate the fix yourself.
>
> Regards,
> Carlos
>
>>
>> Regards,
>> Mike
>>
>> -----Original Message-----
>> >From: Carlos Pita
>> >Sent: Dec 26, 2006 8:49 AM
>> >To: Developer discussions
>> >Subject: Re: [Cs-dev] python swig wrapper (bug fix)
>> >
>> >I've identified what causes the fore mentioned bug. The unfortunate fact
>> >that sometimes just avoiding the importation of python's threading
>> >module seemed to fix the problem, while it always showed up when
>> >importing that module, was a bit misleading to me at first. But it has
>> >nothing to do with threading but with wrong initialization of Csound
>> >class instead. Let's do a little debugging:
>> >
>> >csound.hpp -----------------------
>> >[...]
>> > Csound()
>> > {
>> > printf("Csound():1\n"); fflush(stdout);
>> > csound = csoundCreate((CSOUND*) 0);
>> > printf("Csound():2\n"); fflush(stdout);
>> > }
>> > Csound(void *hostData)
>> > {
>> > printf("Csound(void *):1\n"); fflush(stdout);
>> > csound = csoundCreate(hostData);
>> > printf("Csound(void *):2\n"); fflush(stdout);
>> > pvsindata.frame = pvsoutdata.frame = NULL;
>> > printf("Csound(void *):3\n"); fflush(stdout);
>> > }
>> > // destructor
>> > virtual ~Csound()
>> > {
>> > printf("~Csound():1\n"); fflush(stdout);
>> > PvsBusDestroy();
>> > printf("~Csound():2\n"); fflush(stdout);
>> > csoundDestroy(csound);
>> > printf("~Csound():3\n"); fflush(stdout);
>> > }
>> >[...]
>> >-----------------------------------
>> >
>> >simplecsnd1.py-------------------
>> >
>> >import csnd
>> >import threading
>> >csound = csnd.Csound()
>> >--------------------------------
>> >
>> >simplecsnd2.py-------------------
>> >
>> >import csnd
>> >import threading
>> >csound = csnd.Csound(None)
>> >--------------------------------
>> >
>> >python simplecsnd1.py
>> >=>
>> >Csound():1
>> >Csound():2
>> >~Csound():1
>> >*** glibc detected *** python: free(): invalid pointer:
>> >0x00002abf7f236ab0 ***
>> >
>> >python simplecsnd2.py
>> >=>
>> >Csound(void *):1
>> >Csound(void *):2
>> >Csound(void *):3
>> >~Csound():1
>> >~Csound():2
>> >~Csound():3
>> >
>> >This works!
>> >
>> >So from the above the bug seems to happen when calling PvsBusDestroy()
>> >from the destructor for an instance initialized by the first version of
>> >the constructor. PvsBusDestroy() is defined as:
>> >
>> > virtual void PvsBusDestroy(){
>> > if(pvsindata.frame != NULL){
>> > delete[] pvsindata.frame;
>> > delete[] pvsoutdata.frame;
>> > }
>> > }
>> >
>> >I think the void constructor should initialize pvsindata.frame and
>> >pvsoutdata.frame to NULL the same way that the void* constructor does.
>> >That is:
>> >
>> > Csound()
>> > {
>> > csound = csoundCreate((CSOUND*) 0);
>> > pvsindata.frame = pvsoutdata.frame = NULL; // <--- add this
>> > }
>> >
>> >Indeed this simple patch fixes up the bug.
>> >
>> >Cheers,
>> >Carlos
>> >
>> >
>> >
>> >> That's true, but there are workarounds. You can always use a button
>> >> that
>> >> will call the CsoundPerformanceThread.Stop() and .Join() methods.
>> >> Also, if I write a Csound/Python program in Idle, the default Python
>> >> editor/debugger that comes with Csound, I can use signal handling to
>> >> trap
>> >> Control-C in the Python shell and stop Csound. Here's a code snippet
>> >> (which
>> >> does NOT use CsoundPerformanceThread, no threads at all in fact, since
>> >> Csound is running in a separate process in Idle's Python shell which
>> >> communicates with Idle through pipes):
>> >>
>> >> # Set up signal handling so Csound can be killed
>> >> # when performing in the development environment,
>> >> # e.g. by pressing Control-C in the Idle shell.
>> >> import signal
>> >>
>> >> def signalHandler(signal, frame):
>> >> print 'signalHandler called with signal: %d' % (signal)
>> >> csound.stop()
>> >>
>> >> signal.signal(signal.SIGABRT, signalHandler)
>> >> signal.signal(signal.SIGBREAK, signalHandler)
>> >> signal.signal(signal.SIGFPE, signalHandler)
>> >> signal.signal(signal.SIGILL, signalHandler)
>> >> signal.signal(signal.SIGINT, signalHandler)
>> >> signal.signal(signal.SIGSEGV, signalHandler)
>> >>
>> >>
>> >>
>> >> ----- Original Message -----
>> >> From: "Carlos Pita"
>> >> To: "Developer discussions"
>> >> Sent: Monday, December 25, 2006 8:57 PM
>> >> Subject: Re: [Cs-dev] python swig wrapper
>> >>
>> >>
>> >> > One problem I find when importing the threading module is that the
>> >> > python process can't finish cleanly. This happens for
>> >> > wxController.py,
>> >> > wxController2.py and even for a simple example of mine that doesn't
>> >> > use
>> >> > threads at all (neither csound threads nor python threads) but that
>> >> > just
>> >> > imports the threading module. The error is similar in any case:
>> >> >
>> >> >
>> >> > *** glibc detected *** python: free(): invalid pointer:
>> >> > 0x00002adb652a15d0 ***
>> >> > ======= Backtrace: =========
>> >> > /lib/libc.so.6[0x2adb65034733]
>> >> > /lib/libc.so.6(__libc_free+0x84)[0x2adb650348b4]
>> >> > /home/carlos/dev/misc/csound/_csnd.so(_ZN6CsoundD0Ev
>> >> > +0x20)[0x2adb653d19d0]
>> >> > /home/carlos/dev/misc/csound/_csnd.so[0x2adb653615b5]
>> >> > python(PyObject_CallFunctionObjArgs+0x167)[0x415ba7]
>> >> > /home/carlos/dev/misc/csound/_csnd.so[0x2adb65347565]
>> >> > python[0x4379c3]
>> >> > python[0x447dec]
>> >> > python[0x436647]
>> >> > python(PyDict_SetItem+0x78)[0x438068]
>> >> > python(_PyModule_Clear+0x14e)[0x4c094e]
>> >> > python(PyImport_Cleanup+0x37e)[0x48fa9e]
>> >> > python(Py_Finalize+0xac)[0x49a6ec]
>> >> > python(Py_Main+0x691)[0x410891]
>> >> > /lib/libc.so.6(__libc_start_main+0xf4)[0x2adb64fe30c4]
>> >> > python[0x410079]
>> >> > ======= Memory map: ========
>> >> > [...]
>> >> > Csound tidy up: Aborted
>> >> >
>> >> > Cheers,
>> >> > Carlos
>> >> >
>> >> >> Thank you for your detailed answers Michael and Victor.
>> >> >>
>> >> >> I managed myself to get csound running directed by python generated
>> >> >> realtime events (including channel value changes).
>> >> >>
>> >> >> One thing I'm still not completely sure is about threading. Can I
>> >> >> use
>> >> >> python native threading mechanisms or should I strictly use csound
>> >> >> threads instead? Albeit I successfully ran both versions below,
>> >> >> I've a
>> >> >> feeling that the first one could be seen as being bad practice.
>> >> >>
>> >> >> Version 1
>> >> >> [...]
>> >> >> def performThread():
>> >> >> while True:
>> >> >> csound.PerformKsmps()
>> >> >> thread = threading.Thread(None, performThread)
>> >> >> thread.start()
>> >> >> thread.join()
>> >> >>
>> >> >> Version 2
>> >> >> [...]
>> >> >> thread = csnd.CsoundPerformanceThread(csound)
>> >> >> thread.InputMessage("i 1 0 40 660")
>> >> >> thread.Play()
>> >> >> thread.Join()
>> >> >>
>> >> >> Also, the wxController2.py example confuses me a bit, because it
>> >> >> starts
>> >> >> a new threading.Thread thread that runs a routine that itself
>> >> >> starts a
>> >> >> new CsoundPerformanceThread thread. Is this really necessary?
>> >> >>
>> >> >> Thank you in advance.
>> >> >> Cheers,
>> >> >> Carlos.
>> >> >>
>> >> >> On Mon, 2006-12-25 at 15:17 -0500, Michael Gogins wrote:
>> >> >> > What platform are you on?
>> >> >> >
>> >> >> > There are actually a number of APIs involved.
>> >> >> >
>> >> >> > In general, the binding is not meant to be used like the C API.
>> >> >> > It is,
>> >> >> > rather, meant to be used like the C++ binding for the C API,
>> >> >> > CppSound.
>> >> >> > This
>> >> >> > is because SWIG is most suited to wrapping object-oriented
>> >> >> > interfaces,
>> >> >> > not
>> >> >> > procedural interfaces.
>> >> >> >
>> >> >> > The original Python interface is CsoundVST (by me) which is high
>> >> >> > level
>> >> >> > and
>> >> >> > includes extensive support for algorithmic composition. See
>> >> >> > examples/lindenmayer.py.
>> >> >> >
>> >> >> > The csnd interface is lower level and was created later (by
>> >> >> > others as
>> >> >> > well
>> >> >> > as myself) for those on platforms where CsoundVST is not
>> >> >> > supported or
>> >> >> > not
>> >> >> > desired. See examples/koch.py.
>> >> >> >
>> >> >> > CppSound (available in both CsoundVST and csnd) includes internal
>> >> >> > Csound
>> >> >> > file storage and management.
>> >> >> >
>> >> >> > csnd.Csound wraps Csound.hpp and is similar to CppSound but
>> >> >> > slightly
>> >> >> > lower level.
>> >> >> >
>> >> >> > The csound.h interface is even lower level.
>> >> >> >
>> >> >> > Also see the introduction to CsoundAPI.pdf.
>> >> >> >
>> >> >> > Also note, that thread management with the Python interface is
>> >> >> > tricky
>> >> >> > because of the Python global interpreter lock. The
>> >> >> > examples/wxController.py
>> >> >> > example demonstrates how to get around this with the very useful
>> >> >> > csnd.CsoundPerformanceThread class by Istvan Varga.
>> >> >> >
>> >> >> > If you wish to help with the Python interface, please study these
>> >> >> > issues
>> >> >> > first and consult with me. Or, if there are a few things you
>> >> >> > would like
>> >> >> > to
>> >> >> > change, let me know and I will try to do it. I am the originator
>> >> >> > of the
>> >> >> > Python interface and one of its major maintainers.
>> >> >> >
>> >> >> > Hope this helps,
>> >> >> > Mike
>> >> >> >
>> >> >> > ----- Original Message -----
>> >> >> > From: "Carlos Pita"
>> >> >> > To: "Developer discussions"
>> >> >> > Sent: Monday, December 25, 2006 2:50 PM
>> >> >> > Subject: Re: [Cs-dev] python swig wrapper
>> >> >> >
>> >> >> >
>> >> >> > > Oh, shame on me, I've just found out class CsoundArgVList in
>> >> >> > > cs_glue.hpp. But still, is there any basic example of python
>> >> >> > > binding
>> >> >> > > usage? In general, should I use CppSound api or plain csound.h?
>> >> >> > > A
>> >> >> > > simple
>> >> >> > > example showing expected practices would be very valuable to
>> >> >> > > get
>> >> >> > > started.
>> >> >> > > Thank you in advance.
>> >> >> > > Cheers,
>> >> >> > > Carlos
>> >> >> > >
>> >> >> > >
>> >> >> > >> Hi all,
>> >> >> > >> I've been toying a bit with csound 5 python interface. The
>> >> >> > >> binding
>> >> >> > >> feels
>> >> >> > >> quite low level, with all those char** and int* directly
>> >> >> > >> exposed to
>> >> >> > >> python. Perhaps I'm facing it the wrong way but as I haven't
>> >> >> > >> found
>> >> >> > >> any
>> >> >> > >> example I just assumed that the binding is meant to be used
>> >> >> > >> just
>> >> >> > >> like
>> >> >> > >> the C host api. Anyway as neither cpointer.i nor carrays.i are
>> >> >> > >> included
>> >> >> > >> in the swig interface definition I see no way to create those
>> >> >> > >> char**
>> >> >> > >> that signatures like that of csoundInitialize expect. I'm
>> >> >> > >> pretty
>> >> >> > >> comfortable with swig, I've written a number of advanced
>> >> >> > >> bindings,
>> >> >> > >> so I
>> >> >> > >> think I could help improving the python binding if this is
>> >> >> > >> desired.
>> >> >> > >> What
>> >> >> > >> do you say?
>> >> >> > >> Cheers,
>> >> >> > >> Carlos
>> >> >> > >>
>> >> >> > >>
>> >> >> > >>
>> >> >> > >>
>> >> >> > >>
>> >> >> > >>
>> >> >> > >> __________________________________________________
>> >> >> > >> Pregunt. Respond. Descubr.
>> >> >> > >> Todo lo que queras saber, y lo que ni imaginabas,
>> >> >> > >> est en Yahoo! Respuestas (Beta).
>> >> >> > >> Probalo ya!
>> >> >> > >> http://www.yahoo.com.ar/respuestas
>> >> >> > >>
>> >> >> > >>
>> >> >> > >>
>> >> >> > >> -------------------------------------------------------------------------
>> >> >> > >> Take Surveys. Earn Cash. Influence the Future of IT
>> >> >> > >> Join SourceForge.net's Techsay panel and you'll get the chance
>> >> >> > >> to
>> >> >> > >> share
>> >> >> > >> your
>> >> >> > >> opinions on IT & business topics through brief surveys - and
>> >> >> > >> earn
>> >> >> > >> cash
>> >> >> > >> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>> >> >> > >> _______________________________________________ Csound-devel
>> >> >> > >> mailing
>> >> >> > >> list
>> >> >> > >> Csound-devel@lists.sourceforge.net
>> >> >> > >> https://lists.sourceforge.net/lists/listinfo/csound-devel
>> >> >> > >
>> >> >> > >
>> >> >> > >
>> >> >> > >
>> >> >> > >
>> >> >> > >
>> >> >> > > __________________________________________________
>> >> >> > > Preguntá. Respondé. Descubrí.
>> >> >> > > Todo lo que querías saber, y lo que ni imaginabas,
>> >> >> > > está en Yahoo! Respuestas (Beta).
>> >> >> > > ¡Probalo ya!
>> >> >> > > http://www.yahoo.com.ar/respuestas
>> >> >> > >
>> >> >> > >
>> >> >> > >
>> >> >> > >
>> >> >> >
>> >> >> >
>> >> >> > --------------------------------------------------------------------------------
>> >> >> >
>> >> >> >
>> >> >> > > -------------------------------------------------------------------------
>> >> >> > > Take Surveys. Earn Cash. Influence the Future of IT
>> >> >> > > Join SourceForge.net's Techsay panel and you'll get the chance
>> >> >> > > to
>> >> >> > > share
>> >> >> > > your
>> >> >> > > opinions on IT & business topics through brief surveys - and
>> >> >> > > earn
>> >> >> > > cash
>> >> >> > > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>> >> >> >
>> >> >> >
>> >> >> > --------------------------------------------------------------------------------
>> >> >> >
>> >> >> >
>> >> >> > > _______________________________________________
>> >> >> > > Csound-devel mailing list
>> >> >> > > Csound-devel@lists.sourceforge.net
>> >> >> > > https://lists.sourceforge.net/lists/listinfo/csound-devel
>> >> >> > >
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> > -------------------------------------------------------------------------
>> >> >> > Take Surveys. Earn Cash. Influence the Future of IT
>> >> >> > Join SourceForge.net's Techsay panel and you'll get the chance to
>> >> >> > share
>> >> >> > your
>> >> >> > opinions on IT & business topics through brief surveys - and earn
>> >> >> > cash
>> >> >> > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>> >> >> > _______________________________________________
>> >> >> > Csound-devel mailing list
>> >> >> > Csound-devel@lists.sourceforge.net
>> >> >> > https://lists.sourceforge.net/lists/listinfo/csound-devel
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >> __________________________________________________
>> >> >> Pregunt. Respond. Descubr.
>> >> >> Todo lo que queras saber, y lo que ni imaginabas,
>> >> >> est en Yahoo! Respuestas (Beta).
>> >> >> Probalo ya!
>> >> >> http://www.yahoo.com.ar/respuestas
>> >> >>
>> >> >>
>> >> >>
>> >> >> -------------------------------------------------------------------------
>> >> >> Take Surveys. Earn Cash. Influence the Future of IT
>> >> >> Join SourceForge.net's Techsay panel and you'll get the chance to
>> >> >> share
>> >> >> your
>> >> >> opinions on IT & business topics through brief surveys - and earn
>> >> >> cash
>> >> >> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>> >> >> _______________________________________________ Csound-devel
>> >> >> mailing list
>> >> >> Csound-devel@lists.sourceforge.net
>> >> >> https://lists.sourceforge.net/lists/listinfo/csound-devel
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > __________________________________________________
>> >> > Pregunt. Respond. Descubr.
>> >> > Todo lo que queras saber, y lo que ni imaginabas,
>> >> > est en Yahoo! Respuestas (Beta).
>> >> > Probalo ya!
>> >> > http://www.yahoo.com.ar/respuestas
>> >> >
>> >> >
>> >> >
>> >> >
>> >>
>> >>
>> >> --------------------------------------------------------------------------------
>> >>
>> >>
>> >> > -------------------------------------------------------------------------
>> >> > Take Surveys. Earn Cash. Influence the Future of IT
>> >> > Join SourceForge.net's Techsay panel and you'll get the chance to
>> >> > share
>> >> > your
>> >> > opinions on IT & business topics through brief surveys - and earn
>> >> > cash
>> >> > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>> >>
>> >>
>> >> --------------------------------------------------------------------------------
>> >>
>> >>
>> >> > _______________________________________________
>> >> > Csound-devel mailing list
>> >> > Csound-devel@lists.sourceforge.net
>> >> > https://lists.sourceforge.net/lists/listinfo/csound-devel
>> >> >
>> >>
>> >>
>> >> -------------------------------------------------------------------------
>> >> Take Surveys. Earn Cash. Influence the Future of IT
>> >> Join SourceForge.net's Techsay panel and you'll get the chance to
>> >> share your
>> >> opinions on IT & business topics through brief surveys - and earn cash
>> >> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>> >> _______________________________________________
>> >> Csound-devel mailing list
>> >> Csound-devel@lists.sourceforge.net
>> >> https://lists.sourceforge.net/lists/listinfo/csound-devel
>> >
>> >
>> >
>> >
>> >
>> >
>> >__________________________________________________
>> >Pregunt�. Respond�. Descubr�.
>> >Todo lo que quer�as saber, y lo que ni imaginabas,
>> >est� en Yahoo! Respuestas (Beta).
>> >�Probalo ya!
>> >http://www.yahoo.com.ar/respuestas
>> >
>> >
>> >
>>
>>
>>
>>
>> -------------------------------------------------------------------------
>> Take Surveys. Earn Cash. Influence the Future of IT
>> Join SourceForge.net's Techsay panel and you'll get the chance to share
>> your
>> opinions on IT & business topics through brief surveys - and earn cash
>> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
>
>
>
>
> __________________________________________________
> Pregunt. Respond. Descubr.
> Todo lo que queras saber, y lo que ni imaginabas,
> est en Yahoo! Respuestas (Beta).
> Probalo ya!
> http://www.yahoo.com.ar/respuestas
>
>
>
>
--------------------------------------------------------------------------------
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share
> your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
--------------------------------------------------------------------------------
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cso |