 call either the standalone API functions defined in csound.h, e.g.
csoundGetSr(csound), or the function pointers in the Csound instance structure, e.g. csound->GetSr(csound). Each function in the Csound API has a corresponding function pointer in the Csound instance structure.
Here is the complete code for the simplest possible Csound API host, a command-line Csound application:
#include <csound.h> int main(int argc, char **argv) { void *csound = csoundCreate(0); int result = csoundPerform(csound, argc, argv); csoundCleanup(csound); csoundReset(csound); csoundDestroy(csound); return result; }
All opcodes, including plugins, receive a pointer to their host instance of Csound in the opcode structure itself. Therefore, plugins MUST NOT create an instance of Csound, and MUST call the Csound API function pointers off the Csound instance pointer in the insdshead member of the OPDS structure, for example:
MYFLT sr = MyOpcodeStructure->h.insdshead->csound->GetSr(MyOpcodeStructure->h.insdshead->csound);
In general, plugins should ONLY access Csound functionality through the API function pointers.
TODO
The Csound API is not finished. At this time, Csound does not support creating multiple instances of Csound in a single process, and the Csound API functions do not all take a pointer to the Csound instance as their first argument. This needs to be changed.
In addition, some new functions need to be added to the API for various purposes:
Definition in file csound.h.
#include "sysdep.h"
#include "cwindow.h"
#include "opcode.h"
#include <stdarg.h>
Go to the source code of this file.