Loading...
Logo
Processing Forum
So for example i have 8 ellipses in my sketch, and i have 8 knobs on my midi (NANO Kontrol 2)
How can i move them seperately with the 8 knobs?
Like Knob 1 moves Ellipse 1, Knob 2 moves Ellipse 2, and so on ...
Now every knob or slider on my Midi Controller does the same.
I use the ProMIDI library
i can show you me sketch if you ask me, but its kinda big.

Replies(12)

You should post your code here.
In general, you should choose the MIDI channel you like to receive.
Any knob should send their position via one channel.
There is an example on the ProMIDI website:


-
Philipp Ronnenberg
Interaction design
-
http://www.phiron.de
Yeah i thought it would have something to do with the MIDI channel, put cant seem to figure out how to specifically write it in code. And the example above isnt helping me as well, already saw it. 
Im a beginner in processing and code language in general :)

Here is my sketch:

import promidi.*;

MidiIO midiIO;

int val = 0;
int num = 0;

void setup(){
size(128*5,128*5);
smooth();

midiIO = MidiIO.getInstance(this);
println("printPorts of midiIO");
midiIO.printDevices();
midiIO.openInput(1,0);
}

void controllerIn(
Controller controller,
int deviceNumber,
int midiChannel
){
num = controller.getNumber();
val = controller.getValue();
print(num);
}

void draw(){
background(0, 0, 0);
stroke(255);
fill(0, 0, 0);
strokeWeight(val/2);
ellipse(width/2,height/2,val*3,val*3);

strokeWeight(2);
ellipse(width/8*1-40,height/8,30,30);
ellipse(width/8*2-40,height/8,30,30);
ellipse(width/8*3-40,height/8,30,30);
ellipse(width/8*4-40,height/8,30,30);
ellipse(width/8*5-40,height/8,30,30);
ellipse(width/8*6-40,height/8,30,30);
ellipse(width/8*7-40,height/8,30,30);
ellipse(width/8*8-40,height/8,30,30);
}

those eight ellipses you see, I want to assign different knobs for.
Thanks for the comment!
As you can see, now i assign ALL the knobs and buttons and sliders from my midi to 1 ellipse, changing the radius and thickness of stroke when i turn them.
So what i need to do is take the 'val' number but specifically from 1 'num'.
But thats too far over my head :D
So you should see different numbers printing when rotating different knobs on your nano.
Copy code
  1. void controllerIn(Controller controller, int deviceNumber, int midiChannel) {
  2. num = controller.getNumber();
    val = controller.getValue();
    print(num); // <- this line should print the knobs number/note
    }
If you see those numbers changing, while rotating different knobs you should be able to control single ellipses.
Copy code
  1. if(num==1) do something with ellipse#1;

-
Philipp Ronnenberg
Interaction design
-
http://www.phiron.de
if(num = 1);
ellipse(width/8*1-40,val,30,30);

'cannot convert from int to boolean'
And yeah the numbers are changing :)
oh tried it with == and then he opens the sketch but it doenst work.
still all the knobs move ellipse nr 1 around
yeah ok i'm a noob, shouldnt put the ; there 
THANKS ALOT
this had bin a big braincrahs for me the last 2 days :D
the only thing thats bothering me now is that he only can show 1 ellipse, but thats probalby because of the 'if'

Put this on top of your code:
Copy code
  1. int[] values=new int[9];
Replace your controllerIn function:
Copy code
  1. void controllerIn(Controller controller,int deviceNumber,int midiChannel) {
  2. num = controller.getNumber();
  3. val = controller.getValue();
  4. print(num);
  5. // check your current num's and set the numbers to your specific knob:
  6. if(num==0) values[0] = val;
  7. if(num==1) values[1] = val;
  8. if(num==2) values[2] = val;
  9. // etc.
  10. }
Replace your current draw() with this:
Copy code
  1. void draw() {
  2.   for(int i=0; i<9; i++) {
  3.     strokeWeight(values[i]/2);
  4.     ellipse(width/8*i-40,height/8,30,30);
  5.   }
  6. }

-
Philipp Ronnenberg
Interaction design
-
http://www.phiron.de
thanks, looks complicated, will have a look though!
thanks for the help