morris
New Member
Posts: 1
Posts: 1
|
Post by morris on Sept 28, 2018 20:46:51 GMT 1
Hi Folks,
I#m attempting to create a basic MIDI input range limiter, so if a note is outside of the range, it is shifted (by a set increment, i.e. 12 for an octave) until it's within the range. I've got various functions and formulas worked out, but I'm at a loss how to translate this into SE functions etc.
Here's the code (in PHP at the moment):
$input_note = 29; # MIDI input note (29=F1) $min = 48; # Start of MIDI note range (48=C3) $max = 59; # End of MIDI note range (59=B3) $noteshift = 12; # What increment to shift the input note by on each iteration of while loop
while ($input_note < $min || $input_note > $max){ $input_note += ($input_note < $min) ? $noteshift : -$noteshift; }
echo $input_note; // Should return 53 (F3)
What's happening here?
If the input note is not between 48 or 59 (our restricted range), a while loop runs Within the loop, the input note is shifted up or down 12 notes/semitones (depending upon whether it's below or above the range's mix/max, I'm using ternary syntax above) When the while breaks (the number is within range), the number is output
The PHP works fine and is pretty simple beginner's code.
Any ideas of what modules or methods I might try? I've attempted to use EZMath3, which has a clutch of methods available, but I'm finding it hard to migrate the code - there's no while loop and the for loop has got me baffled. I'm semi-familiar with SE and understand the general worflow and I'm debugging a lot with monitors, and converting from MIDI to INT etc.
Many thanks.
|
|
|
Post by Rob on Oct 8, 2018 21:39:58 GMT 1
There used to be a MIDI filter module from DH, but it didn’t have a loop function. You should learn to make SE modules and create this MIDI module from scratch, there are MIDI example modules in the SDK.
|
|