Mercurial > ~darius > hgwebdir.cgi > modulator
changeset 29:babdb5376356
Fix interpolator setup.
- Don't overflow the shape table at the end of pulse up
- Don't generate bogus offsets
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Thu, 27 Feb 2025 15:19:32 +1030 |
parents | 600a394629e6 |
children | 92fdf2ef995d |
files | modulator.c |
diffstat | 1 files changed, 7 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/modulator.c Thu Feb 27 13:58:37 2025 +1030 +++ b/modulator.c Thu Feb 27 15:19:32 2025 +1030 @@ -188,8 +188,10 @@ nsamples = shapesamples * 2 * ncode + codegap * (ncode - 1) + slew1 + slew2 + 1; } - // Number of steps per samples in the pulse shape - stepsize = qdiv(qint(shapelen), qint(shapesamples)); + // How far to advance the shape pointer for each sample point + // Needs to be 1 less than the shape length otherwise we overflow + // at the end of the pulse up. + stepsize = qdiv(qint(shapelen - 1), qint(shapesamples)); qsprint(stepsize, tmps, sizeof(tmps)); printf("shapelen = %d shapesamples = %lu nsamples = %lu stepsize = %s\n", shapelen, shapesamples, nsamples, tmps); @@ -213,7 +215,7 @@ // Mask start is 0 because we use 8 bit samples cfg = interp_default_config(); interp_config_set_shift(&cfg, QBITS); - interp_config_set_mask(&cfg, 0, 32 - QBITS); + interp_config_set_mask(&cfg, 0, 32 - QBITS - 1); interp_config_set_blend(&cfg, true); interp_set_config(interp0, 0, &cfg); @@ -287,6 +289,7 @@ for (uint16_t i = 0; i < shapesamples; i++) { ctrl[idx] = ctrltmp; if (c == 0) { + // First code bit // Get sample pair uint8_t *sample_pair = (uint8_t *) interp0->peek[2]; // Ask lane 1 for a LERP, using the lane 0 accumulator @@ -304,6 +307,7 @@ } if (c == 0) bit1stopup = idx - 1; + // Pulse down // Since the pulse is symmetrical just copy the up slope in reverse // XXX: if we had asymmetrical predistortion this wouldn't be true