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

Method UpdateDisplay

src/widgets/MeterPanel.cpp:898–933  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

896}
897
898void MeterPanel::UpdateDisplay(
899 unsigned numChannels, int numFrames, const float *sampleData)
900{
901 auto sptr = sampleData;
902 auto num = std::min(numChannels, mNumBars);
903 MeterUpdateMsg msg;
904
905 memset(&msg, 0, sizeof(msg));
906 msg.numFrames = numFrames;
907
908 for(int i=0; i<numFrames; i++) {
909 for(unsigned int j=0; j<num; j++) {
910 msg.peak[j] = floatMax(msg.peak[j], fabs(sptr[j]));
911 msg.rms[j] += sptr[j]*sptr[j];
912
913 // In addition to looking for mNumPeakSamplesToClip peaked
914 // samples in a row, also send the number of peaked samples
915 // at the head and tail, in case there's a run of peaked samples
916 // that crosses block boundaries
917 if (fabs(sptr[j])>=MAX_AUDIO) {
918 if (msg.headPeakCount[j]==i)
919 msg.headPeakCount[j]++;
920 msg.tailPeakCount[j]++;
921 if (msg.tailPeakCount[j] > mNumPeakSamplesToClip)
922 msg.clipping[j] = true;
923 }
924 else
925 msg.tailPeakCount[j] = 0;
926 }
927 sptr += numChannels;
928 }
929 for(unsigned int j=0; j<mNumBars; j++)
930 msg.rms[j] = sqrt(msg.rms[j]/numFrames);
931
932 mQueue.Put(msg);
933}
934
935// Vaughan, 2010-11-29: This not currently used. See comments in MixerTrackCluster::UpdateMeter().
936//void MeterPanel::UpdateDisplay(int numChannels, int numFrames,

Callers

nothing calls this directly

Calls 4

floatMaxFunction · 0.85
minFunction · 0.50
sqrtFunction · 0.50
PutMethod · 0.45

Tested by

no test coverage detected