Refactor um_data: remove inputLevel
This commit is contained in:
parent
c1f9445e9d
commit
dfa1a3ad90
@ -824,7 +824,7 @@ class AudioReactive : public Usermod {
|
||||
// usermod exchangeable data
|
||||
// we will assign all usermod exportable data here as pointers to original variables or arrays and allocate memory for pointers
|
||||
um_data = new um_data_t;
|
||||
um_data->u_size = 10;
|
||||
um_data->u_size = 9;
|
||||
um_data->u_type = new um_types_t[um_data->u_size];
|
||||
um_data->u_data = new void*[um_data->u_size];
|
||||
um_data->u_data[0] = &volumeSmth; //*used (New)
|
||||
@ -845,8 +845,6 @@ class AudioReactive : public Usermod {
|
||||
um_data->u_type[7] = UMT_BYTE;
|
||||
um_data->u_data[8] = fftBin; //*used (for debugging) (only once, Binmap)
|
||||
um_data->u_type[8] = UMT_FLOAT_ARR;
|
||||
um_data->u_data[9] = &inputLevel; // global UI element!!! (Gravimeter, Binmap)
|
||||
um_data->u_type[9] = UMT_BYTE;
|
||||
}
|
||||
|
||||
// Reset I2S peripheral for good measure
|
||||
|
@ -5972,15 +5972,15 @@ static const char *_data_FX_MODE_2DDRIFTROSE PROGMEM = "2D Drift Rose@Fade,Blur;
|
||||
float *fftBin = nullptr;
|
||||
um_data_t *um_data;
|
||||
if (usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
||||
volumeSmth = *(float*) um_data->u_data[0];
|
||||
volumeRaw = *(float*) um_data->u_data[1];
|
||||
fftResult = (uint8_t*) um_data->u_data[2];
|
||||
samplePeak = *(uint8_t*) um_data->u_data[3];
|
||||
FFT_MajorPeak = *(float*) um_data->u_data[4];
|
||||
fftResult = (uint8_t*) um_data->u_data[2];
|
||||
my_magnitude = *(float*) um_data->u_data[5];
|
||||
maxVol = (uint8_t*) um_data->u_data[6]; // requires UI element (SEGMENT.customX?), changes source element
|
||||
binNum = (uint8_t*) um_data->u_data[7]; // requires UI element (SEGMENT.customX?), changes source element
|
||||
volumeSmth = *(float*) um_data->u_data[0];
|
||||
fftBin = (float*) um_data->u_data[8];
|
||||
inputLevel = (uint8_t*) um_data->u_data[9]; // requires UI element (SEGMENT.customX?), changes source element
|
||||
volumeRaw = *(float*) um_data->u_data[1];
|
||||
} else {
|
||||
// add support for no audio data
|
||||
um_data = simulateSound(SEGMENT.soundSim);
|
||||
@ -6669,7 +6669,7 @@ uint16_t WS2812FX::mode_binmap(void) {
|
||||
maxVol = (uint8_t*)um_data->u_data[6];
|
||||
#endif
|
||||
fftBin = (float*) um_data->u_data[8];
|
||||
inputLevel = (uint8_t*)um_data->u_data[9];
|
||||
inputLevel = (uint8_t*)um_data->u_data[10];
|
||||
}
|
||||
if (!fftBin) return mode_static();
|
||||
|
||||
|
@ -402,8 +402,6 @@ um_data_t* simulateSound(uint8_t simulationId)
|
||||
static uint8_t maxVol;
|
||||
static uint8_t binNum;
|
||||
|
||||
uint8_t inputLevel;
|
||||
|
||||
static float volumeSmth;
|
||||
static uint16_t volumeRaw;
|
||||
static float my_magnitude;
|
||||
@ -423,7 +421,7 @@ um_data_t* simulateSound(uint8_t simulationId)
|
||||
// NOTE!!!
|
||||
// This may change as AudioReactive usermod may change
|
||||
um_data = new um_data_t;
|
||||
um_data->u_size = 10;
|
||||
um_data->u_size = 9;
|
||||
um_data->u_type = new um_types_t[um_data->u_size];
|
||||
um_data->u_data = new void*[um_data->u_size];
|
||||
um_data->u_data[0] = &volumeSmth;
|
||||
@ -435,7 +433,6 @@ um_data_t* simulateSound(uint8_t simulationId)
|
||||
um_data->u_data[6] = &maxVol;
|
||||
um_data->u_data[7] = &binNum;
|
||||
um_data->u_data[8] = fftBin; //only used in binmap
|
||||
um_data->u_data[9] = &inputLevel;
|
||||
} else {
|
||||
// get arrays from um_data
|
||||
fftResult = (uint8_t*)um_data->u_data[2];
|
||||
@ -500,7 +497,6 @@ um_data_t* simulateSound(uint8_t simulationId)
|
||||
FFT_MajorPeak = volumeSmth;
|
||||
maxVol = 10; // this gets feedback fro UI
|
||||
binNum = 8; // this gets feedback fro UI
|
||||
inputLevel = 128; // this gets feedback fro UI
|
||||
volumeRaw = volumeSmth;
|
||||
my_magnitude = 10000.0 / 8.0f; //no idea if 10000 is a good value for FFT_Magnitude ???
|
||||
if (volumeSmth < 1 ) my_magnitude = 0.001f; // noise gate closed - mute
|
||||
|
Loading…
Reference in New Issue
Block a user