Sunday, February 8, 2026

JP80x0 midi to coefficient mapping tables

Pitch

MidiPitch
01555
11647
21745
31849
41959
52075
62198
72329
82468
92615
102770
112935
123110
133295
143491
153698
163918
174151
184397
194658
204936
215230
225541
235871
246220
256590
266982
277396
287836
298302
308794
319317
329873
3310460
3411082
3511742
3612441
3713181
3813965
3914792
4015672
4116604
4217589
4318635
4419747
4520921
4622164
4723485
4824883
4926362
5027930
5129585
5231345
5333209
5435179
5537270
5639494
5741842
5844329
5946970
6049767
6152725
6255860
6359171
6462691
6566418
6670358
6774541
6878988
6983684
7088659
7193941
7299534
73105450
74111720
75118342
76125382
77132836
78140716
79149082
80157976
81167368
82177318
83187882
84199068
85210900
86223440
87236684
88250764
89265672
90281432
91298164
92315952
93334736
94354636
95375764
96398136
97421800
98446880
99473368
100501528
101531344
102562864
103596328
104631904
105669472
106709272
107751528
108796272
109843600
110893760
111946736
1121003056
1131062688
1141125728
1151192656
1161263808
1171338944
 

Detune:

MidiuC
01
11
22
32
43
53
64
74
85
95
106
116
127
137
148
158
169
179
1810
1910
2011
2111
2212
2312
2413
2513
2614
2714
2815
2915
3016
3116
3217
3317
3418
3518
3619
3719
3820
3920
4021
4121
4222
4322
4423
4523
4624
4724
4825
4925
5026
5126
5227
5327
5428
5528
5629
5729
5830
5930
6031
6131
6232
6332
6433
6534
6635
6736
6837
6938
7039
7140
7241
7342
7443
7544
7645
7746
7847
7948
8049
8151
8253
8355
8457
8559
8661
8763
8865
8967
9069
9171
9273
9375
9477
9579
9681
9783
9885
9987
10089
10191
10293
10395
10497
10599
106101
107103
108105
109107
110109
111111
112113
113115
114117
115119
116121
117123
118125
119127
120129
121137
122145
123153
124169
125193
126225
127321
 

Mix

MidiMix
0102400
1118784
2135168
3151552
4167936
5184320
6200704
7217088
8233472
9249856
10266240
11282624
12299008
13315392
14331776
15348160
16364544
17380928
18397312
19413696
20430080
21446464
22462848
23479232
24495616
25512000
26528384
27544768
28561152
29577536
30593920
31610304
32626688
33643072
34659456
35675840
36692224
37708608
38724992
39741376
40757760
41774144
42790528
43806912
44823296
45839680
46856064
47872448
48888832
49905216
50921600
51937984
52954368
53970752
54987136
551003520
561019904
571036288
581052672
591069056
601085440
611101824
621118208
631134592
641150976
651167360
661183744
671200128
681216512
691232896
701249280
711265664
721282048
731298432
741314816
751331200
761347584
771363968
781380352
791396736
801413120
811429504
821445888
831462272
841478656
851495040
861511424
871527808
881544192
891560576
901576960
911593344
921609728
931626112
941642496
951658880
961675264
971691648
981708032
991724416
1001740800
1011757184
1021773568
1031789952
1041806336
1051822720
1061839104
1071855488
1081871872
1091888256
1101904640
1111921024
1121937408
1131953792
1141970176
1151986560
1162002944
1172019328
1182035712
1192052096
1202068480
1212084864
1222101248
1232117632
1242134016
1252150400
1262166784
1272183168
 

Tuesday, February 3, 2026

Confirming that the code is correct

This post shows the verification of the code in the previous post.


int24_t saw[7] = {0,0,0,0,0,0,0};

const int24_t detune_table[7] = {0, 128, -128, 408, -412, 704, -720};

int24_t next(int24_t pitch, int24_t mix, int24_t detune) {

int24_t sum = 0;

for (int i = 0; i < 7; i++) {
int24_t detunePitch = ((int48_t) pitch * detune) >> 23;
int24_t voice_detune = ((int48_t) detune_table[i] * detunePitch) >> 7;
saw[i] += pitch + voice_detune;

if (i == 0) {
sum += ((int48_t) saw[i] * 25) >> 7;
} else {
sum += ((int48_t) saw[i] * (mix >> 16)) >> 7;
}
}
return high_pass(sum);
}


Pitch

Pitch arrives at program memory location 0x0424, after some calculations pitch is stored at iram[0x65]. The same value arrives unchanged at the first oscillator calculation at 0x0455.
 
Pitch code is correct.


Detune

Detune arrives at 0x043f. The same value minus one arrives at the first oscillator calculation at 0x0455. Detune is stored in mulcoeffs[0]. 

With detune = midi 127 and pitch = midi 97, we get 

pitch = 421800 

detune = 164352

(pitch * detune) >> 23 = 8237

Test:

Osc 4 detune 8237 * 408 / 128 = 26255.4, from debugger: 26255

Osc 5 detune  8237 * -412 / 128 = -26512.8, from debugger: -26513

Osc 6 detune: 8237 * 704 / 128 = 45303.5, from debugger: 45303

Osc 7 detune: , 8237 * -720 / 128 = 46333.13, from debugger: -46334

 

Detune code is correct.

 

Mix

Mix arrives at 0x043c. The same value minus one arrives at the oscillator mixing code at 0x47a. Mix is stored in mulcoeffs[1] 

With mix = midi 127:

mix = mulcoeffs[1] = 2183167 (input - 1) 

mix >> 16 =  2183167 >> 16 = 33

 

Results below are found by stepping through the debugger. Iram contains the raw values for each saws.

Step 1: 

Iram 11 = -7537654

Result  = -1943302

Control: 

 -7537654 * 33 / 128 = - 1943301.4 // OK!

 

Step 2: 

Iram 6 = -8000810

Result = -4006011

Control: 

-8000810 * 33 / 128 = -2062708.8 // contrib from this osc

-2062708.8 - 1943302 = -4006011.8 // OK!


Step 3:

Iram 9 = 92969

Result = -3982043

Control: 

92969 * 33 / 128 = 23968.57 // contrib from this osc

23968.57 - 4006011.8 = -3982043.23 // OK! 


Step 4:

Iram 5 = -4968160

Result = -4952387

Control:  

-4968160 *25 / 128 = -907343.75 // center oscillator

-3982043 -907343.75 = -4952386.75 // OK!

 

Step 5: 

Iram 7 = 6361263

Result = -3312374

Control:  

6361263 * 33 / 128 = 1640013.12 // contrib from this osc

1640013.12 - 4952386.75 = -3312373.6 // OK!

 

Step 6: 

Iram 0b = 3650948

Result = -2371114

Control: 

3650948 * 33 / 128 = 941260.03 // contrib from this osc

941260.03 - 3312374 = -2371113.96 // OK!


Step 7:

Iram 0f is 6940947

Result = -581652

Control: 

6940947 * 33 / 128 = 1789462.0 // contrib from this osc

1789462.0 - 2371114 = -581651.1 // OK!

 

Summing code is correct.

 

Checking the detune coefficients

The integer coefficients we found:

[0, 128, -128, 408, -412, 704, -720]

The decimal coefficients in the presentation, that match Adam Szabo's detected ones:

[0, 0.01953125, -0.01953125, 0.06225585, -0.0628662, 0.107421875, -0.10986328125] 

These are 10/65536 times the integer coefficients (or 10 * (integer coefficient) >> 16). This holds true for all of the coefficients.

 

The coefficients are correct.