# Each argument is accessed by a MIDI controller. Camera eyeX,Y,Z control

**URL:** <https://discourse.processing.org/t/each-argument-is-accessed-by-a-midi-controller-camera-eyex-y-z-control/22716>\
**Category:** Libraries\
**Created:** [July 19, 2020, 6:10am UTC](https://discourse.processing.org/t/each-argument-is-accessed-by-a-midi-controller-camera-eyex-y-z-control/22716 "2020-07-19T06:10:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sq20](https://avatars.discourse-cdn.com/v4/letter/s/df788c/32.png) [@sq20](https://discourse.processing.org/u/sq20)\
**Post date:** [July 19, 2020, 6:10am UTC](https://discourse.processing.org/t/each-argument-is-accessed-by-a-midi-controller-camera-eyex-y-z-control/22716/1 "2020-07-19T06:10:30Z")

</div>

I’m trying to control the camera view using a MIDI controller.  
For each knob, we want to control it by attaching it to X, Y, and Z.  
But when I do X,Y,Z control in my code, when I touch the X knob, other knobs such as Y,Z are converted to initial values.

We want the initial value to always be stored as the last value.

I want to know an example of how to modify what part.

Regards.

```auto
import themidibus.*;
MidiBus myBus;

int ccChannel;
int ccNumber;
int ccValue;

void setup() {
  size(400, 400, P3D);
  //background(0);
  MidiBus.list();
  myBus = new MidiBus(this, 0, 1); 
  
  
}

void draw() {
  //model
  noStroke();
  background(0);
  lights();
  translate(0, height/2, -height/2);
  fill(153);
  box(50);
  translate(width, 0.0);
  fill(255);
  sphere(50);
  
  //camera
  camera(ctlX(), ctlY(), ctlZ(),// eye, eyeY, eyeZ
  0.0, 0.0, 0.0, //centerX, centerT, centerZ
  0.0, 1.0, 0.0);//upX, upY, upZ)

println(ctlX(), ctlY(), ctlZ());

}

void controllerChange(int channel, int number, int value) {
  ccChannel = channel;
  ccNumber = number;
  ccValue = value;
  println("channel " + channel, "number " + number, "value " + value);
}

float ctlX() {
  float x = 0.1;
  if (ccNumber == 16) {
  x = map(ccValue, 0, 127, 0.0, 200.0);
  } 
   return x;
}
float ctlY() {
  float y = 0.1;
  if (ccNumber == 17) {
  y = map(ccValue, 0, 127, 0.0, 200.0);
  } 
   return y;
}

float ctlZ() {
  float z = 0.1;
  if (ccNumber == 18) {
  z = map(ccValue, 0, 127, 0.0, 800.0);
  } 
   return z;

}

```

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [July 19, 2020, 9:48am UTC](https://discourse.processing.org/t/each-argument-is-accessed-by-a-midi-controller-camera-eyex-y-z-control/22716/2 "2020-07-19T09:48:39Z")

</div>

Pseudo-code:

```auto
float ctlY() {
  float y = 0.1;
  if (ccNumber == 17) {

  if(y==0) {
   return oldValuey; 
  } else {
  y = map(ccValue, 0, 127, 0.0, 200.0);
  oldValuey=y; 
  }

  } 
   return y;
}

```
