vsariola / sointu

Fork of 4klang that can target 386, amd64 and WebAssembly. Tools run on Windows, Mac & Linux
MIT License
254 stars 17 forks source link

Pow op #118

Closed wayfu closed 7 months ago

wayfu commented 10 months ago

A pow op would be very handy for making envelopes - bending linear curves to be tighter (higher values) or looser (0...1). I've been using push/mulp combos for squaring values, but a real pow would be much more, haha, powerful.

vsariola commented 10 months ago

DISTORT can probably do something a bit like you are looking for now. There's asm code for computing 2**x, converting it to generic y**x is possible but a bit of hassle and takes again more bytes.

Funnily, the first poking of 4klang that eventually became sointu was trying to get gopher remove the unnecessary code in Pow function, remnants of the pow being able to compute generic y**x and not just 2**x :)

https://github.com/hzdgopher/4klang/issues/8

wayfu commented 10 months ago

hehehe I'll use the distortion for now then! thanks!

vsariola commented 7 months ago

I'll close this issue: the recommended way to shape the envelopes is to use distort. It's also possible to do ^2 (or ^4 or ^8) using a mul operator(s).