rescaled lookup table
This commit is contained in:
parent
6a8e0686a6
commit
d0a259a960
|
|
@ -85,7 +85,7 @@ void Module::runLFO() {
|
||||||
|
|
||||||
pw = (lfoState & 0x02) ? lfoPhase + 0x2000 : 0x2000 - lfoPhase; // PW LFO is unipolar
|
pw = (lfoState & 0x02) ? lfoPhase + 0x2000 : 0x2000 - lfoPhase; // PW LFO is unipolar
|
||||||
pw = (patchRam.switch2 & 0x01) ? 0x3fff : pw; // either LFO or "all on"
|
pw = (patchRam.switch2 & 0x01) ? 0x3fff : pw; // either LFO or "all on"
|
||||||
pw = 0x3fff - ((pw * (int)(patchRam.pwmLfo*1.45)) >> 7); // FIXME tidy up this bit
|
pw = 0x3fff - ((pw * (int)(patchRam.pwmLfo * 1.45)) >> 7); // FIXME tidy up this bit
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::run(Voice* voices, uint32_t blockSize) {
|
void Module::run(Voice* voices, uint32_t blockSize) {
|
||||||
|
|
@ -173,18 +173,24 @@ void Module::run(Voice* voices, uint32_t blockSize) {
|
||||||
int8_t semi = pitch >> 8;
|
int8_t semi = pitch >> 8;
|
||||||
semi -= 36;
|
semi -= 36;
|
||||||
float frac = (pitch & 0xff) / 256.0;
|
float frac = (pitch & 0xff) / 256.0;
|
||||||
if (semi<0) { semi=0; frac = 0; }
|
if (semi < 0) {
|
||||||
if (semi>=103) { semi=103; frac = 0; };
|
semi = 0;
|
||||||
|
frac = 0;
|
||||||
|
}
|
||||||
|
if (semi >= 103) {
|
||||||
|
semi = 103;
|
||||||
|
frac = 0;
|
||||||
|
};
|
||||||
float p1 = pitchTable[semi], p2 = pitchTable[semi + 1];
|
float p1 = pitchTable[semi], p2 = pitchTable[semi + 1];
|
||||||
int16_t px = ((p2 - p1) * frac + p1); // interpolated pitch from table
|
int16_t px = ((p2 - p1) * frac + p1); // interpolated pitch from table
|
||||||
|
|
||||||
// octave divider
|
// octave divider
|
||||||
px *= (patchRam.switch1 & 0x07);
|
px *= (patchRam.switch1 & 0x07);
|
||||||
|
|
||||||
v->omega = px / (sampleRate * 4.0f); // FIXME recalculate table using proper scaler
|
v->omega = px / sampleRate; // FIXME recalculate table using proper scaler
|
||||||
|
|
||||||
// per voice we need to calculate the key follow amount and envelope amount
|
// per voice we need to calculate the key follow amount and envelope amount
|
||||||
v->vcfCut = vcfBase + (((v->env * patchRam.vcfEnv)>>7) * ((patchRam.switch2 & 0x02) ? -1 : 1));
|
v->vcfCut = vcfBase + (((v->env * patchRam.vcfEnv) >> 7) * ((patchRam.switch2 & 0x02) ? -1 : 1));
|
||||||
|
|
||||||
v->vcfCut += (int)((v->note - 36) * (patchRam.vcfKey << 1) * 0.375);
|
v->vcfCut += (int)((v->note - 36) * (patchRam.vcfKey << 1) * 0.375);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -89,19 +89,19 @@ uint16_t lfoDelayTable[8] = {
|
||||||
0xffff, 0x0419, 0x020c, 0x015e, 0x0100, 0x0100, 0x0100, 0x0100};
|
0xffff, 0x0419, 0x020c, 0x015e, 0x0100, 0x0100, 0x0100, 0x0100};
|
||||||
|
|
||||||
float pitchTable[104] = {
|
float pitchTable[104] = {
|
||||||
32.494, 34.430, 36.486, 38.658, 40.962, 43.399, 45.990, 48.731,
|
8.123, 8.607, 9.122, 9.664, 10.240, 10.850, 11.497, 12.183,
|
||||||
51.633, 54.711, 57.969, 61.419, 65.072, 68.944, 73.059, 77.405,
|
12.908, 13.678, 14.492, 15.355, 16.268, 17.236, 18.265, 19.351,
|
||||||
82.014, 86.892, 92.077, 97.556, 103.365, 109.529, 116.043, 122.933,
|
20.504, 21.723, 23.019, 24.389, 25.841, 27.382, 29.011, 30.733,
|
||||||
130.242, 137.988, 146.220, 154.919, 164.136, 173.898, 184.264, 195.217,
|
32.561, 34.497, 36.555, 38.730, 41.034, 43.474, 46.066, 48.804,
|
||||||
206.847, 219.178, 232.207, 245.972, 260.586, 276.091, 292.569, 309.981,
|
51.712, 54.795, 58.052, 61.493, 65.147, 69.023, 73.142, 77.495,
|
||||||
328.407, 347.947, 368.664, 390.549, 413.822, 438.500, 464.576, 492.005,
|
82.102, 86.987, 92.166, 97.637, 103.455, 109.625, 116.144, 123.001,
|
||||||
521.241, 552.334, 585.309, 620.155, 657.030, 696.136, 737.463, 781.250,
|
130.310, 138.083, 146.327, 155.039, 164.258, 174.034, 184.366, 195.312,
|
||||||
827.815, 877.193, 929.368, 984.252, 1042.753, 1104.972, 1170.960, 1240.695,
|
206.954, 219.298, 232.342, 246.063, 260.688, 276.243, 292.740, 310.174,
|
||||||
1314.060, 1392.758, 1474.926, 1562.500, 1655.629, 1754.386, 1858.736, 1968.504,
|
328.515, 348.189, 368.732, 390.625, 413.907, 438.596, 464.684, 492.126,
|
||||||
2085.506, 2209.945, 2341.920, 2481.390, 2628.121, 2785.515, 2949.853, 3125.000,
|
521.376, 552.486, 585.480, 620.347, 657.030, 696.379, 737.463, 781.250,
|
||||||
3311.258, 3508.772, 3717.472, 3937.008, 4175.365, 4424.779, 4683.841, 4962.779,
|
827.815, 877.193, 929.368, 984.252, 1043.841, 1106.195, 1170.960, 1240.695,
|
||||||
5263.158, 5571.031, 5899.705, 6250.000, 6622.517, 7017.544, 7434.944, 7874.016,
|
1315.789, 1392.758, 1474.926, 1562.500, 1655.629, 1754.386, 1858.736, 1968.504,
|
||||||
8333.333, 8849.558, 9389.671, 9950.249, 10526.316, 11173.184, 11834.320, 12500.000
|
2083.333, 2212.389, 2347.418, 2487.562, 2631.579, 2793.296, 2958.580, 3125.000,
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Loading…
Reference in New Issue