Thank you!
At the moment it doesn’t seem to be working, here’s what I adapted it to as per your messages…
const tracks = [89, 90, 91, 92, 93]; // add more indices here if you need several tracks
const device = 1;
const param = 1;
const fadeDuration = 8000; // ms — total duration of the sweep
const steps = 300;
const stepTime = fadeDuration / steps;
// Prevents overlapping sweeps if the button is pressed mid-fade
if (shared(“filterFading”, false)) return;
setShared(“filterFading”, true);
const isClosed = shared(“filterClosed”, false);
if (isClosed) {
// Sweep back up to the previous value
const prev = shared(“filterPrev”, 1.0);
for (let i = 1; i <= steps; i++) {
const v = (i / steps) * prev;
for (const t of tracks) {
sendOsc(":AbletonOSC/live/device/set/parameter/value", int(t), int(device), int(param), v);
}
await sleep(stepTime);
}
setShared(“filterClosed”, false);
} else {
// Save the current value, then sweep down to 0
const current = osc(“:AbletonOSC/live/device/90/1/get/parameter/value”, 1) ?? 1.0;
setShared(“filterPrev”, current);
for (let i = 1; i <= steps; i++) {
const v = current * (1 - i / steps);
for (const t of tracks) {
sendOsc(":AbletonOSC/live/device/set/parameter/value", int(t), int(device), int(param), v);
}
await sleep(stepTime);
}
setShared(“filterClosed”, true);
}
setShared(“filterFading”, false);
Let me know if there’s anything I’ve done wrong there.
I’ll test the icon and colour feedback once I know it’s actually working inside Ableton 