MCPcopy Create free account
hub / github.com/awawa-dev/HyperHDR / Smooth

Method Smooth

sources/base/SoundCaptureResult.cpp:75–276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73
74
75void SoundCaptureResult::Smooth()
76{
77 int32_t currentAverage = 0, distance = 0, red = 0, green = 0, blue = 0;
78
79 MovingTarget res = mtInternal;
80
81 _validData = true;
82
83 for (int i = 0; i < SOUNDCAP_RESULT_RES; i++)
84 {
85 int32_t buffResult = (pureResult[i] + lastResult[i]) / 2;
86
87 if (maxResult[i] <= buffResult && buffResult > 400)
88 {
89 if (maxResult[i] == 0)
90 _validData = false;
91
92 maxResult[i] = buffResult;
93
94 for (int j = 0; j < SOUNDCAP_RESULT_RES; j++)
95 if (i != j && maxResult[j] < buffResult / 4 && maxResult[j] < 400)
96 maxResult[j] = buffResult / 4;
97 }
98
99
100 if (_validData && maxResult[i] > 0)
101 {
102 int32_t sr = (pureResult[i] * 255) / maxResult[i];
103
104 if (sr > 255)
105 sr = 255;
106
107 pureScaledResult[i] = (uint8_t)sr;
108
109 if (pureScaledResult[i] >= buffScaledResult[i] || buffScaledResult[i] - deltas[i] < pureScaledResult[i])
110 {
111 buffScaledResult[i] = pureScaledResult[i];
112 deltas[i] = std::max(pureScaledResult[i] / 10, 3);
113 }
114 else
115 {
116 buffScaledResult[i] -= deltas[i];
117 deltas[i] = std::min((deltas[i] * 3) / 2, 255);
118 }
119 }
120
121 lastResult[i] = pureResult[i];
122 }
123
124 for (int j = 0; j < SOUNDCAP_RESULT_RES; j++)
125 {
126 int32_t max = maxResult[j];
127 if (max > 2000)
128 maxResult[j] = max - 2;
129
130 currentAverage += buffScaledResult[j];
131 }
132

Callers 1

analyzeSpectrumMethod · 0.80

Calls 5

ColorRgbClass · 0.85
getRGBMethod · 0.80
RedMethod · 0.80
GreenMethod · 0.80
BlueMethod · 0.80

Tested by

no test coverage detected