OSX: install libs into bundle explicitly
[supercollider.git] / include / server / SC_Prototypes.h
blob8f19fd06f7794695cc45ed21f599f5d2da233b42
1 /*
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
22 #ifndef _SC_Prototypes_
23 #define _SC_Prototypes_
25 #include <ctype.h> // for size_t
27 #include "SC_Types.h"
28 #include "scsynthsend.h"
30 ////////////////////////////////////////////////////////////////////////
32 // replacement for calloc.
33 // calloc lazily zeroes memory on first touch. This is good for most purposes, but bad for realtime audio.
34 void* zalloc(size_t n, size_t size);
36 ////////////////////////////////////////////////////////////////////////
38 void World_Run(struct World *inWorld);
39 void World_Start(World *inWorld);
40 void World_SetSampleRate(struct World *inWorld, double inSampleRate);
42 extern "C" {
43 void World_Cleanup(World *inWorld);
44 void* World_Alloc(struct World *inWorld, size_t inByteSize);
45 void* World_Realloc(struct World *inWorld, void *inPtr, size_t inByteSize);
46 void World_Free(struct World *inWorld, void *inPtr);
47 void World_NRTLock(World *world);
48 void World_NRTUnlock(World *world);
51 size_t World_TotalFree(struct World *inWorld);
52 size_t World_LargestFreeChunk(struct World *inWorld);
55 int32 GetKey(struct Node *inNode);
56 int32 GetHash(struct Node *inNode);
57 bool World_AddNode(struct World *inWorld, struct Node* inNode);
58 bool World_RemoveNode(struct World *inWorld, struct Node* inNode);
60 extern "C" {
61 struct Node* World_GetNode(struct World *inWorld, int32 inID);
62 struct Graph* World_GetGraph(struct World *inWorld, int32 inID);
65 struct Group* World_GetGroup(struct World *inWorld, int32 inID);
67 int32 *GetKey(struct UnitDef *inUnitDef);
68 int32 GetHash(struct UnitDef *inUnitDef);
69 bool AddUnitDef(struct UnitDef* inUnitDef);
70 bool RemoveUnitDef(struct UnitDef* inUnitDef);
71 struct UnitDef* GetUnitDef(int32* inKey);
73 int32 *GetKey(struct BufGen *inBufGen);
74 int32 GetHash(struct BufGen *inBufGen);
75 bool AddBufGen(struct BufGen* inBufGen);
76 bool RemoveBufGen(struct BufGen* inBufGen);
77 struct BufGen* GetBufGen(int32* inKey);
79 int32 *GetKey(struct PlugInCmd *inPlugInCmd);
80 int32 GetHash(struct PlugInCmd *inPlugInCmd);
81 bool AddPlugInCmd(struct PlugInCmd* inPlugInCmd);
82 bool RemovePlugInCmd(struct PlugInCmd* inPlugInCmd);
83 struct PlugInCmd* GetPlugInCmd(int32* inKey);
84 int PlugIn_DoCmd(struct World *inWorld, int inSize, char *inArgs, struct ReplyAddress *inReply);
86 int32 *GetKey(struct GraphDef *inGraphDef);
87 int32 GetHash(struct GraphDef *inGraphDef);
88 void World_AddGraphDef(struct World *inWorld, struct GraphDef* inGraphDef);
89 void World_RemoveGraphDef(struct World *inWorld, struct GraphDef* inGraphDef);
90 struct GraphDef* World_GetGraphDef(struct World *inWorld, int32* inKey);
91 void World_FreeAllGraphDefs(World *inWorld);
92 void GraphDef_Free(GraphDef *inGraphDef);
93 void GraphDef_Define(World *inWorld, GraphDef *inList);
94 void GraphDef_FreeOverwritten(World *inWorld);
96 SCErr bufAlloc(struct SndBuf* buf, int numChannels, int numFrames, double sampleRate);
98 ////////////////////////////////////////////////////////////////////////
100 void Rate_Init(struct Rate *inRate, double inSampleRate, int inBufLength);
102 ////////////////////////////////////////////////////////////////////////
104 #define GRAPHDEF(inGraph) ((GraphDef*)((inGraph)->mNode.mDef))
105 #define GRAPH_PARAM_TABLE(inGraph) (GRAPHDEF(inGraph)->mParamSpecTable)
107 int Graph_New(struct World *inWorld, struct GraphDef *def, int32 inID, struct sc_msg_iter* args, struct Graph** outGraph,bool argtype=true);
108 void Graph_Ctor(struct World *inWorld, struct GraphDef *inGraphDef, struct Graph *graph, struct sc_msg_iter *msg,bool argtype);
109 void Graph_Dtor(struct Graph *inGraph);
110 int Graph_GetControl(struct Graph* inGraph, uint32 inIndex, float& outValue);
111 int Graph_GetControl(struct Graph* inGraph, int32 inHash, int32 *inName, uint32 inIndex, float& outValue);
112 void Graph_SetControl(struct Graph* inGraph, uint32 inIndex, float inValue);
113 void Graph_SetControl(struct Graph* inGraph, int32 inHash, int32 *inName, uint32 inIndex, float inValue);
114 void Graph_MapControl(Graph* inGraph, uint32 inIndex, uint32 inBus);
115 void Graph_MapControl(Graph* inGraph, int32 inHash, int32 *inName, uint32 inIndex, uint32 inBus);
116 void Graph_MapAudioControl(Graph* inGraph, uint32 inIndex, uint32 inBus);
117 void Graph_MapAudioControl(Graph* inGraph, int32 inHash, int32 *inName, uint32 inIndex, uint32 inBus);
118 void Graph_Trace(Graph *inGraph);
119 void Graph_RemoveID(World* inWorld, Graph *inGraph);
121 ////////////////////////////////////////////////////////////////////////
123 int Node_New(struct World *inWorld, struct NodeDef *def, int32 inID, struct Node **outNode);
124 void Node_Dtor(struct Node *inNode);
125 void Node_Remove(struct Node* s);
126 void Node_Delete(struct Node* inNode);
127 void Node_AddAfter(struct Node* s, struct Node *afterThisOne);
128 void Node_AddBefore(struct Node* s, struct Node *beforeThisOne);
129 void Node_Replace(struct Node* s, struct Node *replaceThisOne);
130 void Node_SetControl(Node* inNode, int inIndex, float inValue);
131 void Node_SetControl(Node* inNode, int32 inHash, int32 *inName, int inIndex, float inValue);
132 void Node_MapControl(Node* inNode, int inIndex, int inBus);
133 void Node_MapControl(Node* inNode, int32 inHash, int32 *inName, int inIndex, int inBus);
134 void Node_MapAudioControl(Node* inNode, int inIndex, int inBus);
135 void Node_MapAudioControl(Node* inNode, int32 inHash, int32 *inName, int inIndex, int inBus);
136 void Node_StateMsg(Node* inNode, int inState);
137 void Node_Trace(Node* inNode);
138 void Node_SendReply(Node* inNode, int replyID, const char* cmdName, int numArgs, const float* values);
139 void Node_SendReply(Node* inNode, int replyID, const char* cmdName, float value);
141 extern "C" {
142 void Node_SetRun(Node* inNode, int inRun);
143 void Node_SendTrigger(Node* inNode, int triggerID, float value);
144 void Node_End(struct Node* inNode);
145 void Node_NullCalc(struct Node* inNode);
146 void Unit_DoneAction(int doneAction, struct Unit* unit);
149 ////////////////////////////////////////////////////////////////////////
151 extern "C" {
152 void Group_Calc(Group *inGroup);
153 void Graph_Calc(struct Graph *inGraph);
156 int Group_New(World *inWorld, int32 inID, Group** outGroup);
157 void Group_Dtor(Group *inGroup);
158 void Group_DeleteAll(Group *inGroup);
159 void Group_DeepFreeGraphs(Group *inGroup);
160 void Group_AddHead (Group *s, Node *child);
161 void Group_AddTail (Group *s, Node *child);
162 void Group_Insert(Group *s, Node *child, int inIndex);
163 void Group_SetControl(struct Group* inGroup, uint32 inIndex, float inValue);
164 void Group_SetControl(struct Group *inGroup, int32 inHash, int32 *inName, uint32 inIndex, float inValue);
165 void Group_MapControl(Group* inGroup, uint32 inIndex, uint32 inBus);
166 void Group_MapControl(Group* inGroup, int32 inHash, int32 *inName, uint32 inIndex, uint32 inBus);
167 void Group_MapAudioControl(Group* inGroup, uint32 inIndex, uint32 inBus);
168 void Group_MapAudioControl(Group* inGroup, int32 inHash, int32 *inName, uint32 inIndex, uint32 inBus);
169 void Group_Trace(Group* inGroup);
170 void Group_DumpTree(Group* inGroup);
171 void Group_DumpTreeAndControls(Group* inGroup);
172 void Group_CountNodeTags(Group* inGroup, int* count);
173 void Group_CountNodeAndControlTags(Group* inGroup, int* count, int* controlAndDefCount);
174 void Group_QueryTree(Group* inGroup, big_scpacket* packet);
175 void Group_QueryTreeAndControls(Group* inGroup, big_scpacket *packet);
177 ////////////////////////////////////////////////////////////////////////
179 struct Unit* Unit_New(struct World *inWorld, struct UnitSpec *inUnitSpec, char*& memory);
180 void Unit_EndCalc(struct Unit *inUnit, int inNumSamples);
181 void Unit_End(struct Unit *inUnit);
183 void Unit_Dtor(struct Unit *inUnit);
185 extern "C" {
186 void Unit_ZeroOutputs(struct Unit *inUnit, int inNumSamples);
189 ////////////////////////////////////////////////////////////////////////
191 void SendDone(struct ReplyAddress *inReply, const char *inCommandName);
192 void SendDoneWithIntValue(struct ReplyAddress *inReply, const char *inCommandName, int value);
193 void SendFailure(struct ReplyAddress *inReply, const char *inCommandName, const char *errString);
194 void SendFailureWithBufnum(struct ReplyAddress *inReply, const char *inCommandName, const char *errString, uint32 index);
195 void ReportLateness(struct ReplyAddress *inReply, float32 seconds);
196 void DumpReplyAddress(struct ReplyAddress *inReplyAddress);
197 int32 Hash(struct ReplyAddress *inReplyAddress);
199 ////////////////////////////////////////////////////////////////////////
201 extern "C" {
202 int32 server_timeseed();
205 ////////////////////////////////////////////////////////////////////////
207 typedef bool (*AsyncStageFn)(World *inWorld, void* cmdData);
208 typedef void (*AsyncFreeFn)(World *inWorld, void* cmdData);
210 int PerformAsynchronousCommand
212 World *inWorld,
213 void* replyAddr,
214 const char* cmdName,
215 void *cmdData,
216 AsyncStageFn stage2, // stage2 is non real time
217 AsyncStageFn stage3, // stage3 is real time - completion msg performed if stage3 returns true
218 AsyncStageFn stage4, // stage4 is non real time - sends done if stage4 returns true
219 AsyncFreeFn cleanup,
220 int completionMsgSize,
221 void* completionMsgData
224 ////////////////////////////////////////////////////////////////////////
226 #endif