MCPcopy Create free account
hub / github.com/audacity/audacity / Run

Method Run

src/import/FormatClassifier.cpp:129–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127}
128
129void FormatClassifier::Run()
130{
131 // Calc the mono feature vector
132 for (unsigned int n = 0; n < mClasses.size(); n++)
133 {
134 // Read the signal
135 ReadSignal(mClasses[n], 1);
136#ifdef FORMATCLASSIFIER_SIGNAL_DEBUG
137 mpWriter->WriteSignal(mSigBuffer, cSiglen);
138#endif
139
140 // Do some simple preprocessing
141 // Remove DC offset
142 float smean = Mean(mSigBuffer.get(), cSiglen);
143 Sub(mSigBuffer.get(), smean, cSiglen);
144 // Normalize to +- 1.0
145 Abs(mSigBuffer.get(), mAuxBuffer.get(), cSiglen);
146 float smax = Max(mAuxBuffer.get(), cSiglen);
147 Div(mSigBuffer.get(), smax, cSiglen);
148
149 // Now actually fill the feature vector
150 // Low to high band power ratio
151 float pLo = mMeter.CalcPower(mSigBuffer.get(), 0.15f, 0.3f);
152 float pHi = mMeter.CalcPower(mSigBuffer.get(), 0.45f, 0.1f);
153 mMonoFeat[n] = pLo / pHi;
154 }
155
156 // Calc the stereo feature vector
157 for (unsigned int n = 0; n < mClasses.size(); n++)
158 {
159 // Read the signal
160 ReadSignal(mClasses[n], 2);
161#ifdef FORMATCLASSIFIER_SIGNAL_DEBUG
162 mpWriter->WriteSignal(mSigBuffer, cSiglen);
163#endif
164
165 // Do some simple preprocessing
166 // Remove DC offset
167 float smean = Mean(mSigBuffer.get(), cSiglen);
168 Sub(mSigBuffer.get(), smean, cSiglen);
169 // Normalize to +- 1.0
170 Abs(mSigBuffer.get(), mAuxBuffer.get(), cSiglen);
171 float smax = Max(mAuxBuffer.get(), cSiglen);
172 Div(mSigBuffer.get(), smax, cSiglen);
173
174 // Now actually fill the feature vector
175 // Low to high band power ratio
176 float pLo = mMeter.CalcPower(mSigBuffer.get(), 0.15f, 0.3f);
177 float pHi = mMeter.CalcPower(mSigBuffer.get(), 0.45f, 0.1f);
178 mStereoFeat[n] = pLo / pHi;
179 }
180
181 // Get the results
182 size_t midx, sidx;
183 float monoMax = Max(mMonoFeat.get(), mClasses.size(), &midx);
184 float stereoMax = Max(mStereoFeat.get(), mClasses.size(), &sidx);
185
186 if (monoMax > stereoMax)

Callers 3

InitPart2Method · 0.45
OnRescanMethod · 0.45

Calls 4

WriteSignalMethod · 0.80
CalcPowerMethod · 0.80
sizeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected