pyinit Opcodes

pyinit — Initialize the Python interpreter.

Syntax

          
            pyinit
          
        

Description

Plugin opcode in py. This opcode is part of the plugin repository and has to be installed separately. The plugin repository can be found here: https://github.com/csound/plugins

In Csound, you must first invoke the pyinit opcode in the orchestra header to initialize the Python interpreter, before using any of the other Python opcodes.

But if you use the Python opcodes within CsoundAC, or from a python frontend using the csnd6 module, Csound, you need not invoke pyinit, because the Python interpreter will have already been initialized. In this case, CsoundAC (or the csnd6 python module) automatically creates a Python interface to the Csound API. In CsoundAC, this exists in the form a global instance of the CsoundAC.CppSound class named csound. From a python frontend which imports the csnd6 module, the name of the variable holding the Csound instance will depend on the frontend code. Therefore, Python code written in the Csound orchestra has access to the global csound object.

The running Csound instance in which pyinit has been called is stored in a global python variable called _CSOUND_. This holds the actual memory address of the instance and it can be used with the csnd6 module via the csoundGetInstance(instance) call. This python function returns an object that can be used with all the Csound API functions.

See also

Python Opcodes

Credits

Copyright (c) 2002 by Maurizio Umberto Puxeddu. All rights reserved. Portions copyright (c) 2004 and 2005 by Michael Gogins, and (c) 2013, V Lazzarini.