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
23 #include "SC_Endian.h"
25 #include "SC_UnitSpec.h"
26 #include "SC_UnitDef.h"
30 #include "SC_Prototypes.h"
32 void Unit_ChooseMulAddFunc(Unit
* unit
);
34 Unit
* Unit_New(World
*inWorld
, UnitSpec
*inUnitSpec
, char*& memory
)
36 UnitDef
*def
= inUnitSpec
->mUnitDef
;
38 Unit
*unit
= (Unit
*)memory
;
39 memory
+= def
->mAllocSize
;
41 unit
->mWorld
= inWorld
;
44 int numInputs
= inUnitSpec
->mNumInputs
;
45 int numOutputs
= inUnitSpec
->mNumOutputs
;
46 unit
->mNumInputs
= numInputs
;
47 unit
->mNumOutputs
= numOutputs
;
48 int numPorts
= numInputs
+ numOutputs
;
50 unit
->mInput
= (Wire
**)memory
;
51 memory
+= numPorts
* sizeof(Wire
*);
53 unit
->mOutput
= unit
->mInput
+ numInputs
;
55 unit
->mInBuf
= (float**)memory
;
56 memory
+= numPorts
* sizeof(float*);
58 unit
->mOutBuf
= unit
->mInBuf
+ numInputs
;
60 unit
->mCalcRate
= inUnitSpec
->mCalcRate
;
61 unit
->mSpecialIndex
= inUnitSpec
->mSpecialIndex
;
62 Rate
* rateInfo
= unit
->mRate
= inUnitSpec
->mRateInfo
;
63 unit
->mBufLength
= rateInfo
->mBufLength
;
70 void Unit_Dtor(Unit
*inUnit
)
74 void Unit_ZeroOutputs(Unit
*unit
, int inNumSamples
)
76 long numOuts
= unit
->mNumOutputs
;
77 for (int i
=0; i
<numOuts
; ++i
) {
79 Clear(inNumSamples
, out
);
84 void Unit_EndCalc(Unit
*inUnit
, int inNumSamples
)
87 Unit_ZeroOutputs(inUnit
, inNumSamples
);
90 void Unit_End(Unit
*inUnit
)
92 inUnit
->mCalcFunc
= (UnitCalcFunc
)&Unit_EndCalc
;