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

Set, Mul & Add modes for send #117

Closed wayfu closed 10 months ago

wayfu commented 10 months ago

sometimes you want more than one send to influence the same value. it would be good to have Set, Mul, and Add mode available so that effects from multiple sources can be combined

vsariola commented 10 months ago

SET would be redundant, as multiple sends targeting the same value already work like an "ADD". The port is reset to 0 every cycle so sends A and B targeting a port works like: calculate 0 + A + B, then add this to the modulated value.

This is pretty deep design choice in Sointu and is unlikely to change. Internally, SEND unit is already out of bit fields for flags (it uses all 16 bits it has already for it's data), so adding one more bit for "MUL" / "ADD" would require 17th bit i.e. adding new byte to the data of SEND.

Also, two sends with "MUL" set as its mode would not work quite as one would expect, as all ports are reset to 0 during one cycle so it would 0 A B = always 0

Can you give a specific example where Mul is needed? I think it's a pretty specific, rare use case, and there's a way to implement it using RECEIVE-RECEIVE-MULP or something like that.

wayfu commented 10 months ago

I understand! thank you for the explanation. I did not have a concrete situation in mind, but I remembered having wished for the option in 4klang before. thinking about it now, I don't see a burning need for it in daily work, but I'll try and keep an eye out and report back if it ever comes up again (in which case it would likely be possible, as you said, to fake it). feel free to close! :)