We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi,
I am very new to Processing and try to experiment with creating visuals with a midi track. As a starter I tried to simply draw a line with a midi controller. It does receive the controller data because if I println(value) it shows the value of my controller but it doesn't use it to draw something.
Any help appreciated.
Answers
Might be a threading issue where controllerChange() is called outside of the draw loop. Processing 3 got really strict on where you call graphic methods. Try storing
value
in a global variable and call line() in draw.Thanks for your reply. I tried the following but it doesn't work. What I don't understand is, if I return a variable from inside the ControllerChange function, how can I grab this variable? Obviously, I am not calling the function in draw. Thanks!
Can you still receive midi messages in controllerChange()? Try changing it back to void and replace
return value;
withthis.value = value;
.PDE comes w/ lotsa Processing examples, including those from contributed libraries.
Hit CTRL+SHIFT+O to open it. Then click at "Contributed Libraries". And finally "The MidiBus".
@colouredmirrorball: You're a legend, thanks a lot, it works now. If you have a minute here a follow-up question: 1. If I want to access not only value but also the number and channel variables outside of ControlChange, how would that work?
Sure, just make them global variables as well.
It might get complex if you make a new variable for each possible combination of channel and number, maybe you can create an array (2D if you want to include channel in addition to number) or a little class. It's really going to depend on what you want to do with them further on...
interesting topic. I am new to Processing, and tried to follow the code posted above, but if I replace return value; with this.value=value; I'll get an error message ("this method must return a result of type int"). anybody can help with this?
It's because you didn't change the return type of the method back to void.
ok, understand now, thank you so much for your help!