mirror of
https://github.com/eliasstepanik/strudel.git
synced 2026-01-11 05:38:35 +00:00
simplify more
This commit is contained in:
parent
95b1548e5f
commit
b87b2aff9a
@ -117,15 +117,13 @@ function normalize(value = 0, min = 0, max = 1, exp = 1) {
|
|||||||
return Math.pow(normalized, exp);
|
return Math.pow(normalized, exp);
|
||||||
}
|
}
|
||||||
function mapCC(mapping, value) {
|
function mapCC(mapping, value) {
|
||||||
const ccs = [];
|
return Object.keys(value)
|
||||||
const matches = Object.entries(value).filter(([key]) => !!mapping[getControlName(key)]);
|
.filter((key) => !!mapping[getControlName(key)])
|
||||||
matches.forEach((match) => {
|
.map((key) => {
|
||||||
const control = match[0];
|
const { ccn, min = 0, max = 1, exp = 1 } = mapping[key];
|
||||||
const { ccn, min = 0, max = 1, exp = 1 } = mapping[control];
|
const ccv = normalize(value[key], min, max, exp);
|
||||||
const ccv = normalize(value[control], min, max, exp);
|
return { ccn, ccv };
|
||||||
ccs.push({ ccn, ccv });
|
});
|
||||||
});
|
|
||||||
return ccs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// sends a cc message to the given device on the given channel
|
// sends a cc message to the given device on the given channel
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user