Cleanup
This commit is contained in:
parent
4b08dd8447
commit
bae5571df0
2 changed files with 14 additions and 15 deletions
|
|
@ -2814,27 +2814,25 @@ export const scrub = register(
|
||||||
);
|
);
|
||||||
|
|
||||||
const subControlAliases = new Map();
|
const subControlAliases = new Map();
|
||||||
const registerSubControl = (funcName, main, ...aliases) => {
|
const registerSubControl = (control, subControl, ...aliases) => {
|
||||||
const lowerFunc = String(funcName).toLowerCase();
|
const aliasMap = subControlAliases.get(control) ?? new Map();
|
||||||
const aliasMap = subControlAliases.get(lowerFunc) ?? new Map();
|
const allKeys = new Set([subControl, ...aliases]);
|
||||||
const allKeys = new Set([main, ...aliases]);
|
|
||||||
for (const alias of allKeys) {
|
for (const alias of allKeys) {
|
||||||
aliasMap.set(String(alias).toLowerCase(), main);
|
aliasMap.set(String(alias).toLowerCase(), subControl);
|
||||||
}
|
}
|
||||||
subControlAliases.set(lowerFunc, aliasMap);
|
subControlAliases.set(control, aliasMap);
|
||||||
};
|
};
|
||||||
|
|
||||||
const registerSubControls = (funcName, aliasGroups = []) => {
|
const registerSubControls = (control, subControlAliases = []) => {
|
||||||
for (const [main, ...aliases] of aliasGroups) {
|
for (const [subControl, ...aliases] of subControlAliases) {
|
||||||
registerSubControl(funcName, main, ...aliases);
|
registerSubControl(control, subControl, ...aliases);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const resolveConfigKey = (funcName, key) => {
|
const getMainSubcontrolName = (control, subKey) => {
|
||||||
const aliasMap = subControlAliases.get(String(funcName).toLowerCase());
|
const aliasMap = subControlAliases.get(control);
|
||||||
if (!aliasMap) return key;
|
if (!aliasMap) return subKey;
|
||||||
const normalized = String(key).toLowerCase();
|
return aliasMap.get(String(subKey).toLowerCase()) ?? subKey;
|
||||||
return aliasMap.get(normalized) ?? key;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
registerSubControls('lfo', [
|
registerSubControls('lfo', [
|
||||||
|
|
@ -2884,7 +2882,7 @@ Pattern.prototype.modulate = function (type, config, idx) {
|
||||||
let defaultValue = {};
|
let defaultValue = {};
|
||||||
let defaultSet = 'control' in config;
|
let defaultSet = 'control' in config;
|
||||||
for (const [rawKey, value] of Object.entries(config)) {
|
for (const [rawKey, value] of Object.entries(config)) {
|
||||||
const key = resolveConfigKey(type, rawKey);
|
const key = getMainSubcontrolName(type, rawKey);
|
||||||
const valuePat = reify(value);
|
const valuePat = reify(value);
|
||||||
output = output
|
output = output
|
||||||
.fmap((v) => (c) => {
|
.fmap((v) => (c) => {
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ Copyright (C) 2025 Strudel contributors - see <https://codeberg.org/uzu/strudel/
|
||||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Mapping from control name to webaudio node and parameter
|
||||||
const CONTROL_TARGETS = {
|
const CONTROL_TARGETS = {
|
||||||
stretch: { node: 'stretch', param: 'pitchFactor' },
|
stretch: { node: 'stretch', param: 'pitchFactor' },
|
||||||
gain: { node: 'gain', param: 'gain' },
|
gain: { node: 'gain', param: 'gain' },
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue