mhetrick / hetrickcv

VCV Rack Modules by Michael Hetrick
Creative Commons Zero v1.0 Universal
156 stars 13 forks source link

module request: simple wave wrap/modulo #31

Closed glocke01 closed 1 year ago

glocke01 commented 1 year ago

I'm requesting something analogous to msp's wrap~, which is like a floating point modulo operation. It sets a min and max, and when the signal goes below the min, it "portals" to the max and vice versa. Like digital clip or arithmetic fold.

There are many cases where you want to limit the range of an CV (e.g. to a range of octaves) but the only available options are to clip or shrink it. These options can make a dynamic signal (e.g. random walk) . XTRTN has a Modulo module that does this, but the parameterization (range/offset) is odd and only offset is a modulation target.

I am requesting it of you in particular because it fits with the phasor concept and your waveshaper (which I have to tell you, is incredibly useful for reshaping a CV source) and the general "digital native" aesthetic.

params: min, max
diff := max-min

subroutine update():
  next := getInput()
  while (next>max) { next = next - diff }
  while (next<min) { next = next + diff }
  setOutput(next)

Probably this pseudocode is too simple and will snag somewhere, but I think it gets the point across.

(You might make a fold~ as well, though it seems like the pseudocode for that is more complex - I guess you just count the number of times through the while loop...)

mhetrick commented 1 year ago

Yes! I'm actually working on a Phasor Mixer. It can be used for any signal, but it sums them together and applies your choice of wrap or fold to keep everything within the boundary. I have a rough SVG of it on this repo, but I think I'll redesign it for 5 channels instead of 10 and add attenuverters. I'll keep this open and close it once I push the finished module.

mhetrick commented 1 year ago

I just pushed a commit that includes the new module Phasor Mixer. I hope that you enjoy it!