1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
/*
SuperCollider real time audio synthesis system
Copyright (c) 2002 James McCartney. All rights reserved.
http://www.audiosynth.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "SC_Unit.h"
#include "SC_UnitSpec.h"
#include "SC_UnitDef.h"
#include "SC_World.h"
#include "SC_Wire.h"
#include "Unroll.h"
#include <stdio.h>
#include "SC_Prototypes.h"
#ifdef SC_WIN32
// workaround for IN/OUT conflict with Win32 headers. see SC_Unit.h for details
// (note: the pragma momentarily suppresses compiler warning about such conflict)
#pragma warning(disable: 4005)
#define IN SC_IN
#define OUT SC_OUT
#pragma warning(default: 4005)
#endif
void Unit_ChooseMulAddFunc(Unit* unit);
Unit* Unit_New(World *inWorld, UnitSpec *inUnitSpec, char*& memory)
{
UnitDef *def = inUnitSpec->mUnitDef;
Unit *unit = (Unit*)memory;
memory += def->mAllocSize;
unit->mWorld = inWorld;
unit->mUnitDef = def;
int numInputs = inUnitSpec->mNumInputs;
int numOutputs = inUnitSpec->mNumOutputs;
unit->mNumInputs = numInputs;
unit->mNumOutputs = numOutputs;
int numPorts = numInputs + numOutputs;
unit->mInput = (Wire**)memory;
memory += numPorts * sizeof(Wire*);
unit->mOutput = unit->mInput + numInputs;
unit->mInBuf = (float**)memory;
memory += numPorts * sizeof(float*);
unit->mOutBuf = unit->mInBuf + numInputs;
unit->mCalcRate = inUnitSpec->mCalcRate;
unit->mSpecialIndex = inUnitSpec->mSpecialIndex;
Rate* rateInfo = unit->mRate = inUnitSpec->mRateInfo;
unit->mBufLength = rateInfo->mBufLength;
unit->mDone = false;
return unit;
}
void Unit_Dtor(Unit *inUnit)
{
}
void Unit_ZeroOutputs(Unit *unit, int inNumSamples)
{
long numOuts = unit->mNumOutputs;
for (int i=0; i<numOuts; ++i) {
float *out = OUT(i);
Clear(inNumSamples, out);
}
}
void Unit_EndCalc(Unit *inUnit, int inNumSamples)
{
inUnit->mDone = true;
Unit_ZeroOutputs(inUnit, inNumSamples);
}
void Unit_End(Unit *inUnit)
{
inUnit->mCalcFunc = (UnitCalcFunc)&Unit_EndCalc;
}
|