Restore PCM sample conversion.
As shipped, projectM converts incoming integer PCM samples to 32-bit
floats in the range [-2.0, 2.0]. Thinking this was an error, I fixed
this to convert to the range [-1.0, 1.0] (because signal processing
routines "obviously" expect their inputs to be in this range so they can
play all kinds of games with unit vectors, right?) Whether or not the
range [-1.0, 1.0] is actually preferable, unfortunately all the shipping
presets were written to expect the range [-2.0, 2.0], with the
consequence that they look less interesting if they operate on the
reduced range.
Change the sample conversion back such that 16-bit integer samples are
once again converted to floats in the range [-2.0, 2.0].
Change-Id: I89dbb6a2a758ca3c3874029ef8eb34ceed32fde2
diff --git a/src/libprojectM/PCM.cpp b/src/libprojectM/PCM.cpp
index 03aafe9..1caebd4 100644
--- a/src/libprojectM/PCM.cpp
+++ b/src/libprojectM/PCM.cpp
@@ -146,8 +146,8 @@
for (i = 0; i < samples; ++i) {
j = i + start;
- PCMd[0][j % maxsamples] = (pcm_data[i * 2 + 0] / 32768.0);
- PCMd[1][j % maxsamples] = (pcm_data[i * 2 + 1] / 32768.0);
+ PCMd[0][j % maxsamples] = (pcm_data[i * 2 + 0] / 16384.0);
+ PCMd[1][j % maxsamples] = (pcm_data[i * 2 + 1] / 16384.0);
}
start = (start + samples) % maxsamples;
@@ -172,8 +172,8 @@
for (i = 0; i < samples; i++) {
j = i + start;
if (PCMdata[0][i] != 0 && PCMdata[1][i] != 0) {
- PCMd[0][j % maxsamples] = (PCMdata[0][i] / 32768.0);
- PCMd[1][j % maxsamples] = (PCMdata[1][i] / 32768.0);
+ PCMd[0][j % maxsamples] = (PCMdata[0][i] / 16384.0);
+ PCMd[1][j % maxsamples] = (PCMdata[1][i] / 16384.0);
} else {
PCMd[0][j % maxsamples] = (float) 0;
PCMd[1][j % maxsamples] = (float) 0;