diff --git a/include/FluidSCWrapper.hpp b/include/FluidSCWrapper.hpp index 711b5fa..53a2363 100644 --- a/include/FluidSCWrapper.hpp +++ b/include/FluidSCWrapper.hpp @@ -53,6 +53,39 @@ struct WrapperState Result mResult{}; }; +/// Named, shared clients already have a lookup table in their adaptor class +template +struct IsPersistent +{ + using type = std::false_type; +}; + +//TODO: make less tied to current implementation +template +struct IsPersistent>> +{ + using type = std::true_type; +}; + +template +using IsPersistent_t = typename IsPersistent::type; + +/// Models don't, but still need to survive CMD-. +template +struct IsModel +{ + using type = std::false_type; +}; + +template +struct IsModel>> +{ + using type = typename ClientWrapper::isModelObject; +}; + +template +using IsModel_t = typename IsModel::type; + namespace impl { template @@ -301,7 +334,7 @@ class NonRealTime : public SCUnit using SharedState = std::shared_ptr>; public: - static index ControlOffset(Unit*) { return 0; } + static index ControlOffset(Unit*) { return IsModel_t::value ? 1 : 0; } static index ControlSize(Unit* unit) { return index(unit->mNumInputs) - unit->mSpecialIndex - 2; } static void setup(InterfaceTable* ft, const char* name) @@ -383,6 +416,11 @@ public: mWrapper->mDone = sharedState->mJobDone; if(trigger) { + mWrapper->mControlsIterator.reset(mInBuf + ControlOffset(this)); + Wrapper::setParams(mWrapper, + mWrapper->params(), mWrapper->mControlsIterator); // forward on inputs N + audio inputs as params + mWrapper->params().constrainParameterValues(); + SharedState* statePtr = static_cast(mWorld->ft->fRTAlloc(mWorld, sizeof(SharedState))); statePtr = new (statePtr) SharedState(sharedState); mFifoMsg.Set(mWorld, initNRTJob, nullptr, statePtr); @@ -591,38 +629,7 @@ class NonRealTimeAndRealTime : public RealTime, //Discovery for clients that need persistent storage (Dataset and friends) -/// Named, shared clients already have a lookup table in their adaptor class -template -struct IsPersistent -{ - using type = std::false_type; -}; -//TODO: make less tied to current implementation -template -struct IsPersistent>> -{ - using type = std::true_type; -}; - -template -using IsPersistent_t = typename IsPersistent::type; - -/// Models don't, but still need to survive CMD-. -template -struct IsModel -{ - using type = std::false_type; -}; - -template -struct IsModel>> -{ - using type = typename ClientWrapper::isModelObject; -}; - -template -using IsModel_t = typename IsModel::type; template struct LifetimePolicy; @@ -668,7 +675,7 @@ struct LifetimePolicy static void constructClass(Unit* unit) { index uid = static_cast(unit->mInBuf[Wrapper::ControlOffset(unit)][0]); - FloatControlsIter controlsReader{unit->mInBuf + 1 + Wrapper::ControlOffset(unit),Wrapper::ControlSize(unit)}; + FloatControlsIter controlsReader{unit->mInBuf + Wrapper::ControlOffset(unit),Wrapper::ControlSize(unit)}; auto& entry = mRegistry[uid]; auto& client = entry.client; auto& params = entry.params;