| 812 | } |
| 813 | |
| 814 | void NoiseReductionBase::Worker::GatherStatistics(MyTransformer& transformer) |
| 815 | { |
| 816 | ++mStatistics.mTrackWindows; |
| 817 | |
| 818 | { |
| 819 | // NEW statistics |
| 820 | auto pPower = transformer.NthWindow(0).mSpectrums.data(); |
| 821 | auto pSum = mStatistics.mSums.data(); |
| 822 | for (size_t jj = 0; jj < mSettings.SpectrumSize(); ++jj) |
| 823 | { |
| 824 | *pSum++ += *pPower++; |
| 825 | } |
| 826 | } |
| 827 | |
| 828 | #ifdef OLD_METHOD_AVAILABLE |
| 829 | // The noise threshold for each frequency is the maximum |
| 830 | // level achieved at that frequency for a minimum of |
| 831 | // mMinSignalBlocks blocks in a row - the max of a min. |
| 832 | |
| 833 | auto finish = mHistoryLen; |
| 834 | |
| 835 | { |
| 836 | // old statistics |
| 837 | auto pPower = NthWindow(0).mSpectrums.data(); |
| 838 | auto pThreshold = mStatistics.mNoiseThreshold.data(); |
| 839 | for (size_t jj = 0; jj < mSpectrumSize; ++jj) |
| 840 | { |
| 841 | float min = *pPower++; |
| 842 | for (unsigned ii = 1; ii < finish; ++ii) |
| 843 | min = std::min(min, NthWindow(ii).mSpectrums[jj]); |
| 844 | *pThreshold = std::max(*pThreshold, min); |
| 845 | ++pThreshold; |
| 846 | } |
| 847 | } |
| 848 | #endif |
| 849 | } |
| 850 | |
| 851 | // Return true iff the given band of the "center" window looks like noise. |
| 852 | // Examine the band in a few neighboring windows to decide. |