Skip to content

Add ability to define limits for attribute<numbers> #197

@isabelgk

Description

@isabelgk

Currently, it's not possible to define attribute<numbers> with a limit. It'd be nice to be able to do something like:

attribute<numbers, threadsafe::no, limit::clamp> m_foo { this, "foo", { 0.0, 0.0 },
    range { {-1.0, 3.5}, {-4.3, 7.0} }
};

This fails because:

error: no matching constructor for initialization of 'c74::min::range' (aka 'vector<c74::min::atom>')
    range { {-1.0, 3.5}, {-4.3, 7.0} }
    ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
c74_min_attribute.h:758:13: error: static_assert failed due to requirement 'std::is_arithmetic<std::vector<double, std::allocator<double>>>::value' "limiting can only be applied to arithmetic types"
                   static_assert(std::is_arithmetic<T>::value, "limiting can only be applied to arithmetic types");
                   ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

We'd need to:

  • be able to construct a c74::min::range of numbers
  • have a specialization of the constrain method for vectors of numeric types

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions