ctcsound is compatible with the python wrapper csnd6, generated by swig when building Csound. csnd6 needs Python 2, so this notebook runs under a Python 2 kernel.
Import the csnd6 module and create an object called 'csSwig' from the csnd6.Csound class.
In [1]:
import csnd6
csSwig = csnd6.Csound()
Get an opaque pointer to the csound instance created by the csSwig object:
In [2]:
csPointer = csSwig.GetCsound().__int__()
Import the ctcsound module and create an object called 'csct' from the ctcsound.Csound class, using the already existing opaque pointer to the csound instance as an argument:
In [3]:
import ctcsound
csct = ctcsound.Csound(pointer_=csPointer)
Now the csSwig object and the csct object are both tied to the same csound instance. Compile a csd file from the csSwig object...
In [4]:
csSwig.Compile("analogSynth01.csd")
Out[4]:
and play it from the csct object.
In [5]:
csct.perform()
Out[5]:
Reset the csound instance from the csSwig object:
In [6]:
csSwig.Reset()
Recompile the same csd file from the ctcs object...
In [7]:
csct.compile_("csound", "analogSynth01.csd")
Out[7]:
and play it from the csSwig object.
In [8]:
csSwig.Perform()
Out[8]:
Voilà!
In [9]:
csct.cleanup()
Out[9]: