VU meter and Waveform painter
Products: Video Capture SDK .Net, Video Edit SDK .Net, Media Player SDK .Net
WinForms sample
WinForms VU meter
-
Add the "VisioForge.Core.UI.WinForms.VolumeMeterPro.VolumeMeter" control to the form. For stereo, you can add a second control.
-
Set the Audio_VUMeterPro_Enabled property to true before the Start/Play method call.
-
Add the 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
-
Add the "VisioForge.Core.UI.WinForms.VolumeMeterPro.WaveformPainter" control to the form. For stereo, you can add a second control.
-
Set the Audio_VUMeter_Pro_Enabled property to true before the Start/Play method call.
-
Add the 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
-
Add the "VisioForge.Controls.UI.WPF.VolumeMeterPro.VolumeMeter" control to the form. For stereo, you can add a second control.
-
Set the Audio_VUMeter_Pro_Enabled property to true before the Start/Play method call.
VideoCapture1.Audio_VUMeter_Pro_Enabled = true;
volumeMeter1.Start();
volumeMeter2.Start();
- Add the 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);
}
- After stopping playback, stop the volume meters
volumeMeter1.Stop();
volumeMeter1.Clear();
volumeMeter2.Stop();
volumeMeter2.Clear();
WPF Waveform painter
-
Add the "VisioForge.Core.UI.WPF.VolumeMeterPro.WaveformPainter" control to the form. For stereo, you can add a second control.
-
Set the Audio_VUMeter_Pro_Enabled property to true before the Start/Play method call.
VideoCapture1.Audio_VUMeter_Pro_Enabled = true;
waveformPainter.Start();
- Add the OnAudioVUMeterProMaximumCalculated event handle in your MediaPlayerCore or VideoCaptureCore 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);
}
- After stopping playback, stop the volume meters
waveformPainter.Stop();
waveformPainter.Clear();
Required redists
- SDK redist
Visit our GitHub page to get more code samples.