2 SuperCollider real time audio synthesis system
3 Copyright (c) 2002 James McCartney. All rights reserved.
4 http://www.audiosynth.com
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef _SC_SynthInterfaceTable_
22 #define _SC_SynthInterfaceTable_
25 #include "SC_SndBuf.h"
27 #include "SC_BufGen.h"
28 #include "SC_FifoMsg.h"
33 typedef bool (*AsyncStageFn
)(World
*inWorld
, void* cmdData
);
34 typedef void (*AsyncFreeFn
)(World
*inWorld
, void* cmdData
);
38 unsigned int mSineSize
;
39 float32
*mSineWavetable
;
43 // call printf for debugging. should not use in finished code.
44 int (*fPrint
)(const char *fmt
, ...);
46 // get a seed for a random number generator
50 bool (*fDefineUnit
)(const char *inUnitClassName
, size_t inAllocSize
,
51 UnitCtorFunc inCtor
, UnitDtorFunc inDtor
, uint32 inFlags
);
53 // define a command /cmd
54 bool (*fDefinePlugInCmd
)(const char *inCmdName
, PlugInCmdFunc inFunc
, void* inUserData
);
56 // define a command for a unit generator /u_cmd
57 bool (*fDefineUnitCmd
)(const char *inUnitClassName
, const char *inCmdName
, UnitCmdFunc inFunc
);
60 bool (*fDefineBufGen
)(const char *inName
, BufGenFunc inFunc
);
62 // clear all of the unit's outputs.
63 void (*fClearUnitOutputs
)(Unit
*inUnit
, int inNumSamples
);
65 // non real time memory allocation
66 void* (*fNRTAlloc
)(size_t inSize
);
67 void* (*fNRTRealloc
)(void *inPtr
, size_t inSize
);
68 void (*fNRTFree
)(void *inPtr
);
70 // real time memory allocation
71 void* (*fRTAlloc
)(World
*inWorld
, size_t inSize
);
72 void* (*fRTRealloc
)(World
*inWorld
, void *inPtr
, size_t inSize
);
73 void (*fRTFree
)(World
*inWorld
, void *inPtr
);
75 // call to set a Node to run or not.
76 void (*fNodeRun
)(struct Node
* node
, int run
);
78 // call to stop a Graph after the next buffer.
79 void (*fNodeEnd
)(struct Node
* graph
);
81 // send a trigger from a Node to clients
82 void (*fSendTrigger
)(struct Node
* inNode
, int triggerID
, float value
);
84 // send a reply message from a Node to clients
85 void (*fSendNodeReply
)(struct Node
* inNode
, int replyID
, const char* cmdName
, int numArgs
, const float* values
);
87 // sending messages between real time and non real time levels.
88 bool (*fSendMsgFromRT
)(World
*inWorld
, struct FifoMsg
& inMsg
);
89 bool (*fSendMsgToRT
)(World
*inWorld
, struct FifoMsg
& inMsg
);
93 int (*fSndFileFormatInfoFromStrings
)(SF_INFO
*info
,
94 const char *headerFormatString
, const char *sampleFormatString
);
98 struct Node
* (*fGetNode
)(World
*inWorld
, int inID
);
99 struct Graph
* (*fGetGraph
)(World
*inWorld
, int inID
);
101 void (*fNRTLock
)(World
*inWorld
);
102 void (*fNRTUnlock
)(World
*inWorld
);
104 bool mAltivecAvailable
;
106 void (*fGroup_DeleteAll
)(struct Group
* group
);
107 void (*fDoneAction
)(int doneAction
, struct Unit
*unit
);
109 int (*fDoAsynchronousCommand
)
115 AsyncStageFn stage2
, // stage2 is non real time
116 AsyncStageFn stage3
, // stage3 is real time - completion msg performed if stage3 returns true
117 AsyncStageFn stage4
, // stage4 is non real time - sends done if stage4 returns true
119 int completionMsgSize
,
120 void* completionMsgData
124 // fBufAlloc should only be called within a BufGenFunc
125 int (*fBufAlloc
)(SndBuf
*inBuf
, int inChannels
, int inFrames
, double inSampleRate
);
127 typedef struct InterfaceTable InterfaceTable
;
129 #define Print (*ft->fPrint)
130 #define RanSeed (*ft->fRanSeed)
131 #define NodeEnd (*ft->fNodeEnd)
132 #define NodeRun (*ft->fNodeRun)
133 #define DefineUnit (*ft->fDefineUnit)
134 #define DefinePlugInCmd (*ft->fDefinePlugInCmd)
135 #define DefineUnitCmd (*ft->fDefineUnitCmd)
136 #define DefineBufGen (*ft->fDefineBufGen)
137 #define ClearUnitOutputs (*ft->fClearUnitOutputs)
138 #define SendTrigger (*ft->fSendTrigger)
139 #define SendNodeReply (*ft->fSendNodeReply)
140 #define SendMsgFromRT (*ft->fSendMsgFromRT)
141 #define SendMsgToRT (*ft->fSendMsgToRT)
142 #define DoneAction (*ft->fDoneAction)
144 #define NRTAlloc (*ft->fNRTAlloc)
145 #define NRTRealloc (*ft->fNRTRealloc)
146 #define NRTFree (*ft->fNRTFree)
148 #define RTAlloc (*ft->fRTAlloc)
149 #define RTRealloc (*ft->fRTRealloc)
150 #define RTFree (*ft->fRTFree)
152 #define SC_GetNode (*ft->fGetNode)
153 #define SC_GetGraph (*ft->fGetGraph)
155 #define NRTLock (*ft->fNRTLock)
156 #define NRTUnlock (*ft->fNRTUnlock)
158 #define BufAlloc (*ft->fBufAlloc)
160 #define GroupDeleteAll (*ft->fGroup_DeleteAll)
162 #define SndFileFormatInfoFromStrings (*ft->fSndFileFormatInfoFromStrings)
164 #define DoAsynchronousCommand (*ft->fDoAsynchronousCommand)
166 #define DefineSimpleUnit(name) \
167 (*ft->fDefineUnit)(#name, sizeof(name), (UnitCtorFunc)&name##_Ctor, 0, 0);
169 #define DefineDtorUnit(name) \
170 (*ft->fDefineUnit)(#name, sizeof(name), (UnitCtorFunc)&name##_Ctor, \
171 (UnitDtorFunc)&name##_Dtor, 0);
173 #define DefineSimpleCantAliasUnit(name) \
174 (*ft->fDefineUnit)(#name, sizeof(name), (UnitCtorFunc)&name##_Ctor, 0, kUnitDef_CantAliasInputsToOutputs);
176 #define DefineDtorCantAliasUnit(name) \
177 (*ft->fDefineUnit)(#name, sizeof(name), (UnitCtorFunc)&name##_Ctor, \
178 (UnitDtorFunc)&name##_Dtor, kUnitDef_CantAliasInputsToOutputs);
180 #ifdef STATIC_PLUGINS
181 #define PluginLoad(name) void name##_Load(InterfaceTable *inTable)
184 #define PluginLoad(name) extern "C" void load(InterfaceTable *inTable)
186 #define PluginLoad(name) void load(InterfaceTable *inTable)