Each frame contains the VU-meter level data ready to be used. Which makes the VU meter displaying a pretty easy task: all you need is pick the VU meter data from the frame you process and display it.
Get the frame from a source
It can be MFReader, MFLive, or any custom frames source.
mySource.SourceFrameGet(-1, out myFrame, "");
Get the frame's audio and video properties
The properties are stored in M_AV_PROPS structure:
myFrame.MFAVPropsGet(out myProps, out audioSamples);
Get the VU-meter level data
The data array is a field of ancillary data in the M_AV_PROPS structure. There are 3 types of audio volume information representation available now:
- the RMS (actual volume information),
- the VU meter (the dynamic volume information with attack and release ramps),
- and VU meter peaks.
NOTE: The M_AV_PROPS structure contains 2 arrays of audio volume information: the original one (that was provided by the source) and the output one (after applying all the modifications).
// The array of original VU meter values.
float originalChannelsVUmeterArr = myAV_Props.ancData.audOriginal.arrVUMeter;
// The array of output VU meter values.
float outputChannelsVUmeterArr = myAV_Props.ancData.audOutput.arrVUMeter;
Enumerate the array to get the VU meter level for each audio channel
NOTE: the array of VU meter values contains 16 items by default. This value does not match the real number of audio channels of the frame, so you should refer to nChannels field of M_AUD_PROPS structure to get the real number of channels.
// Get the real number of audio channels
int numberOfChannels = avProps.audProps.nChannels;
// Enumerate the VU level values for audio channels
for (int i = 0; i < numberOfChannels; i++)
// Get the VU level value for the current audio channel
float channelVUmeterValue = outputChannelsVUmeterArr[i];
Depending on the required VU meter display accuracy you can process not every single frame audio data, but each 10-th, 20-th etc. to reduce the resources consummation.