i am trying to control Master pitch by 1 semitone on each step of my plugin by cc#100 at channel 1, as you will

see here in my code .

as i am seeing a midi cc# value(0-127) = totel 128 units. so i tried it with 2 methods

-----------Method 1________

i set my knob range to 12.

when pitch knob at center pitch=0,

when fully rotated to left pitch= -1200cents,

when fully rotated to left pitch = +1200 cents .

so totel steps are 24 .

i think 1 step interval will be .... 128/24 =5.33.

so i declared variable (semi_key) multiply with 5.33 to get pitch inc/dec by 100cents/1semitone.

i thought when semi_key =12; , it will do knob to center & get pitch=0.

and chenge pitch in semitones , as i will inc or dec semi_key

and i use code this

```
float semi_key = 12.00;
float Pitch_cc = 63.00;
void loop() {
if (c == 25) { if (semi_key > 0) { semi_key--;
Pitch_cc = ((5.33*semi_key)-1);
controlChange(1,100, Pitch_cc);
MidiUSB.flush(); }}
if (c == 26) { semi_key =12.00;
Pitch_cc = ((5.33*semi_key)-1);
controlChange(1,100, Pitch_cc);
MidiUSB.flush(); }
if (c == 27) { if (semi_key < 24) {semi_key++;
Pitch_cc = ((5.33*semi_key)-1);
controlChange(1,100, Pitch_cc);
MidiUSB.flush(); }}
}
```

## but it got result ,,

##
when semi_key=0 , getting pitch = -28cents , instead of 0 ......(28 cents up)

when semi_key is increased from 0 . getting +85 . instead of +100 .....(15 cents less)

when decreased from 0 . getting pitch =-123 . instead of -100....(23 cent 0ver)

Method 2 ----

i set my knob range to 16

when pitch knob at center pitch=0,

when fully rotated to left pitch= -1600cents,

when fully rotated to left pitch = +1600 cents .

so totel steps are 32.

i think 1 step interval will be .... 128/32 =4.

so i declared variable (semi_key) multiply with 4 to get pitch inc/dec by 100cents/1semitone.

i thought when semi_key =16; , it will do knob to center & get pitch=0.

and chenge pitch in semitones , as i will inc or dec semi_key

and i use code this

```
float semi_key = 16.00;
float Pitch_cc = 63.00;
void loop() {
if (c == 25) { if (semi_key > 0) { semi_key--;
Pitch_cc = ((4*semi_key)-1);
controlChange(1,100, Pitch_cc);
MidiUSB.flush(); }}
if (c == 26) { semi_key =16.00;
Pitch_cc = ((4*semi_key)-1);
controlChange(1,100, Pitch_cc);
MidiUSB.flush(); }
if (c == 27) { if (semi_key < 32) {semi_key++;
Pitch_cc = ((4*semi_key)-1);
controlChange(1,100, Pitch_cc);
MidiUSB.flush(); }}
}
```

## but it got result ,,

##
when semi_key=0 , getting pitch = -13 cents , instead of 0 ......(13 cents up)

when semi_key is increased from 0 . getting +88 . instead of +100 .. (12 cents less)

when decreased from 0 . getting pitch =-113 instead of -100 ......(13cents over)

in both Metods am not getting accurate pitch changes . where am i doing mistake??????