trying to make sound pressure less boring for line-in

"sound pressure" for line-in was always close to max - which is expected, because the ADC chip utilize the full 24/16bit sample range.
The new calculation leads to some more "movement".
This commit is contained in:
Frank
2023-04-10 23:57:44 +02:00
parent 25122f982c
commit a1bdb47c30

View File

@@ -1269,8 +1269,12 @@ class AudioReactive : public Usermod {
float micSampleMax = fabsf(sampleReal); // from getSample() - nice results, however a bit distorted by MicLev processing
//float micSampleMax = fabsf(micDataReal); // from FFTCode() - better source, but more flickering
if (dmType == 0) micSampleMax *= 2.0f; // correction for ADC analog
if (dmType == 4) micSampleMax *= 16.0f; // correction for I2S Line-In
//if (dmType == 4) micSampleMax *= 16.0f; // correction for I2S Line-In
if (dmType == 5) micSampleMax *= 2.0f; // correction for PDM
if (dmType == 4) { // I2S Line-In. This is a dirty trick to make sound pressure look interesting for line-in (which doesn't have "sound pressure" as its not a microphone)
micSampleMax /= 11.0f; // reduce to max 128
micSampleMax *= micSampleMax; // blow up --> max 16000
}
// make sure we are in expected ranges
if(micSampleMax <= sampleMin) return 0.0f;
if(micSampleMax >= sampleMax) return 255.0f;