Logo Search packages:      
Sourcecode: csound version File versions  Download package

csound.h File Reference


Detailed Description

Declares the public Csound application programming interface (API).

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

The purposes of the Csound API are as follows:

Users

Users of the Csound API fall into two main categories: hosts, and plugins.

Hosts using the Csound API must #include <csound.h>, and link with the Csound API library. Plugin libraries should #include <csdl.h> to get access to the API function pointers in the CSOUND structure, and do not need to link with the Csound API library. Only one of csound.h and csdl.h may be included by a compilation unit.

Hosts must first create an instance of Csound using the csoundCreate API function. When hosts are finished using Csound, they must destroy the instance of csound using the csoundDestroy API function. Most of the other Csound API functions take the Csound instance as their first argument. Hosts can only call the standalone API functions declared in csound.h.

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)
 {
     CSOUND *csound = csoundCreate(NULL);
     int result = csoundCompile(csound, argc, argv);
     if (!result)
       result = csoundPerform(csound);
     csoundDestroy(csound);
     return (result >= 0 ? 0 : result);
 }

All opcodes, including plugins, receive a pointer to their host instance of Csound as the first argument. Therefore, plugins MUST NOT compile, perform, or destroy the host instance of Csound, and MUST call the Csound API function pointers off the Csound instance pointer.

 MYFLT sr = csound->GetSr(csound);

In general, plugins should ONLY access Csound functionality through the API function pointers and public members of the CSOUND structure.

Definition in file csound.h.

#include "sysdep.h"
#include "text.h"
#include <stdarg.h>
#include "cfgvar.h"
#include "msg_attr.h"
#include "version.h"

Go to the source code of this file.

Classes

struct  CsoundChannelListEntry_
struct  CsoundRandMTState_
struct  csRtAudioParams
struct  opcodeListEntry
struct  pvsdat_ext
struct  RTCLOCK_S

Defines

#define CSOUND_AUDIO_CHANNEL   2
#define CSOUND_CALLBACK_KBD_EVENT   (0x00000001U)
#define CSOUND_CALLBACK_KBD_TEXT   (0x00000002U)
#define CSOUND_CHANNEL_TYPE_MASK   15
#define CSOUND_CONTROL_CHANNEL   1
#define CSOUND_CONTROL_CHANNEL_EXP   3
#define CSOUND_CONTROL_CHANNEL_INT   1
#define CSOUND_CONTROL_CHANNEL_LIN   2
#define CSOUND_EXITJMP_SUCCESS   (256)
#define CSOUND_INPUT_CHANNEL   16
#define CSOUND_OUTPUT_CHANNEL   32
#define CSOUND_SPIN_LOCK
#define CSOUND_SPIN_UNLOCK
#define CSOUND_STRING_CHANNEL   3
#define CSOUNDINIT_NO_ATEXIT   2
#define CSOUNDINIT_NO_SIGNAL_HANDLER   1
#define csoundSpinLock(spinlock)
#define csoundSpinUnLock(spinlock)
#define PUBLIC

Typedefs

typedef struct CSOUND_ CSOUND
typedef void(* CsoundChannelIOCallback_t )(CSOUND *csound, const char *channelName, MYFLT *channelValuePtr, int channelType)
typedef struct
CsoundChannelListEntry_ 
CsoundChannelListEntry
typedef struct CsoundRandMTState_ CsoundRandMTState
typedef struct pvsdat_ext PVSDATEXT
typedef struct RTCLOCK_S RTCLOCK
typedef struct windat_ WINDAT
typedef struct xyindat_ XYINDAT

Enumerations

enum  CSOUND_FILETYPES {
  CSFTYPE_UNIFIED_CSD = 1, CSFTYPE_ORCHESTRA = 2, CSFTYPE_SCORE = 3, CSFTYPE_ORC_INCLUDE = 4,
  CSFTYPE_SCO_INCLUDE = 5, CSFTYPE_SCORE_OUT = 6, CSFTYPE_SCOT = 7, CSFTYPE_OPTIONS = 8,
  CSFTYPE_EXTRACT_PARMS = 9, CSFTYPE_RAW_AUDIO = 10, CSFTYPE_IRCAM = 11, CSFTYPE_AIFF = 12,
  CSFTYPE_AIFC = 13, CSFTYPE_WAVE = 14, CSFTYPE_AU = 15, CSFTYPE_SD2 = 16,
  CSFTYPE_W64 = 17, CSFTYPE_WAVEX = 18, CSFTYPE_FLAC = 19, CSFTYPE_CAF = 20,
  CSFTYPE_AVR = 21, CSFTYPE_HTK = 22, CSFTYPE_MAT4 = 23, CSFTYPE_MAT5 = 24,
  CSFTYPE_NIST = 25, CSFTYPE_PAF = 26, CSFTYPE_PVF = 27, CSFTYPE_SDS = 28,
  CSFTYPE_SVX = 29, CSFTYPE_VOC = 30, CSFTYPE_XI = 31, CSFTYPE_UNKNOWN_AUDIO = 32,
  CSFTYPE_SOUNDFONT = 33, CSFTYPE_STD_MIDI = 34, CSFTYPE_MIDI_SYSEX = 35, CSFTYPE_HETRO = 36,
  CSFTYPE_PVC = 37, CSFTYPE_PVCEX = 38, CSFTYPE_CVANAL = 39, CSFTYPE_LPC = 40,
  CSFTYPE_ATS = 41, CSFTYPE_LORIS = 42, CSFTYPE_SDIF = 43, CSFTYPE_HRTF = 44,
  CSFTYPE_VST_PLUGIN = 45, CSFTYPE_LADSPA_PLUGIN = 46, CSFTYPE_SNAPSHOT = 47, CSFTYPE_FTABLES_TEXT = 48,
  CSFTYPE_FTABLES_BINARY = 49, CSFTYPE_XSCANU_MATRIX = 50, CSFTYPE_FLOATS_TEXT = 51, CSFTYPE_FLOATS_BINARY = 52,
  CSFTYPE_INTEGER_TEXT = 53, CSFTYPE_INTEGER_BINARY = 54, CSFTYPE_IMAGE_PNG = 59, CSFTYPE_POSTSCRIPT = 55,
  CSFTYPE_SCRIPT_TEXT = 56, CSFTYPE_OTHER_TEXT = 57, CSFTYPE_OTHER_BINARY = 58, CSFTYPE_UNKNOWN = 0
}
enum  CSOUND_STATUS {
  CSOUND_SUCCESS = 0, CSOUND_ERROR = -1, CSOUND_INITIALIZATION = -2, CSOUND_PERFORMANCE = -3,
  CSOUND_MEMORY = -4, CSOUND_SIGNAL = -5
}

Functions

PUBLIC void csoundAddSpinSample (CSOUND *csound, int frame, int channel, MYFLT sample)
PUBLIC int csoundAppendOpcode (CSOUND *, const char *opname, int dsblksiz, int thread, const char *outypes, const char *intypes, int(*iopadr)(CSOUND *, void *), int(*kopadr)(CSOUND *, void *), int(*aopadr)(CSOUND *, void *))
PUBLIC int csoundChanIASet (CSOUND *, const MYFLT *value, int n)
PUBLIC int csoundChanIASetSample (CSOUND *, int channel, int frame, MYFLT sample)
PUBLIC int csoundChanIKSet (CSOUND *, MYFLT value, int n)
PUBLIC int csoundChanIKSetValue (CSOUND *, int channel, MYFLT value)
PUBLIC int csoundChanOAGet (CSOUND *, MYFLT *value, int n)
PUBLIC MYFLT csoundChanOAGetSample (CSOUND *, int channel, int frame)
PUBLIC int csoundChanOKGet (CSOUND *, MYFLT *value, int n)
PUBLIC MYFLT csoundChanOKGetValue (CSOUND *, int channel)
PUBLIC int csoundCleanup (CSOUND *)
PUBLIC int csoundCloseLibrary (void *library)
PUBLIC int csoundCompile (CSOUND *, int argc, char **argv)
PUBLIC CSOUND * csoundCreate (void *hostData)
PUBLIC void * csoundCreateBarrier (unsigned int max)
PUBLIC int csoundCreateGlobalVariable (CSOUND *, const char *name, size_t nbytes)
PUBLIC void * csoundCreateMutex (int isRecursive)
PUBLIC void * csoundCreateThread (uintptr_t(*threadRoutine)(void *), void *userdata)
PUBLIC void * csoundCreateThreadLock (void)
PUBLIC void csoundDeleteChannelList (CSOUND *, CsoundChannelListEntry *lst)
PUBLIC void csoundDeleteUtilityList (CSOUND *, char **lst)
PUBLIC void csoundDestroy (CSOUND *)
PUBLIC int csoundDestroyBarrier (void *barrier)
PUBLIC int csoundDestroyGlobalVariable (CSOUND *, const char *name)
void PUBLIC csoundDestroyMessageBuffer (CSOUND *csound)
PUBLIC void csoundDestroyMutex (void *mutex_)
PUBLIC void csoundDestroyThreadLock (void *lock)
PUBLIC void csoundDisposeOpcodeList (CSOUND *, opcodeListEntry *opcodelist)
void PUBLIC csoundEnableMessageBuffer (CSOUND *csound, int toStdOut)
PUBLIC MYFLT csoundGet0dBFS (CSOUND *)
PUBLIC int csoundGetAPIVersion (void)
PUBLIC int * csoundGetChannelLock (CSOUND *, const char *name, int type)
PUBLIC int csoundGetChannelPtr (CSOUND *, MYFLT **p, const char *name, int type)
PUBLIC int csoundGetControlChannelParams (CSOUND *, const char *name, MYFLT *dflt, MYFLT *min, MYFLT *max)
PUBLIC double csoundGetCPUTime (RTCLOCK *)
PUBLIC void * csoundGetCurrentThreadId (void)
PUBLIC int csoundGetDebug (CSOUND *)
PUBLIC const char * csoundGetEnv (CSOUND *csound, const char *name)
PUBLIC const char * csoundGetFirstMessage (CSOUND *csound)
int PUBLIC csoundGetFirstMessageAttr (CSOUND *csound)
PUBLIC void * csoundGetHostData (CSOUND *)
PUBLIC MYFLT * csoundGetInputBuffer (CSOUND *)
PUBLIC long csoundGetInputBufferSize (CSOUND *)
PUBLIC MYFLT csoundGetKr (CSOUND *)
PUBLIC int csoundGetKsmps (CSOUND *)
PUBLIC void * csoundGetLibrarySymbol (void *library, const char *symbolName)
int PUBLIC csoundGetMessageCnt (CSOUND *csound)
PUBLIC int csoundGetMessageLevel (CSOUND *)
PUBLIC int csoundGetNchnls (CSOUND *)
PUBLIC MYFLT * csoundGetOutputBuffer (CSOUND *)
PUBLIC long csoundGetOutputBufferSize (CSOUND *)
PUBLIC const char * csoundGetOutputFileName (CSOUND *)
PUBLIC uint32_t csoundGetRandomSeedFromTime (void)
PUBLIC double csoundGetRealTime (RTCLOCK *)
PUBLIC void ** csoundGetRtPlayUserData (CSOUND *)
PUBLIC void ** csoundGetRtRecordUserData (CSOUND *)
PUBLIC int csoundGetSampleFormat (CSOUND *)
PUBLIC int csoundGetSampleSize (CSOUND *)
PUBLIC MYFLT csoundGetScoreOffsetSeconds (CSOUND *)
PUBLIC double csoundGetScoreTime (CSOUND *)
PUBLIC int csoundGetSizeOfMYFLT (void)
PUBLIC MYFLT * csoundGetSpin (CSOUND *)
PUBLIC MYFLT * csoundGetSpout (CSOUND *csound)
PUBLIC MYFLT csoundGetSpoutSample (CSOUND *csound, int frame, int channel)
PUBLIC MYFLT csoundGetSr (CSOUND *)
PUBLIC int csoundGetStrVarMaxLen (CSOUND *)
PUBLIC int csoundGetTable (CSOUND *, MYFLT **tablePtr, int tableNum)
PUBLIC const char * csoundGetUtilityDescription (CSOUND *, const char *utilName)
PUBLIC int csoundGetVersion (void)
PUBLIC int csoundInitialize (int *argc, char ***argv, int flags)
PUBLIC int csoundInitializeCscore (CSOUND *, FILE *insco, FILE *outsco)
PUBLIC void csoundInitTimerStruct (RTCLOCK *)
PUBLIC void csoundInputMessage (CSOUND *, const char *message)
PUBLIC int csoundIsScorePending (CSOUND *)
PUBLIC uintptr_t csoundJoinThread (void *thread)
PUBLIC void csoundKeyPress (CSOUND *, char c)
PUBLIC int csoundListChannels (CSOUND *, CsoundChannelListEntry **lst)
PUBLIC char ** csoundListUtilities (CSOUND *)
PUBLIC char * csoundLocalizeString (const char *s)
PUBLIC void csoundLockMutex (void *mutex_)
PUBLIC int csoundLockMutexNoWait (void *mutex_)
PUBLIC CS_PRINTF2 void csoundMessage (CSOUND *, const char *format,...)
PUBLIC CS_PRINTF3 void csoundMessageS (CSOUND *, int attr, const char *format,...)
PUBLIC void csoundMessageV (CSOUND *, int attr, const char *format, va_list args)
PUBLIC int csoundNewOpcodeList (CSOUND *, opcodeListEntry **opcodelist)
PUBLIC void csoundNotifyThreadLock (void *lock)
PUBLIC int csoundOpenLibrary (void **library, const char *libraryPath)
PUBLIC int csoundPerform (CSOUND *)
PUBLIC int csoundPerformBuffer (CSOUND *)
PUBLIC int csoundPerformKsmps (CSOUND *)
PUBLIC int csoundPerformKsmpsAbsolute (CSOUND *)
void PUBLIC csoundPopFirstMessage (CSOUND *csound)
PUBLIC int csoundPreCompile (CSOUND *)
PUBLIC int csoundPvsinSet (CSOUND *, const PVSDATEXT *fin, int n)
PUBLIC int csoundPvsoutGet (CSOUND *csound, PVSDATEXT *fout, int n)
PUBLIC void * csoundQueryGlobalVariable (CSOUND *, const char *name)
PUBLIC void * csoundQueryGlobalVariableNoCheck (CSOUND *, const char *name)
PUBLIC int csoundQueryInterface (const char *name, void **iface, int *version)
PUBLIC int csoundRand31 (int *seedVal)
PUBLIC uint32_t csoundRandMT (CsoundRandMTState *p)
PUBLIC int csoundRegisterSenseEventCallback (CSOUND *, void(*func)(CSOUND *, void *), void *userData)
PUBLIC void csoundRemoveCallback (CSOUND *, int(*func)(void *, void *, unsigned int))
PUBLIC void csoundReset (CSOUND *)
PUBLIC void csoundRewindScore (CSOUND *)
PUBLIC long csoundRunCommand (const char *const *argv, int noWait)
PUBLIC int csoundRunUtility (CSOUND *, const char *name, int argc, char **argv)
PUBLIC int csoundScoreEvent (CSOUND *, char type, const MYFLT *pFields, long numFields)
PUBLIC int csoundScoreExtract (CSOUND *, FILE *inFile, FILE *outFile, FILE *extractFile)
PUBLIC int csoundScoreSort (CSOUND *, FILE *inFile, FILE *outFile)
PUBLIC void csoundSeedRandMT (CsoundRandMTState *p, const uint32_t *initKey, uint32_t keyLength)
PUBLIC int csoundSetCallback (CSOUND *, int(*func)(void *userData, void *p, unsigned int type), void *userData, unsigned int typeMask)
PUBLIC void csoundSetChannelIOCallback (CSOUND *, CsoundChannelIOCallback_t func)
PUBLIC int csoundSetControlChannelParams (CSOUND *, const char *name, int type, MYFLT dflt, MYFLT min, MYFLT max)
PUBLIC void csoundSetCscoreCallback (CSOUND *, void(*cscoreCallback_)(CSOUND *))
PUBLIC void csoundSetDebug (CSOUND *, int debug)
PUBLIC void csoundSetDrawGraphCallback (CSOUND *, void(*drawGraphCallback_)(CSOUND *, WINDAT *windat))
PUBLIC void csoundSetExitGraphCallback (CSOUND *, int(*exitGraphCallback_)(CSOUND *))
PUBLIC void csoundSetExternalMidiErrorStringCallback (CSOUND *, const char *(*func)(int))
PUBLIC void csoundSetExternalMidiInCloseCallback (CSOUND *, int(*func)(CSOUND *, void *userData))
PUBLIC void csoundSetExternalMidiInOpenCallback (CSOUND *, int(*func)(CSOUND *, void **userData, const char *devName))
PUBLIC void csoundSetExternalMidiOutCloseCallback (CSOUND *, int(*func)(CSOUND *, void *userData))
PUBLIC void csoundSetExternalMidiOutOpenCallback (CSOUND *, int(*func)(CSOUND *, void **userData, const char *devName))
PUBLIC void csoundSetExternalMidiReadCallback (CSOUND *, int(*func)(CSOUND *, void *userData, unsigned char *buf, int nBytes))
PUBLIC void csoundSetExternalMidiWriteCallback (CSOUND *, int(*func)(CSOUND *, void *userData, const unsigned char *buf, int nBytes))
PUBLIC void csoundSetFileOpenCallback (CSOUND *p, void(*func)(CSOUND *, const char *, int, int, int))
PUBLIC int csoundSetGlobalEnv (const char *name, const char *value)
PUBLIC void csoundSetHostData (CSOUND *, void *hostData)
PUBLIC void csoundSetHostImplementedAudioIO (CSOUND *, int state, int bufSize)
PUBLIC void csoundSetInputValueCallback (CSOUND *, void(*inputValueCalback_)(CSOUND *, const char *channelName, MYFLT *value))
PUBLIC int csoundSetIsGraphable (CSOUND *, int isGraphable)
PUBLIC void csoundSetKillGraphCallback (CSOUND *, void(*killGraphCallback_)(CSOUND *, WINDAT *windat))
PUBLIC void csoundSetKillXYinCallback (CSOUND *, void(*killXYinCallback_)(CSOUND *, XYINDAT *))
PUBLIC void csoundSetLanguage (cslanguage_t lang_code)
PUBLIC void csoundSetMakeGraphCallback (CSOUND *, void(*makeGraphCallback_)(CSOUND *, WINDAT *windat, const char *name))
PUBLIC void csoundSetMakeXYinCallback (CSOUND *, void(*makeXYinCallback_)(CSOUND *, XYINDAT *, MYFLT x, MYFLT y))
PUBLIC void csoundSetMessageCallback (CSOUND *, void(*csoundMessageCallback_)(CSOUND *, int attr, const char *format, va_list valist))
PUBLIC void csoundSetMessageLevel (CSOUND *, int messageLevel)
PUBLIC void csoundSetOutputValueCallback (CSOUND *, void(*outputValueCalback_)(CSOUND *, const char *channelName, MYFLT value))
PUBLIC void csoundSetPlayopenCallback (CSOUND *, int(*playopen__)(CSOUND *, const csRtAudioParams *parm))
PUBLIC void csoundSetReadXYinCallback (CSOUND *, void(*readXYinCallback_)(CSOUND *, XYINDAT *))
PUBLIC void csoundSetRecopenCallback (CSOUND *, int(*recopen_)(CSOUND *, const csRtAudioParams *parm))
PUBLIC void csoundSetRtcloseCallback (CSOUND *, void(*rtclose__)(CSOUND *))
PUBLIC void csoundSetRtplayCallback (CSOUND *, void(*rtplay__)(CSOUND *, const MYFLT *outBuf, int nbytes))
PUBLIC void csoundSetRtrecordCallback (CSOUND *, int(*rtrecord__)(CSOUND *, MYFLT *inBuf, int nbytes))
PUBLIC void csoundSetScoreOffsetSeconds (CSOUND *, MYFLT time)
PUBLIC void csoundSetScorePending (CSOUND *, int pending)
PUBLIC void csoundSetYieldCallback (CSOUND *, int(*yieldCallback_)(CSOUND *))
PUBLIC void csoundSleep (size_t milliseconds)
PUBLIC void csoundStop (CSOUND *)
PUBLIC MYFLT csoundTableGet (CSOUND *, int table, int index)
PUBLIC int csoundTableLength (CSOUND *, int table)
PUBLIC void csoundTableSet (CSOUND *, int table, int index, MYFLT value)
PUBLIC void csoundUnlockMutex (void *mutex_)
PUBLIC int csoundWaitBarrier (void *barrier)
PUBLIC int csoundWaitThreadLock (void *lock, size_t milliseconds)
PUBLIC void csoundWaitThreadLockNoTimeout (void *lock)
void PUBLIC sigcpy (MYFLT *dest, MYFLT *src, int size)


Generated by  Doxygen 1.6.0   Back to index