I have a "test" 50 Hz tone signal, stored as 4-byte floating point values. The sample rate is 5120 Hz. The signal (roughly 0.25 seconds' worth) and the corresponding FFT are shown in this image:
The data file is then processed by converting the floats into 2-byte short values via an amplitude scaler (6.214e-5). The shorts are then scaled back into floats via the same scaler value. I'm doing this as a test case for other processing operations; the "real" data is not a single tone, and may arrive as either shorts or floats, but is always converted to floats before the FFT.
The problem is that in this very simple case, converting the data from float to short and back to float, I seem to be introducing harmonics in the FFT, as shown here:
The harmonics appear at regular 20 Hz separations.
I am trying to understand how these harmonics appear in what ought to be very nearly the same data values. I've compared the data files in MatLab, calculating the differences between data values, and only see differences on the order of +/- 6e-5, which I would expect given the short-to-float conversion.
Part of the processing involves buffering the data into fixed-size arrays, then performing the FFT on that array's worth of data. Could the size of those arrays be implicated in the harmonics showing up? (E.g., perhaps the array size is not some proper multiple of the sample rate?)
A colleague suggested that a sample (or samples) may be getting dropped during the processing, but I am not sure how missing a sample could create these harmonics across the entire data set.
Any suggestions for culprits?