Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
`ControlIn` objects
– properly adjust `ac` when adjusting `av` 
– ensure mListSize is always intialized to something 
– fix resize logic
  • Loading branch information
weefuzzy committed May 2, 2022
1 parent fac9bba commit 86a38e5
Showing 1 changed file with 25 additions and 17 deletions.
42 changes: 25 additions & 17 deletions source/include/FluidMaxWrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,6 @@ struct NonRealTime

using Client = typename Wrapper::ClientType;

std::cout << Wrapper::template IsModel_t<Client>::value;

constexpr bool isDataObject =
Wrapper::template IsThreadedShared<Client>::value ||
Wrapper::template IsModel_t<Client>::value;
Expand Down Expand Up @@ -494,7 +492,7 @@ class FluidMaxWrapper
struct StreamingListInput
{

void processInput(FluidMaxWrapper* x, long ac, t_atom* av)
void processInput(FluidMaxWrapper*, long, t_atom*)
{

}
Expand All @@ -507,8 +505,8 @@ class FluidMaxWrapper
std::min<index>(x->mListSize, ac),
x->mInputListData[0].data());
x->mClient.process(x->mInputListViews, x->mOutputListViews, c);

for (index i = 0; i < x->mAllControlOuts.size(); ++i)
for (index i = 0; i < asSigned(x->mAllControlOuts.size()); ++i)
{
atom_setdouble_array(
std::min<index>(x->mListSize, ac), x->mOutputListAtoms.data(),
Expand Down Expand Up @@ -921,7 +919,7 @@ class FluidMaxWrapper
using ParamValues = typename ParamSetType::ValueTuple;

FluidMaxWrapper(t_symbol*, long ac, t_atom* av)
: mMessages{}, mParams(Client::getParameterDescriptors()),
: mListSize{32}, mMessages{}, mParams(Client::getParameterDescriptors()),
mParamSnapshot(Client::getParameterDescriptors()),
mClient{initParamsFromArgs(ac, av)},mDumpDictionary{nullptr}
{
Expand Down Expand Up @@ -1034,7 +1032,7 @@ class FluidMaxWrapper
{
void* x = object_alloc(getClass());
new (x) FluidMaxWrapper(sym, ac, av);
std::cout << attr_args_offset(static_cast<short>(ac), av) << '\n';

if (static_cast<index>(attr_args_offset(static_cast<short>(ac), av)) - isControlIn<typename Client::Client> >
ParamDescType::NumFixedParams)
{
Expand All @@ -1059,7 +1057,7 @@ class FluidMaxWrapper
if (isControlIn<typename Client::Client>)
{
class_addmethod(getClass(), (method) handleList, "list", A_GIMME, 0);
t_object* a = attr_offset_new("autosize", USESYM(long), 0, nullptr, nullptr,
t_object* a = attr_offset_new("autosize", USESYM(atom_long), 0, nullptr, nullptr,
calcoffset(FluidMaxWrapper, mAutosize));
class_addattr(getClass(), a);
CLASS_ATTR_FILTER_CLIP(getClass(), "autosize", 0, 1);
Expand All @@ -1079,7 +1077,7 @@ class FluidMaxWrapper

class_addmethod(getClass(), (method) doVersion, "version", 0);
// Change for MSVC, which didn't like the macro version
t_object* a = attr_offset_new("warnings", USESYM(long), 0, nullptr, nullptr,
t_object* a = attr_offset_new("warnings", USESYM(atom_long), 0, nullptr, nullptr,
calcoffset(FluidMaxWrapper, mVerbose));
class_addattr(getClass(), a);

Expand Down Expand Up @@ -1146,7 +1144,7 @@ class FluidMaxWrapper
{
mInputListViews.emplace_back(mInputListData.row(i));
}
std::cout << mInputListViews.size() << '\n';

mOutputListData.resize(mClient.controlChannelsOut().count,mListSize);
mOutputListAtoms.reserve(mListSize);
mOutputListViews.clear();
Expand All @@ -1160,10 +1158,17 @@ class FluidMaxWrapper

static void doList(FluidMaxWrapper* x, t_symbol*, long ac, t_atom* av)
{
if(!isr() && x->mAutosize && (ac != x->mListSize)) x->resizeListHandlers(ac);

// if(!isr() && x->mAutosize && (ac != x->mListSize)) x->resizeListHandlers(ac);
x->mListHandler(x, ac, av);
}

static void doListResize(FluidMaxWrapper* x, t_symbol*, long ac, t_atom*)
{
x->resizeListHandlers(ac);
}


static void handleList(FluidMaxWrapper* x, t_symbol* s, long ac, t_atom* av)
{
if(!x->mListSize && !x->mAutosize)
Expand All @@ -1177,6 +1182,7 @@ class FluidMaxWrapper
if(x->mAutosize && ac != x->mListSize)
{
object_warn((t_object*)x, "input list size (%d) != object argument (%d) and autosize is enabled: this operation will be deferred",ac,x->mListSize);
defer(x,method(doListResize),s,ac,av);
defer(x,(method)doList,s, ac, av);
return;
}
Expand All @@ -1187,6 +1193,7 @@ class FluidMaxWrapper
return;
}
}
else if(ac != x->mListSize) doListResize(x,s,ac,av);

doList(x,s,ac,av);

Expand Down Expand Up @@ -1310,9 +1317,9 @@ class FluidMaxWrapper
if(isControlIn<typename Client::Client>)
{
mListSize = atom_getlong(av);
// if(numArgs == 1) return;
numArgs -= 1;
av += 1;
ac--;
}

auto results = mParams.template setFixedParameterValues<Fetcher>(
Expand Down Expand Up @@ -1476,7 +1483,7 @@ class FluidMaxWrapper
using Handler = std::conditional_t<isVoid, IfVoid, IfParams>;

Handler{}.template handle<N>(
typename T::ReturnType{}, typename T::ArgumentTypes{},
typename T::ReturnType{}, ArgumentTypes{},
[&message](auto M) {
class_addmethod(getClass(),
(method) deferRead<decltype(M)::value>,
Expand Down Expand Up @@ -1826,7 +1833,7 @@ class FluidMaxWrapper
static t_symbol* maxAttrType(LongT) { return USESYM(atom_long); }
static t_symbol* maxAttrType(BufferT) { return USESYM(symbol); }
static t_symbol* maxAttrType(InputBufferT) { return USESYM(symbol); }
static t_symbol* maxAttrType(EnumT) { return USESYM(long); }
static t_symbol* maxAttrType(EnumT) { return USESYM(atom_long); }
static t_symbol* maxAttrType(FloatPairsArrayT) { return gensym("atom"); }
static t_symbol* maxAttrType(FFTParamsT) { return gensym("atom"); }
static t_symbol* maxAttrType(StringT) { return USESYM(symbol); }
Expand All @@ -1839,22 +1846,23 @@ class FluidMaxWrapper
return USESYM(symbol);
}

index mListSize;

std::deque<Result> mMessages;
Result mResult;
void* mNRTDoneOutlet;
void* mControlOutlet;
void* mDumpOutlet;
void* mProgressOutlet;
bool mVerbose;
bool mAutosize;
index mVerbose;
index mAutosize;
ParamSetType mParams;
ParamSetType mParamSnapshot;
Client mClient;
t_int32_atomic mInPerform{0};
t_dictionary* mDumpDictionary;
std::vector<void*> mProxies;

index mListSize;
FluidTensor<double, 2> mInputListData;
std::vector<FluidTensorView<double, 1>> mInputListViews;
FluidTensor<double, 2> mOutputListData;
Expand Down

0 comments on commit 86a38e5

Please sign in to comment.