vsariola / sointu

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

Unit send targets should be by ID #40

Closed vsariola closed 3 years ago

vsariola commented 3 years ago

The internal data format should be changed: units should be optionally given a running ID and send targets should be identified by their ID. Trying to keep the send targets synced to all mutations currently is a pain and likely source of bugs.

IDs can be stripped for units that don't need them during save, to keep the overall file format clean.

The question of polyphonic sends remain. There are a few possible solutions: 1) Still have optional "voice" parameter, which defines target voice (relative to the instrument). 0 = auto ("if this is local send, then target the same voice that is currently getting run, otherwise just voice 1"), 1 = voice 1, 2 = voice 2 etc. 2) Try to use the polyphony bitmask to repeat sends during run time 3) Try to pack the number of voices sent into lodsw data. Unlikely to work, as we already use all 16 bits (3 for ports, 1 for POP, 1 for global send, 6 for unit, 5 for voice)... LEB128 encoding might be future proof, but could theoretically make some send addresses 3 bytes long, while sometimes making them 1 byte (first bit must be 0, 3 bits for unit, 1 for POP, 3 for port... actually might work in some cases)... The LEB128 decoding in the beginning of send might result in further juggling for the carry flag. 4) Multisends, with completely new address for every send, and one bit snipped from unit number to indicate if there's a new address coming. If so, repeat the entire send, starting from lodsw.

vsariola commented 3 years ago

The system is now implemented as with option 1; auto = same voice (local send) if targeting unit in the same instrument; auto = first voice if global send