Advice around unsafe multiple mutable ref for an audio DSP library

I'm trying to develop a audio DSP library where I have a bunch of reusable signal processing structs that have generic i/o with a fixed number of inputs and outputs, based on some trait bounds, as well as a top level object that has concrete i/o but with variable number of inputs and outputs depending on what the user (or hardware) provides. These all operate on audio vectors, arrays of data, not single samples.

I want the top level object to be able to assume it gets N inputs and M outputs and if it gets less than those, the inputs it operates on return 0.0 and the outputs can be written to but that data is just thrown away. The signal processing structs might have inputs that instead of an actual vector are just a single value, and outputs and need to be written to but the top level object doesn't care about so those values are just thrown away.

Here is a playground with my work in progress code:

the DSPObj struct is an example of the reusable signal processing structs with generic i/o and the CoreObj is an example of one that a user might actually interact with.

I actually have this working but I use unsafe in SignalOutputIteratorMut and I'm wondering if that is possible to avoid and what some gotchas might be with my implementations? This is a pretty big example, I would consolidate it more if I could.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.