Fix/params maxima (#148)

* Readme: Correct C++ version

* Wrapper: constrain runtime param maxima
nix
Owen Green 3 years ago committed by GitHub
parent 39d4087666
commit 084adc9e2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -85,8 +85,9 @@ public:
using Reportage = decltype(static_cast<FluidSCWrapper*>(x)->mReportage);
Reportage* reportage = initialized ? &(static_cast<FluidSCWrapper*>(x)->mReportage) : new Reportage();
p.template setParameterValuesRT<ControlSetter>(verbose ? reportage: nullptr , x, inputs, alloc);
p.template setParameterValuesRT<ControlSetter>(
verbose ? reportage : nullptr, x, inputs, p, alloc);
if (constrain) p.constrainParameterValuesRT(verbose ? reportage : nullptr);
if(verbose)
{

@ -126,12 +126,13 @@ struct ParamReader<impl::FloatControlsIter>
auto id = fromArgs(x, args, index{}, 0);
return {id >= 0 ? std::to_string(id).c_str() : "" };
}
static auto fromArgs(Unit*,Controls& args,typename LongRuntimeMaxT::type&, int)
static auto fromArgs(Unit*, Controls& args, typename LongRuntimeMaxT::type&,
int)
{
return typename LongRuntimeMaxT::type{static_cast<index>(args.next()), static_cast<index>(args.next())};
return typename LongRuntimeMaxT::type{static_cast<index>(args.next()),
static_cast<index>(args.next())};
}
};
// NRT case: we're decoding data from sc_msg_iter*, there will be a World*, we can't have LocalBufs
@ -329,11 +330,13 @@ struct ClientParams{
/// Grizzly enable_if hackage coming up. Need to brute force an int from incoming data into a string param for FluidDataSet / FluidLabelSet.
/// This will go away one day
/// This will go away one day
template<typename Context, typename Client = typename Wrapper::Client, size_t Number = N>
std::enable_if_t<!impl::IsNamedShared_v<Client> || Number!=0, typename T::type>
operator()(Context* x, ArgType& args, Allocator& alloc)
template <typename Context, typename Params,
typename Client = typename Wrapper::Client, size_t Number = N>
std::enable_if_t<!impl::IsNamedShared_v<Client> || Number != 0,
typename T::type>
operator()(Context* x, ArgType& args, Params& p, Allocator& alloc)
{
// Just return default if there's nothing left to grab
if (args.remain() == 0)
@ -351,12 +354,25 @@ struct ClientParams{
a[i] = static_cast<LiteralType>(
ParamReader<ArgType>::fromArgs(x, args, a[0], 0));
return a.value();
/// He said "I don't like it, but I have to go along with it"
/// Make sure that the maximum for LongRuntimeMax params is
/// properly constrained *as soon as possible*
if constexpr (std::is_same_v<T, LongRuntimeMaxT>)
{
auto param = a.value();
index maximum = param.maxRaw();
maximum = p.template applyConstraintToMax<N>(maximum);
return LongRuntimeMaxParam(param(), maximum);
}
else
return a.value();
}
template<typename Context, typename Client = typename Wrapper::Client, size_t Number = N>
std::enable_if_t<impl::IsNamedShared_v<Client> && Number==0, typename T::type>
operator()(Context* x, ArgType& args, Allocator& alloc)
template <typename Context, typename Params,
typename Client = typename Wrapper::Client, size_t Number = N>
std::enable_if_t<impl::IsNamedShared_v<Client> && Number == 0,
typename T::type>
operator()(Context* x, ArgType& args, Params&, Allocator& alloc)
{
// Just return default if there's nothing left to grab
if (args.remain() == 0)

@ -272,8 +272,8 @@ private:
: NRTCommand{world, args, replyAddr, !IsNamedShared_v<Client>},
mParams{Client::getParameterDescriptors(), NRTCommand::allocator()}
{
mParams.template setParameterValuesRT<ParamsFromOSC>(nullptr, world,
*args, NRTCommand::allocator());
mParams.template setParameterValuesRT<ParamsFromOSC>(
nullptr, world, *args, mParams, NRTCommand::allocator());
}
CommandNew(index id, World* world, FloatControlsIter& args, Unit* x)
@ -281,7 +281,7 @@ private:
NRTCommand::allocator()}
{
mParams.template setParameterValuesRT<ParamsFromSynth>(
nullptr, x, args, NRTCommand::allocator());
nullptr, x, args, mParams, NRTCommand::allocator());
}
static const char* name()
@ -364,8 +364,8 @@ private:
if (auto ptr = get(NRTCommand::mID).lock())
{
ptr->mDone.store(false, std::memory_order_release);
mParams.template setParameterValuesRT<ParamsFromOSC>(nullptr, world,
ar, NRTCommand::allocator());
mParams.template setParameterValuesRT<ParamsFromOSC>(
nullptr, world, ar, mParams, NRTCommand::allocator());
mSynchronous = static_cast<bool>(ar.geti());
} // if this fails, we'll hear about it in stage2 anyway
}
@ -716,7 +716,7 @@ private:
if (auto ptr = get(NRTCommand::mID).lock())
{
ptr->mParams.template setParameterValuesRT<ParamsFromOSC>(
nullptr, world, ar, NRTCommand::allocator());
nullptr, world, ar, ptr->mParams, NRTCommand::allocator());
Result result = validateParameters(ptr->mParams);
ptr->mClient.setParams(ptr->mParams);
}
@ -747,7 +747,7 @@ private:
if (auto ptr = get(NRTCommand::mID).lock())
{
ptr->mParams.template setParameterValues<ParamsFromOSC>(
true, world, mArgs, FluidDefaultAllocator());
true, world, mArgs, ptr->mParams, FluidDefaultAllocator());
Result result = validateParameters(ptr->mParams);
ptr->mClient.setParams(ptr->mParams);
}

Loading…
Cancel
Save