Setting Custom Volume Levels for Audio Tracks in C# Applications¶
Video Edit SDK .Net VideoEditCore
Overview¶
Managing audio volume levels is a critical aspect of video production and editing applications. This guide demonstrates how to implement individual volume controls for separate audio tracks in your .NET application.
Implementation Details¶
Setting custom volume levels for audio tracks gives your users more precise control over their audio mix. Each track can have its own independent volume setting, allowing for professional-quality audio balancing.
Sample Code Implementation¶
The following C# example shows how to apply a volume envelope effect to an audio track:
// AudioVolumeEnvelopeEffect(level) sets a constant volume for the track.
// Optional StartTime / StopTime (TimeSpan) restrict the effect to a time window.
var volume = new AudioVolumeEnvelopeEffect(level: 10);
// The 5-arg Input_AddAudioFile overload takes an AudioSource (not a string),
// so wrap the file path before passing it alongside the effect array.
// Signature: Input_AddAudioFile(AudioSource, TimeSpan? timelineInsertTime = null,
// int targetStreamIndex = 0, AudioTrackEffect[] effects = null,
// TimelineAudioTrackCustomSettings = null)
var audioSource = new AudioSource(audioFile);
VideoEdit1.Input_AddAudioFile(audioSource, null, 0, new[] { volume });
Understanding the Parameters¶
AudioVolumeEnvelopeEffect(level: 10): constant-volume envelope. Level is anint; useStartTime/StopTimeproperties (bothTimeSpan) to scope the effect to a time window.audioFile(string) must be wrapped in anew AudioSource(...)— the effects-array overload ofInput_AddAudioFileonly accepts anAudioSource, not a raw filename.Input_AddAudioFile: adds the audio file to the timeline with the given effects applied to the chosen audio stream.
Required Dependencies¶
To implement this functionality, you'll need the following redistributable packages:
- Video Edit SDK redistributables:
- x86 package
- x64 package
Deployment Information¶
For information about installing or deploying the required components to your end users' systems, please refer to our deployment guide.
Additional Resources¶
For more code examples and implementation techniques, visit our GitHub repository with complete sample projects.