Skip to main content

VU meter and Waveform painter

Products: Video Capture SDK .Net, Video Edit SDK .Net, Media Player SDK .Net

WinForms sample

WinForms VU meter

  1. Add VisioForge.Controls.UI.WinForms.VolumeMeterPro.VolumeMeter control to the form. For stereo, you can add second control.

  2. Set Audio_VUMeter\Pro_Enabled property to true before the Start/Play method call.

  3. Add OnAudioVUMeterProVolume event handle in your MediaPlayer or VideoCapture control instance.

private void VideoCapture1_OnAudioVUMeterProVolume(object sender, AudioLevelEventArgs e)
{
volumeMeter1.Amplitude = e.ChannelLevelsDb[0];
if (e.ChannelLevelsDb.Length > 1)
{
volumeMeter2.Amplitude = e.ChannelLevelsDb[1];
}
}

WinForms Waveform painter

  1. Add VisioForge.Controls.UI.WinForms.VolumeMeterPro.WaveformPainter control to the form. For stereo, you can add second control.

  2. Set Audio_VUMeter\Pro\Enabled property to true before the Start/Play method call.

  3. Add OnAudioVUMeterProVolume event handle in your MediaPlayer or VideoCapture control instance.

private void VideoCapture1_OnAudioVUMeterProVolume(object sender, AudioLevelEventArgs e)
{
waveformPainter1.AddMax(e.ChannelLevelsDb[0]);
if (e.ChannelLevelsDb.Length > 1)
{
waveformPainter2.AddMax(e.ChannelLevelsDb[1]);
}
}

WPF sample

WPF VU meter

  1. Add VisioForge.Controls.UI.WPF.VolumeMeterPro.VolumeMeter control to the form. For stereo, you can add second control.

  2. Set Audio\VUMeter\Pro\Enabled property to true before the Start/Play method call.

VideoCapture1.Audio_VUMeter_Pro_Enabled = true;

volumeMeter1.Start();
volumeMeter2.Start();
  1. Add OnAudioVUMeterProVolume event handle in your MediaPlayer or VideoCapture control instance.
private delegate void AudioVUMeterProVolumeDelegate(AudioLevelEventArgs e);

private void AudioVUMeterProVolumeDelegateMethod(AudioLevelEventArgs e)
{
volumeMeter1.Amplitude = e.ChannelLevelsDb[0];
volumeMeter1.Update();

if (e.ChannelLevelsDb.Length > 1)
{
volumeMeter2.Amplitude = e.ChannelLevelsDb[1];
volumeMeter2.Update();
}
}

private void VideoCapture1_OnAudioVUMeterProVolume(object sender, AudioLevelEventArgs e)
{
Dispatcher.BeginInvoke(new AudioVUMeterProVolumeDelegate(AudioVUMeterProVolumeDelegateMethod), e);
}
  1. After stopping playback, stop volume meters
volumeMeter1.Stop();
volumeMeter1.Clear();

volumeMeter2.Stop();
volumeMeter2.Clear();

WPF Waveform painter

  1. Add VisioForge.Controls.UI.WPF.VolumeMeterPro.WaveformPainter control to the form. For stereo, you can add second control.

  2. Set Audio\VUMeter\Pro\Enabled property to true before the Start/Play method call.

VideoCapture1.Audio_VUMeter_Pro_Enabled = true;
waveformPainter.Start();
  1. Add OnAudioVUMeterProMaximumCalculated event handle in your MediaPlayer or VideoCapture control instance.
private delegate void AudioVUMeterProMaximumCalculatedDelegate(VUMeterMaxSampleEventArgs e);

private void AudioVUMeterProMaximumCalculatedelegateMethod(VUMeterMaxSampleEventArgs e)
{
waveformPainter.AddValue(e.MaxSample, e.MinSample);
}

private void VideoCapture1_OnAudioVUMeterProMaximumCalculated(object sender, VUMeterMaxSampleEventArgs e)
{
Dispatcher.BeginInvoke(new AudioVUMeterProMaximumCalculatedDelegate(AudioVUMeterProMaximumCalculatedelegateMethod), e);
}
  1. After stopping playback, stop volume meters
waveformPainter.Stop();
waveformPainter.Clear();

Required redists

  • SDK redist

How to install required redists or deploy them to the user's PC?


Visit our GitHub page to get more code samples.