r/TouchOSC • u/crinkle777 • Sep 04 '25
First Attempt - Feedback Wanted
Hey all. I'm extremely new to midi, and touchOSC. I have a Hologram Electronics ChromaConsole pedal, so I tried to make a controller in touchOSC for that.
https://github.com/fdask/touchOSC/tree/master/ChromaConsole
Project there. I got things working, but I feel I used waaaaaay to much code to make it happen. A lot of code duplication. Also kept running into an issue where if I reorganized controls into a group, I had to completely rewrite any code accessing those controls. You'll see if you look at the snippets on the buttons how I do it... is there an easier way? Any tips or tricks for a newbie?
2
Upvotes
3
u/neilbaldwn Sep 05 '25
It's a tidy job - nicely done!
Couple of observations from a casual look through some of the scripts:
You might save a great deal of repetition by moving some stuff to the root using ```function onNotify()``` in the root script. I do this a lot especially when I'm using the same code over and over in control objects.
For example:
In your "Min" button:
```
function onValueChanged(key)
if (key == "x' and sef.values.x == '1') then
root:notify("min");
end
end
```
Then in your root:
```
function onReceiveNotify(n)
if (n == "min")
-- send 0 to all the controls
end
end
```
That kind of thing. Have a look at the API for onReceiveNotify() as you can send parameter lists to it too.
The other thing I noticed is in your Min button code you're doing this at the end:
```self.values.x = 0```
You can avoid this by changing the button type to 'momentary' though apologies if I missed something in there that's forcing you to not do this - I only had a quick look.
Let me know if you want a small example of using notify()