1 /*
2 SuperCollider real time audio synthesis system
3 Copyright (c) 2002 James McCartney. All rights reserved.
4 http://www.audiosynth.com
5
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.
10
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.
15
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
19 */
20
21
22 #pragma once
23
24 #include "SC_Types.h"
25 #include "SC_Rate.h"
26 #include "SC_SndBuf.h"
27 #include "SC_RGen.h"
28
29 #ifdef SUPERNOVA
30 namespace nova {
31 class spin_lock;
32 class padded_rw_spinlock;
33 }
34 #endif
35
36 struct World {
37 // a pointer to private implementation, not available to plug-ins.
38 struct HiddenWorld* hw;
39
40 // a pointer to the table of function pointers that implement the plug-ins'
41 // interface to the server.
42 struct InterfaceTable* ft;
43
44 // data accessible to plug-ins :
45 double mSampleRate;
46 int mBufLength;
47 int mBufCounter;
48
49 uint32 mNumAudioBusChannels;
50 uint32 mNumControlBusChannels;
51 uint32 mNumInputs;
52 uint32 mNumOutputs;
53
54 // vector of samples for all audio busses
55 float* mAudioBus;
56
57 // vector of samples for all control busses
58 float* mControlBus;
59
60 // these tell if a bus has been written to during a control period
61 // if the value is equal to mBufCounter then the buss has been touched
62 // this control period.
63 int32* mAudioBusTouched;
64 int32* mControlBusTouched;
65
66 uint32 mNumSndBufs;
67 SndBuf* mSndBufs;
68 SndBuf* mSndBufsNonRealTimeMirror;
69 SndBufUpdates* mSndBufUpdates;
70
71 struct Group* mTopGroup;
72
73 Rate mFullRate, mBufRate;
74
75 uint32 mNumRGens;
76 RGen* mRGen;
77
78 uint32 mNumUnits, mNumGraphs, mNumGroups;
79 int mSampleOffset; // offset in the buffer of current event time.
80
81 void* mNRTLock;
82
83 uint32 mNumSharedControls;
84 float* mSharedControls;
85
86 bool mRealTime;
87 bool mRunning;
88 int mDumpOSC;
89
90 void* mDriverLock;
91
92 float mSubsampleOffset; // subsample accurate offset in the buffer of current event time.
93
94 int mVerbosity;
95 int mErrorNotification;
96 int mLocalErrorNotification;
97
98 bool mRendezvous; // Allow user to disable Rendezvous
99
100 const char* mRestrictedPath; // OSC commands to read/write data can only do it within this path, if specified
101
102 #ifdef SUPERNOVA
103 nova::padded_rw_spinlock* mAudioBusLocks;
104 nova::spin_lock* mControlBusLock;
105 #endif
106 };
107
World_GetBuf(struct World * inWorld,uint32 index)108 inline SndBuf* World_GetBuf(struct World* inWorld, uint32 index) {
109 if (index > inWorld->mNumSndBufs)
110 index = 0;
111 return inWorld->mSndBufs + index;
112 }
113
World_GetNRTBuf(struct World * inWorld,uint32 index)114 inline SndBuf* World_GetNRTBuf(struct World* inWorld, uint32 index) {
115 if (index > inWorld->mNumSndBufs)
116 index = 0;
117 return inWorld->mSndBufsNonRealTimeMirror + index;
118 }
119
120 typedef void (*LoadPlugInFunc)(struct InterfaceTable*);
121 typedef void (*UnLoadPlugInFunc)();
122