Transpose values outside range +/- oct(s) ?

I have a patch producing a generative series of MIDI notes, which I’m sending to a few different instruments with VCV Host.

The issue is that some of the instruments I’m using in Host have higher or lower, more or less limited ranges. Notes outside the instrument range simply don’t play.

Is there a module that will transpose MIDI up or down by octave(s) if it falls outside of a note range? For example, if I use a glockenspiel VST with a note range of C4–E6, I’d like to feed it:

D5 → D5

F6 → F5

F7 → F5

C3 → C4

I could do something like this….

… for every instrument, and manually put their upper and lower range limits as the comparator threshold values, but I’m limited to +/-1oct.

Put more generally in voltage terms, how can I use module(s) to add or subtract 1V to a signal until it falls within a set range?

I think this is close, but I’d like values outside the range to be transposed rather than rounded off to the ceiling or floor value.

I appreciate any guidance!

The module you’re looking for is Fence by Orange Line.

Does exactly what you describe and I use it all the time to keep notes in specific octave ranges.