49 env.
GetPoints( when.get(), value.get(), numPoints );
53 mCurves[ curve ].points.clear();
58 for (
size_t point = 0; point < numPoints; point++)
60 double freq = when[ point ] * hiFreq;
61 double db = value[ point ];
69 double loLog = log10( 20. );
70 double hiLog = log10( hiFreq );
71 double denom = hiLog - loLog;
74 for (
size_t point = 0; point < numPoints; point++)
76 double freq = pow( 10., ( ( when[ point ] * denom ) + loLog ));
77 double db = value[ point ];
88 size_t numPoints = logEnvelope.GetNumberOfPoints();
91 logEnvelope.GetPoints(when.get(), value.get(), numPoints);
92 for (
size_t i = 0, j = 0; j + 2 < numPoints; i++, j++)
94 if ((value[i] < value[i + 1] + .05) && (value[i] > value[i + 1] - .05) &&
95 (value[i + 1] < value[i + 2] + .05) && (value[i + 1] > value[i + 2] - .05))
97 logEnvelope.Delete(j + 1);
120 wxASSERT( currentCurve < (
int)
mCurves.size() );
123 int numPoints = (int)
mCurves[currentCurve].points.size();
127 env.SetTrackLen(1.0);
130 if (numPoints == 0) {
138 if (numPoints == 1) {
140 when =
mCurves[currentCurve].points[0].Freq;
142 when = when / hiFreq;
146 double loLog = log10((
double)loFreqI);
147 double hiLog = log10(hiFreq);
148 double denom = hiLog - loLog;
150 (log10(std::max<double>(loFreqI, when))
153 value =
mCurves[currentCurve].points[0].dB;
154 env.Insert(
std::min(1.0, std::max(0.0, when)), value);
160 std::sort(
mCurves[currentCurve].points.begin(),
161 mCurves[currentCurve].points.end());
163 if (
mCurves[currentCurve].points[0].Freq < 0) {
170 for(
int pointCount = 0; pointCount < numPoints; pointCount++) {
171 when =
mCurves[currentCurve].points[pointCount].Freq / hiFreq;
172 value =
mCurves[currentCurve].points[pointCount].dB;
174 env.Insert(when, value);
182 double nextDB =
mCurves[currentCurve].points[pointCount].dB;
183 if (pointCount > 0) {
184 double nextF =
mCurves[currentCurve].points[pointCount].Freq;
185 double lastF =
mCurves[currentCurve].points[pointCount-1].Freq;
186 double lastDB =
mCurves[currentCurve].points[pointCount-1].dB;
189 ((hiFreq - lastF) / (nextF - lastF)));
193 env.Insert(when, value);
199 double loLog = log10((
double) loFreqI);
200 double hiLog = log10(hiFreq);
201 double denom = hiLog - loLog;
206 for (firstAbove20Hz = 0; firstAbove20Hz < numPoints; firstAbove20Hz++) {
207 if (
mCurves[currentCurve].points[firstAbove20Hz].Freq > loFreqI)
211 if (firstAbove20Hz == numPoints) {
214 value =
mCurves[currentCurve].points[numPoints-1].dB;
215 env.Insert(when, value);
220 if (firstAbove20Hz > 0) {
223 double prevF =
mCurves[currentCurve].points[firstAbove20Hz-1].Freq;
224 prevF = log10(std::max(1.0, prevF));
225 double prevDB =
mCurves[currentCurve].points[firstAbove20Hz-1].dB;
226 double nextF = log10(
mCurves[currentCurve].points[firstAbove20Hz].Freq);
227 double nextDB =
mCurves[currentCurve].points[firstAbove20Hz].dB;
229 value = nextDB - ((nextDB - prevDB) * ((nextF - loLog) / (nextF - prevF)));
230 env.Insert(when, value);
234 for(
int pointCount = firstAbove20Hz; pointCount < numPoints; pointCount++)
236 double flog = log10(
mCurves[currentCurve].points[pointCount].Freq);
237 wxASSERT(
mCurves[currentCurve].points[pointCount].Freq >= loFreqI);
239 when = (flog - loLog)/denom;
240 value =
mCurves[currentCurve].points[pointCount].dB;
242 env.Insert(when, value);
258 if (pointCount > 0) {
259 double lastDB =
mCurves[currentCurve].points[pointCount-1].dB;
261 log10(
mCurves[currentCurve].points[pointCount-1].Freq);
264 ((log10(hiFreq) - logLastF) / (flog - logLastF)));
266 env.Insert(when, value);
282 for( i = 0; i <
mCurves.size(); i++ )
283 if( curveName ==
mCurves[ i ].Name )
289 XO(
"Requested curve not found, using 'unnamed'"),
Toolkit-neutral facade for basic user interface services.
Piecewise linear or piecewise exponential function from double to double.
size_t GetNumberOfPoints() const
Return number of points.
void GetPoints(double *bufferWhen, double *bufferValue, int bufferLen) const
Returns the sets of when and value pairs.
void Flatten(double value)
MessageBoxResult ShowMessageBox(const TranslatableString &message, MessageBoxOptions options={})
Show a modal message box with either Ok or Yes and No, and optionally Cancel.
MessageBoxOptions && IconStyle(Icon style) &&
EqualizationFilter & mParameters
static constexpr int loFreqI
const Envelope & ChooseEnvelope() const