using IF/THEN to create wrapping transposition

meeble's icon

hello,

I am trying to create a MIDI note transposer that is somewhat smart and wraps out of range notes back into a usable note value. My usable MIDI note range is from 60 to 71. My transpose knob goes from -12 to +12. If my input note value + transpose value is > 71 or < 60, I need to wrap the value. Example: let's say my input note value = 70 & transpose value = 2. I want to output a value of 60. Let's say my input note value is 62 and transpose value is -4. I would then want to output 70.

I have tried to create this logic using if/then modules, but the addition and subtraction isn't working in Max. Is there some way to do this?

Max Patch
Copy patch and select New From Clipboard in Max.

thanks!

double_UG's icon
Max Patch
Copy patch and select New From Clipboard in Max.
meeble's icon

Thank you DOUBLEBUG!

I had to modify the patch to get it to allow note values of 71. It now seems to work perfectly when I transpose it upward, but the pong module acts strange in the downward direction. Has anyone noticed that?

Again , my usable MIDI note values are 60 through 71. Here's the values that pong is outputting when transposing down:
Note 60, transpose -1: pong out: 71 (this is right)
Note 60, transpose -11: pong out: 61 (this is right)
Note 60, transpose -12: pong out: 72
That's where things get odd - not sure why the first time it would wrap to 71, but then wrap to 72 the second time around. any ideas?

Max Patch
Copy patch and select New From Clipboard in Max.

Thanks!

meeble's icon

I ended up getting it to work they way I need with these pong values:

pong 59.9 71.9 @mode wrap

:)

ak's icon
Max Patch
Copy patch and select New From Clipboard in Max.
Roman Thilenius's icon

yes, first remove the offset from the range (60-71 minus 60 == 0-11), then use [% 12] to start the scrolling fun, then add 60 again.

there are externals which do fold and wrap as ell, but simple algebra or expr is more flexible - and you always wanted to learn about it anyway.

-110

meeble's icon

awesome input, guys. appreciate the mathematical approach!