Merge branch 'MoonModules:mdev' into downsample4x
This commit is contained in:
@@ -145,7 +145,11 @@ static float fftAvg[NUM_GEQ_CHANNELS] = {0.0f}; // Calculated frequency chann
|
||||
static float agcSensitivity = 128; // AGC sensitivity estimation, based on agc gain (multAgc). calculated by getSensitivity(). range 0..255
|
||||
|
||||
// user settable parameters for limitSoundDynamics()
|
||||
static bool limiterOn = true; // bool: enable / disable dynamics limiter
|
||||
#ifdef UM_AUDIOREACTIVE_DYNAMICS_LIMITER_OFF
|
||||
static bool limiterOn = false; // bool: enable / disable dynamics limiter
|
||||
#else
|
||||
static bool limiterOn = true;
|
||||
#endif
|
||||
static uint16_t attackTime = 50; // int: attack time in milliseconds. Default 0.08sec
|
||||
static uint16_t decayTime = 300; // int: decay time in milliseconds. New default 300ms. Old default was 1.40sec
|
||||
|
||||
@@ -994,19 +998,21 @@ class AudioReactive : public Usermod {
|
||||
int8_t mclkPin = MCLK_PIN;
|
||||
#endif
|
||||
#endif
|
||||
// new "V2" audiosync struct - 40 Bytes
|
||||
struct audioSyncPacket {
|
||||
char header[6]; // 06 Bytes
|
||||
float sampleRaw; // 04 Bytes - either "sampleRaw" or "rawSampleAgc" depending on soundAgc setting
|
||||
float sampleSmth; // 04 Bytes - either "sampleAvg" or "sampleAgc" depending on soundAgc setting
|
||||
uint8_t samplePeak; // 01 Bytes - 0 no peak; >=1 peak detected. In future, this will also provide peak Magnitude
|
||||
uint8_t frameCounter; // 01 Bytes - track duplicate/out of order packets
|
||||
uint8_t fftResult[16]; // 16 Bytes
|
||||
float FFT_Magnitude; // 04 Bytes
|
||||
float FFT_MajorPeak; // 04 Bytes
|
||||
// new "V2" audiosync struct - 44 Bytes
|
||||
struct __attribute__ ((packed)) audioSyncPacket { // WLEDMM "packed" ensures that there are no additional gaps
|
||||
char header[6]; // 06 Bytes offset 0
|
||||
uint8_t gap1[2]; // gap added by compiler: 02 Bytes, offset 6
|
||||
float sampleRaw; // 04 Bytes offset 8 - either "sampleRaw" or "rawSampleAgc" depending on soundAgc setting
|
||||
float sampleSmth; // 04 Bytes offset 12 - either "sampleAvg" or "sampleAgc" depending on soundAgc setting
|
||||
uint8_t samplePeak; // 01 Bytes offset 16 - 0 no peak; >=1 peak detected. In future, this will also provide peak Magnitude
|
||||
uint8_t frameCounter; // 01 Bytes offset 17 - track duplicate/out of order packets
|
||||
uint8_t fftResult[16]; // 16 Bytes offset 18
|
||||
uint8_t gap2[2]; // gap added by compiler: 02 Bytes, offset 34
|
||||
float FFT_Magnitude; // 04 Bytes offset 36
|
||||
float FFT_MajorPeak; // 04 Bytes offset 40
|
||||
};
|
||||
|
||||
// old "V1" audiosync struct - 83 Bytes - for backwards compatibility
|
||||
// old "V1" audiosync struct - 83 Bytes payload, 88 bytes total - for backwards compatibility
|
||||
struct audioSyncPacket_v1 {
|
||||
char header[6]; // 06 Bytes
|
||||
uint8_t myVals[32]; // 32 Bytes
|
||||
@@ -1022,7 +1028,7 @@ class AudioReactive : public Usermod {
|
||||
#define UDPSOUND_MAX_PACKET 96 // max packet size for audiosync, with a bit of "headroom"
|
||||
|
||||
// set your config variables to their boot default value (this can also be done in readFromConfig() or a constructor if you prefer)
|
||||
#ifdef SR_ENABLE_DEFAULT
|
||||
#if defined(SR_ENABLE_DEFAULT) || defined(UM_AUDIOREACTIVE_ENABLE)
|
||||
bool enabled = true; // WLEDMM
|
||||
#else
|
||||
bool enabled = false;
|
||||
@@ -1611,6 +1617,9 @@ class AudioReactive : public Usermod {
|
||||
my_magnitude = fmaxf(receivedPacket->FFT_Magnitude, 0.0f);
|
||||
FFT_Magnitude = my_magnitude;
|
||||
FFT_MajorPeak = constrain(receivedPacket->FFT_MajorPeak, 1.0f, 11025.0f); // restrict value to range expected by effects
|
||||
soundPressure = volumeSmth; // substitute - V2 format does not (yet) include this value
|
||||
agcSensitivity = 128.0f; // substitute - V2 format does not (yet) include this value
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1640,6 +1649,8 @@ class AudioReactive : public Usermod {
|
||||
my_magnitude = fmaxf(receivedPacket->FFT_Magnitude, 0.0);
|
||||
FFT_Magnitude = my_magnitude;
|
||||
FFT_MajorPeak = constrain(receivedPacket->FFT_MajorPeak, 1.0, 11025.0); // restrict value to range expected by effects
|
||||
soundPressure = volumeSmth; // substitute - V1 format does not include this value
|
||||
agcSensitivity = 128.0f; // substitute - V1 format does not include this value
|
||||
}
|
||||
|
||||
bool receiveAudioData() // check & process new data. return TRUE in case that new audio data was received.
|
||||
@@ -1897,6 +1908,26 @@ class AudioReactive : public Usermod {
|
||||
DEBUGSR_PRINTLN(enabled ? F("true.") : F("false."));
|
||||
USER_FLUSH();
|
||||
|
||||
// dump audiosync data layout
|
||||
#if defined(SR_DEBUG)
|
||||
{
|
||||
audioSyncPacket data;
|
||||
USER_PRINTF("\naudioSyncPacket_v1 size = %d\n", sizeof(audioSyncPacket_v1)); // size 88
|
||||
USER_PRINTF("audioSyncPacket size = %d\n", sizeof(audioSyncPacket)); // size 44
|
||||
USER_PRINTF("| char header[6] offset = %2d size = %2d\n", offsetof(audioSyncPacket, header[0]), sizeof(data.header)); // offset 0 size 6
|
||||
USER_PRINTF("| uint8_t gap1[2] offset = %2d size = %2d\n", offsetof(audioSyncPacket, gap1[0]), sizeof(data.gap1)); // offset 6 size 2
|
||||
USER_PRINTF("| float sampleRaw offset = %2d size = %2d\n", offsetof(audioSyncPacket, sampleRaw), sizeof(data.sampleRaw)); // offset 8 size 4
|
||||
USER_PRINTF("| float sampleSmth offset = %2d size = %2d\n", offsetof(audioSyncPacket, sampleSmth), sizeof(data.sampleSmth)); // offset 12 size 4
|
||||
USER_PRINTF("| uint8_t samplePeak offset = %2d size = %2d\n", offsetof(audioSyncPacket, samplePeak), sizeof(data.samplePeak)); // offset 16 size 1
|
||||
USER_PRINTF("| uint8_t frameCounter offset = %2d size = %2d\n", offsetof(audioSyncPacket, frameCounter), sizeof(data.frameCounter)); // offset 17 size 1
|
||||
USER_PRINTF("| uint8_t fftResult[16] offset = %2d size = %2d\n", offsetof(audioSyncPacket, fftResult[0]), sizeof(data.fftResult)); // offset 18 size 16
|
||||
USER_PRINTF("| uint8_t gap2[2] offset = %2d size = %2d\n", offsetof(audioSyncPacket, gap2[0]), sizeof(data.gap2)); // offset 34 size 2
|
||||
USER_PRINTF("| float FFT_Magnitude offset = %2d size = %2d\n", offsetof(audioSyncPacket, FFT_Magnitude), sizeof(data.FFT_Magnitude));// offset 36 size 4
|
||||
USER_PRINTF("| float FFT_MajorPeak offset = %2d size = %2d\n", offsetof(audioSyncPacket, FFT_MajorPeak), sizeof(data.FFT_MajorPeak));// offset 40 size 4
|
||||
USER_PRINTLN(); USER_FLUSH();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP32) && defined(SR_DEBUG)
|
||||
DEBUGSR_PRINTF("|| %-9s min free stack %d\n", pcTaskGetTaskName(NULL), uxTaskGetStackHighWaterMark(NULL)); //WLEDMM
|
||||
#endif
|
||||
@@ -1993,12 +2024,12 @@ class AudioReactive : public Usermod {
|
||||
DEBUG_PRINTF( " RealtimeMode = %d; RealtimeOverride = %d\n", int(realtimeMode), int(realtimeOverride));
|
||||
}
|
||||
#endif
|
||||
if ((disableSoundProcessing == true) && (audioSyncEnabled < AUDIOSYNC_REC)) lastUMRun = millis(); // just left "realtime mode" - update timekeeping
|
||||
if ((disableSoundProcessing == true) && (audioSyncEnabled != AUDIOSYNC_REC)) lastUMRun = millis(); // just left "realtime mode" - update timekeeping
|
||||
disableSoundProcessing = false;
|
||||
}
|
||||
|
||||
if (audioSyncEnabled == AUDIOSYNC_REC) disableSoundProcessing = true; // make sure everything is disabled IF in audio Receive mode
|
||||
if (audioSyncEnabled & AUDIOSYNC_SEND) disableSoundProcessing = false; // keep running audio IF we're in audio Transmit mode
|
||||
if (audioSyncEnabled == AUDIOSYNC_SEND) disableSoundProcessing = false; // keep running audio IF we're in audio Transmit mode
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
if (!audioSource->isInitialized()) { // no audio source
|
||||
disableSoundProcessing = true;
|
||||
@@ -2110,6 +2141,8 @@ class AudioReactive : public Usermod {
|
||||
volumeSmth =0.0f;
|
||||
volumeRaw =0;
|
||||
my_magnitude = 0.1; FFT_Magnitude = 0.01; FFT_MajorPeak = 2;
|
||||
soundPressure = 1.0f;
|
||||
agcSensitivity = 64.0f;
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
multAgc = 1;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user