Loading...
Searching...
No Matches
csdl.h File Reference

Declares the Csound plugin opcode interface. More...

`#include "interlocks.h"`
`#include "csoundCore.h"`

## Macros

#define | Str(x)
#define | LINKAGE
| The LINKAGE macro sets up linking of opcode list.
#define | LINKAGE_BUILTIN(name)
| The LINKAGE_BUILTIN macro sets up linking of opcode list for builtin opcodes which must have unique function names.
#define | FLINKAGE
| LINKAGE for f-table plugins.
#define | FLINKAGE_BUILTIN(name)

## Functions

PUBLIC int64_t | csound_opcode_init (CSOUND *, OENTRY **)
PUBLIC NGFENS * | csound_fgen_init (CSOUND *)
PUBLIC int | csoundModuleCreate (CSOUND *)
PUBLIC int | csoundModuleInit (CSOUND *)
PUBLIC int | csoundModuleDestroy (CSOUND *)
PUBLIC const char * | csoundModuleErrorCodeToString (int)
PUBLIC int | csoundModuleInfo (void)

## Detailed Description

Declares the Csound plugin opcode interface.

Author
  John P. ffitch, Michael Gogins, Matt Ingalls, John D. Ramsdell, Istvan Varga, Victor Lazzarini.

Plugin opcodes can extend the functionality of Csound, providing new functionality that is exposed as opcodes in the Csound language. Plugins need to include this header file only, as it will bring all necessary data structures to interact with Csound. It is not necessary for plugins to link to the libcsound library, as plugin opcodes will always receive a CSOUND* pointer (to the CSOUND_ struct) which contains all the API functions inside.

This is the basic template for a plugin opcode. See the manual for further details on accepted types and function call rates. The use of the LINKAGE macro is highly recommended, rather than calling the functions directly.

#include "csdl.h"
typedef struct {
OPDS h;
MYFLT *out;
MYFLT *in1, *in2;
} OPCODE;
static int op_init(CSOUND *csound, OPCODE *p)
{
// Intialization code goes here
return OK;
}
static int op_k(CSOUND *csound, OPCODE *p)
{
// code called at k-rate goes here
return OK;
}
// You can use these functions if you need to prepare and cleanup things on
// loading/unloading the library, but they can be absent if you don't need them
PUBLIC int csoundModuleCreate(CSOUND *csound)
{
return 0;
}
PUBLIC int csoundModuleInit(CSOUND *csound)
{
OENTRY *ep = (OENTRY *) &(localops[0]);
int err = 0;
while (ep->opname != NULL) {
err |= csound->AppendOpcode(csound,
ep->opname, ep->dsblksiz, ep->thread,
ep->outypes, ep->intypes,
(int (*)(CSOUND *, void *)) ep->iopadr,
(int (*)(CSOUND *, void *)) ep->kopadr,
(int (*)(CSOUND *, void *)) ep->aopadr);
ep++;
}
return err;
}
PUBLIC int csoundModuleDestroy(CSOUND *csound)
{
// Called when the plugin opcode is unloaded, usually when Csound terminates.
return 0;
}
static OENTRY localops[] =
{
{ "opcode", sizeof(OPCODE), 0, 3, "i", "ii", (SUBR)op_init, (SUBR)op_k }}
};
LINKAGE(localops)
csdl.h
Declares the Csound plugin opcode interface.
csoundModuleInit
PUBLIC int csoundModuleInit(CSOUND *)
csoundModuleDestroy
PUBLIC int csoundModuleDestroy(CSOUND *)
csoundModuleCreate
PUBLIC int csoundModuleCreate(CSOUND *)
LINKAGE
#define LINKAGE
The LINKAGE macro sets up linking of opcode list.
Definition csdl.h:149
OPDS
struct opds OPDS
This struct holds the info for one opcode in a concrete instrument instance in performance.
OK
#define OK
Definition csoundCore.h:96
OPCODE
#define OPCODE
Definition csoundCore.h:781
OENTRY
struct oentry OENTRY
SUBR
int(* SUBR)(CSOUND *, void *)
Definition csoundCore.h:600
CSOUND
struct CSOUND_ CSOUND
Definition csound.h:475
PUBLIC
#define PUBLIC
Definition csound.h:277
CSOUND_::AppendOpcode
int(* AppendOpcode)(CSOUND *, const char *opname, int dsblksiz, int flags, int thread, const char *outypes, const char *intypes, int(*iopadr)(CSOUND *, void *), int(*kopadr)(CSOUND *, void *), int(*aopadr)(CSOUND *, void *))
Definition csoundCore.h:1332
oentry::kopadr
int(* kopadr)(CSOUND *, void *p)
Definition csoundCore.h:299
oentry::intypes
char * intypes
Definition csoundCore.h:297
oentry::opname
char * opname
Definition csoundCore.h:292
oentry::dsblksiz
uint16 dsblksiz
Definition csoundCore.h:293
oentry::aopadr
int(* aopadr)(CSOUND *, void *p)
Definition csoundCore.h:300
oentry::iopadr
int(* iopadr)(CSOUND *, void *p)
Definition csoundCore.h:298
oentry::thread
uint8_t thread
Definition csoundCore.h:295
oentry::outypes
char * outypes
Definition csoundCore.h:296

## Macro Definition Documentation

## FLINKAGE

#define FLINKAGE

Value:
PUBLIC NGFENS *csound_fgen_init(CSOUND *csound) \
{ (void) csound; return localfgens; } \
PUBLIC int csoundModuleInfo(void) \
{ return ((CS_APIVERSION << 16) + (CS_APISUBVER << 8) + (int) sizeof(MYFLT)); }
csoundModuleInfo
PUBLIC int csoundModuleInfo(void)
csound_fgen_init
PUBLIC NGFENS * csound_fgen_init(CSOUND *)
NGFENS
Definition csoundCore.h:702

LINKAGE for f-table plugins.

## FLINKAGE_BUILTIN

#define FLINKAGE_BUILTIN | ( |  | name | ) |

Value:
PUBLIC NGFENS *csound_fgen_init(CSOUND *csound) \
{ (void) csound; return name; } \
PUBLIC int csoundModuleInfo(void) \
{ return ((CS_APIVERSION << 16) + (CS_APISUBVER << 8) + (int) sizeof(MYFLT)); }

## LINKAGE

#define LINKAGE

Value:
PUBLIC int64_t csound_opcode_init(CSOUND *csound, OENTRY **ep) \
{ (void) csound; *ep = localops; return (int64_t) sizeof(localops); } \
PUBLIC int csoundModuleInfo(void) \
{ return ((CS_APIVERSION << 16) + (CS_APISUBVER << 8) + (int) sizeof(MYFLT)); }
csound_opcode_init
PUBLIC int64_t csound_opcode_init(CSOUND *, OENTRY **)

The LINKAGE macro sets up linking of opcode list.

## LINKAGE_BUILTIN

#define LINKAGE_BUILTIN | ( |  | name | ) |

Value:
PUBLIC int64_t csound_opcode_init(CSOUND *csound, OENTRY **ep) \
{ (void) csound; *ep = name; return (int64_t) (sizeof(name)); } \
PUBLIC int csoundModuleInfo(void) \
{ return ((CS_APIVERSION << 16) + (CS_APISUBVER << 8) + (int) sizeof(MYFLT)); }

The LINKAGE_BUILTIN macro sets up linking of opcode list for builtin opcodes which must have unique function names.

## Str

#define Str | ( |  | x | ) |

Value:
(csound->LocalizeString(x))

## Function Documentation

## csound_fgen_init()

PUBLIC NGFENS * csound_fgen_init | ( | CSOUND * |  | ) |

References PUBLIC.

## csound_opcode_init()

PUBLIC int64_t csound_opcode_init | ( | CSOUND * | ,
|  | OENTRY ** | )

References PUBLIC.

## csoundModuleCreate()

PUBLIC int csoundModuleCreate | ( | CSOUND * |  | ) |

References PUBLIC.

## csoundModuleDestroy()

PUBLIC int csoundModuleDestroy | ( | CSOUND * |  | ) |

References PUBLIC.

## csoundModuleErrorCodeToString()

PUBLIC const char * csoundModuleErrorCodeToString | ( | int |  | ) |

References PUBLIC.

## csoundModuleInfo()

PUBLIC int csoundModuleInfo | ( | void |  | ) |

References PUBLIC.

## csoundModuleInit()

PUBLIC int csoundModuleInit | ( | CSOUND * |  | ) |

References PUBLIC.