| 296 | } |
| 297 | |
| 298 | bool SpectrogramSettings::Validate(bool quiet) |
| 299 | { |
| 300 | if (!quiet && |
| 301 | maxFreq < 100) { |
| 302 | BasicUI::ShowMessageBox( XO("Maximum frequency must be 100 Hz or above") ); |
| 303 | return false; |
| 304 | } |
| 305 | else |
| 306 | maxFreq = std::max(100, maxFreq); |
| 307 | |
| 308 | if (!quiet && |
| 309 | minFreq < 0) { |
| 310 | BasicUI::ShowMessageBox( XO("Minimum frequency must be at least 0 Hz") ); |
| 311 | return false; |
| 312 | } |
| 313 | else |
| 314 | minFreq = std::max(0, minFreq); |
| 315 | |
| 316 | if (!quiet && |
| 317 | maxFreq <= minFreq) { |
| 318 | BasicUI::ShowMessageBox( XO( |
| 319 | "Minimum frequency must be less than maximum frequency") ); |
| 320 | return false; |
| 321 | } |
| 322 | else |
| 323 | maxFreq = std::max(1 + minFreq, maxFreq); |
| 324 | |
| 325 | if (!quiet && |
| 326 | range <= 0) { |
| 327 | BasicUI::ShowMessageBox( XO("The range must be at least 1 dB") ); |
| 328 | return false; |
| 329 | } |
| 330 | else |
| 331 | range = std::max(1, range); |
| 332 | |
| 333 | if (!quiet && |
| 334 | frequencyGain < 0) { |
| 335 | BasicUI::ShowMessageBox( XO("The frequency gain cannot be negative") ); |
| 336 | return false; |
| 337 | } |
| 338 | else if (!quiet && |
| 339 | frequencyGain > 60) { |
| 340 | BasicUI::ShowMessageBox( XO( |
| 341 | "The frequency gain must be no more than 60 dB/dec") ); |
| 342 | return false; |
| 343 | } |
| 344 | else |
| 345 | frequencyGain = |
| 346 | std::max(0, std::min(60, frequencyGain)); |
| 347 | |
| 348 | // The rest are controlled by drop-down menus so they can't go wrong |
| 349 | // in the Preferences dialog, but we also come here after reading fom saved |
| 350 | // preference files, which could be or from future versions. Validate quietly. |
| 351 | windowType = |
| 352 | std::max(0, std::min(NumWindowFuncs() - 1, windowType)); |
| 353 | scaleType = |
| 354 | ScaleType(std::max(0, |
| 355 | std::min((int)(SpectrogramSettings::stNumScaleTypes) - 1, |
nothing calls this directly
no test coverage detected