Single Knob: LP/HP filter + filter type + bi-polar LED setup + deadzone +/- | Intech Studio
💬 general Grid

Single Knob: LP/HP filter + filter type + bi-polar LED setup + deadzone +/-

BryanR
BryanR · · 19 replies

Well, of course I'm going to tackle the most complex config in my setup right out of the box 😅

I'm this far:

if val == 64 then
led_value(num, 1, 0)
elseif val > 64 then
led_color(num, 1, 255, 255, 0, 0)
led_value(num, 1, val - 64)
else
led_color(num, 1, 255, 110, 0, 0)
led_value(num, 1, math.abs(64 - val))
end
if val == 64 then
elseif val > 64 then
midi_send(0, 176, 74, val)
midi_send(ch, 176, 76, 127)
else
midi_send(0, 176, 74, val)
midi_send(0, 176, 76, 0)
end

Not sure how to scale the CC value so if >64 0-127, 64> 0-127 (basically L or R from zero/12 o'clock it starts at 0 and goes to 127). From research gathered to-date here, and the website forum, setting resolution to 256, then doing a few IF/ELSE, with maths could get me there... ...this is day#1 and I'm about ~7hours in to general understanding 😁

If I knew what I was doing, I'd probably include a little dead zone with the LED either off or green

Thanks in advance for any assistance 🍻

Replies (19)

narayb narayb ·

In my mind, the easiest solution would be to increase the resolution to 0-255 and then use the inverted value as the MIDI value over half.

You were almost there!

You can find the profile "Inverted Potmeter" in the cloud. It changes the local val variable from the usual to (-1*(self:potmeter_value()+1))%(self:potmeter_max()+1) which inverts its behavior. Based on that:

The midi side should look something like this.

image.png
narayb narayb ·

And it would function like this.

djfilter.gif
narayb narayb ·

I hope this helps!

BryanR BryanR ·

Thanks! It helped (as did bringing an 18yo with coding experience into the room. lol)

BryanR BryanR ·

So now I'm here:

self:potmeter_resolution(7)
self:potmeter_max(255)
if self:potmeter_state() < 64 then
midi_send(1, 176, 74, val - 128)
midi_send(1, 176, 76, 127)
elseif self:potmeter_state() > 64 then
midi_send(1, 176, 74, 128 - val)
midi_send(1, 176, 76, 0)
end

if val == 64 then
led_value(num, 1, 0)
elseif val > 64 then
led_color(num, 1, 255, 255, 0, 0)
led_value(num, 1, val - 64)
else
led_color(num, 1, 255, 110, 0, 0)
led_value(num, 1, math.abs(64 - val))
end

...but in order to get LED to behave, I'm over character limit 😕

narayb narayb ·

I would move all the max and potmeter resolution code to the init even as you only need to declare those once.

narayb narayb ·

What I don't really understand is why are you sending two constant MIDI messages per potmeter event?

narayb narayb ·

But otherwise it looks solid!

narayb narayb ·

If you want to save characters, you could move some of your messages to functions for example under system init you could define the following:

sendit=function(state,val)
if state < 64 then
    midi_send(1, 176, 74, val - 128)
    midi_send(1, 176, 76, 127)
elseif state > 64 then
    midi_send(1, 176, 74, 128 - val)
    midi_send(1, 176, 76, 0)
end
end
narayb narayb ·

And then call this same function under your potmeter event like so:

sendit(self:potmeter_state(),val)
if val == 64 then
    led_value(num, 1, 0)
elseif val > 64 then
    led_color(num, 1, 255, 255, 0, 0)
    led_value(num, 1, val - 64)
else
    led_color(num, 1, 255, 110, 0, 0)
    led_value(num, 1, math.abs(64 - val))
end
narayb narayb ·

You could move your led coloring into another function in the same way reducing the code size to even less.

BryanR BryanR ·

The two midi messages are for filter amount and filter type. The rytm doesn’t have a bandwidth filter type like the Digitakt, so I need to select LP or HP which is cc76.

BryanR BryanR ·

And this is the understanding I lack. I almost feel bad asking these questions with only having the admins reply (I’m sorry! Haha). Having the cloud component with others uploading their configs is definitely helpful in dissecting how functions work and implementing them. The coding portion is not my forte. Most of what I’m setting up is straight forward midi implementation, which the UI accommodates, but there’s a few complex functions that I wanted, which drew me to the product. I appreciate the help 🍻

BryanR BryanR ·

Question: is the a “how-to Lua coding for dumbasses” manual? 😅

narayb narayb ·

We're working on something that can help ppl get started.

BryanR BryanR ·

Well, the LP/HP filter works - but I totally bombed the test on the bi-polar LED 😅

narayb narayb ·

Hell yeah! That looks great!

narayb narayb ·

Let me know if I can help you with setting up a bipolar LED for that.

Discord

View on Discord

This post is from the Intech Studio Discord community.

Open thread →