diff --git a/source/include/FluidMaxWrapper.hpp b/source/include/FluidMaxWrapper.hpp index ef11b67f..f7f10e3b 100644 --- a/source/include/FluidMaxWrapper.hpp +++ b/source/include/FluidMaxWrapper.hpp @@ -822,6 +822,41 @@ class FluidMaxWrapper } }; + template + struct Setter + { + + static t_max_err set(FluidMaxWrapper* x, t_object* /*attr*/, + long ac, t_atom* av) + { + while (x->mInPerform) {} // spin-wait + + x->messages().reset(); + auto desc = x->params().template descriptorAt(); + + typename ChoicesT::type a{ac ? 0u : desc.defaultValue}; + + + for (index i = 0; i < static_cast(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(std::move(a), x->verbose() ? &x->messages() : nullptr); + + object_attr_touch((t_object*) x, gensym("latency")); + return MAX_ERR_NONE; + } + }; + + ////////////////////////////////////////////////////////////////////////////// // Getter @@ -870,6 +905,33 @@ class FluidMaxWrapper return MAX_ERR_NONE; } }; + + template + struct Getter + { + static constexpr index argSize = paramDescriptor().fixedSize; + + static t_max_err get(FluidMaxWrapper* x, t_object* /*attr*/, + long* ac, t_atom** av) + { + + typename ChoicesT::type& a = x->params().template get(); + auto desc = x->params().template descriptorAt(); + + 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; + } + }; ////////////////////////////////////////////////////////////////////////////// @@ -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 static std::enable_if_t::value, t_symbol*>