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

Method OnMeterUpdate

src/widgets/MeterPanel.cpp:980–1075  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

978//}
979
980void MeterPanel::OnMeterUpdate(wxTimerEvent & WXUNUSED(event))
981{
982 MeterUpdateMsg msg;
983 int numChanges = 0;
984#ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
985 double maxPeak = 0.0;
986 bool discarded = false;
987#endif
988
989 // We shouldn't receive any events if the meter is disabled, but clear it to be safe
990 if (mMeterDisabled) {
991 mQueue.Clear();
992 return;
993 }
994
995
996 // There may have been several update messages since the last
997 // time we got to this function. Catch up to real-time by
998 // popping them off until there are none left. It is necessary
999 // to process all of them, otherwise we won't handle peaks and
1000 // peak-hold bars correctly.
1001 while(mQueue.Get(msg)) {
1002 numChanges++;
1003 double deltaT = msg.numFrames / mRate;
1004
1005 mT += deltaT;
1006 for(unsigned int j=0; j<mNumBars; j++) {
1007 mBar[j].isclipping = false;
1008
1009 //
1010 if (mDB) {
1011 msg.peak[j] = ToDB(msg.peak[j], mDBRange);
1012 msg.rms[j] = ToDB(msg.rms[j], mDBRange);
1013 }
1014
1015 if (mDecay) {
1016 if (mDB) {
1017 float decayAmount = mDecayRate * deltaT / mDBRange;
1018 mBar[j].peak = floatMax(msg.peak[j],
1019 mBar[j].peak - decayAmount);
1020 }
1021 else {
1022 double decayAmount = mDecayRate * deltaT;
1023 double decayFactor = DB_TO_LINEAR(-decayAmount);
1024 mBar[j].peak = floatMax(msg.peak[j],
1025 mBar[j].peak * decayFactor);
1026 }
1027 }
1028 else
1029 mBar[j].peak = msg.peak[j];
1030
1031 // This smooths out the RMS signal
1032 float smooth = pow(0.9, (double)msg.numFrames/1024.0);
1033 mBar[j].rms = mBar[j].rms * smooth + msg.rms[j] * (1.0 - smooth);
1034
1035 if (mT - mBar[j].peakHoldTime > mPeakHoldDuration ||
1036 mBar[j].peak > mBar[j].peakHold) {
1037 mBar[j].peakHold = mBar[j].peak;

Callers

nothing calls this directly

Calls 7

ToDBFunction · 0.85
floatMaxFunction · 0.85
AILAIsActiveMethod · 0.80
AILAProcessMethod · 0.80
ClearMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected