Implementing fader curves/crossfades using LUA

Thanks so much for this details explanation! Ima gonna message you for further OT stuff :slight_smile:

Awesome guys, thanks for sharing it!

I was doing some curves too , they are not for crossfades but I normally use them very often in other apps, so I’ve made them also for grid as separate pot elements, just sharing here in case you find useful as well:

-- linear to sigmoid
function lin2sig(x)
    local n = x / 127
    local s = 1 / (1 + math.exp(-12 * (n - 0.5)))
    return math.floor(s * 128)
end
val = lin2sig(val)

-- linear to sine
function lin2sin(x)
    local a = (x / 127) * math.pi - math.pi / 2
    local s = math.sin(a)
    return math.floor((s + 1) / 2 * 127)
end
val = lin2sin(val)

-- linear to cubic
function lin2cub(x)
    local n = x / 127
    local c = n * n * n
    return math.floor(c * 127)
end
val = lin2cub(val)

Cheers!

3 Likes

These are awesome :sunglasses: .

Thank you for sharing @antblanca !

1 Like