Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions source/include/FluidMaxWrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,41 @@ class FluidMaxWrapper
}
};

template <size_t N>
struct Setter<ChoicesT, N>
{

static t_max_err set(FluidMaxWrapper<Client>* x, t_object* /*attr*/,
long ac, t_atom* av)
{
while (x->mInPerform) {} // spin-wait

x->messages().reset();
auto desc = x->params().template descriptorAt<N>();

typename ChoicesT::type a{ac ? 0u : desc.defaultValue};


for (index i = 0; i < static_cast<index>(ac); i++)
{
t_symbol* s = atom_getsym(av + i);
index pos = desc.lookup(s->s_name);
if(pos == -1)
{
object_error((t_object*)x,"%s: unrecognised choice",s->s_name);
continue;
}
a.set(pos,1);
}

x->params().template set<N>(std::move(a), x->verbose() ? &x->messages() : nullptr);

object_attr_touch((t_object*) x, gensym("latency"));
return MAX_ERR_NONE;
}
};


//////////////////////////////////////////////////////////////////////////////

// Getter
Expand Down Expand Up @@ -870,6 +905,33 @@ class FluidMaxWrapper
return MAX_ERR_NONE;
}
};

template <size_t N>
struct Getter<ChoicesT,N>
{
static constexpr index argSize = paramDescriptor<N>().fixedSize;

static t_max_err get(FluidMaxWrapper<Client>* x, t_object* /*attr*/,
long* ac, t_atom** av)
{

typename ChoicesT::type& a = x->params().template get<N>();
auto desc = x->params().template descriptorAt<N>();

index argSize = a.count();

char alloc;
atom_alloc_array(argSize, ac, av, &alloc);

for (index i = 0, arg = 0; i < desc.numOptions; i++)
{
if(a[i])
ParamAtomConverter::toAtom(*av + arg++,desc.strings[i]);
}

return MAX_ERR_NONE;
}
};

//////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -1830,6 +1892,8 @@ class FluidMaxWrapper
static t_symbol* maxAttrType(FFTParamsT) { return gensym("atom"); }
static t_symbol* maxAttrType(StringT) { return USESYM(symbol); }
static t_symbol* maxAttrType(LongArrayT) { return gensym("atom"); }
static t_symbol* maxAttrType(ChoicesT) { return gensym("atom"); }


template <typename T>
static std::enable_if_t<IsSharedClient<typename T::type>::value, t_symbol*>
Expand Down