Cycling74 / min-api

High-level C++-language application programming interface for Max
MIT License
57 stars 23 forks source link

Introduce attribute::set_range() and fix two bugs #175

Closed hiddedejong closed 3 years ago

hiddedejong commented 3 years ago

The new set_range method updates an attribute's range and sets the attribute's value so that the new range gets applied. This new addition also exposed a bug with attributes that set allow_repetitions::no: the attribute's range was not taken into account while checking whether the new value was a repetition. The Add a test that shows that ranges aren't applied correctly before filtering out repetitions commit shows the bug.

The fix required the new args to be constrained before passing them into compare_to_current_value. However, the constrain method was called much later and did alter the atoms in-place. Therefore, we couldn't really use the constrain method as it was. Now, instead of altering the atoms in-place, the constrain method returns the constrained atoms. This change also allows us to make the set method's arguments const.

Finally, the scale function didn't work properly when the in_low and out_low arguments were equal.

hiddedejong commented 3 years ago

min-devkit test run using this branch: https://github.com/Cycling74/min-devkit/actions/runs/568005479