Class AudioSource
- Namespace
- VisioForge.Core.Types.VideoEdit
- Assembly
- VisioForge.Core.dll
Represents an audio source that can be used in video editing operations.
public class AudioSourceInheritance
Inherited Members
Remarks
The VisioForge.Core.Types.VideoEdit.AudioSource class defines an audio file or stream that can be included in a video editing project. It supports various configurations including multi-segment playback, stream selection, playback rate control, and synchronization with video files.
Key features:
- Support for multiple file segments with custom start/stop times
- Multiple audio stream selection from multi-stream files
- Variable playback rate (speed up or slow down audio)
- Audio/video synchronization capabilities
Common use cases:
- Adding background music to a video
- Extracting audio from video files
- Creating audio mashups with multiple segments
- Synchronizing audio tracks with video content
Constructors
AudioSource(string, TimeSpan?, TimeSpan?, string, int, double)
Initializes a new instance of the VisioForge.Core.Types.VideoEdit.AudioSource class with a single time segment.
public AudioSource(string filename, TimeSpan? startTime = null, TimeSpan? stopTime = null, string fileToSync = null, int streamNumber = 0, double rate = 1)Parameters
filenamestring-
The path to the audio file. Supports various formats including MP3, WAV, AAC, OGG, FLAC, and audio streams from video containers.
startTimeTimeSpan?-
The start time of the segment to use. Set to
nullto start from the beginning of the file. If bothstartTimeandstopTimearenull, the entire file is used. stopTimeTimeSpan?-
The stop time of the segment to use. Set to
nullto play until the end of the file. If bothstartTimeandstopTimearenull, the entire file is used. fileToSyncstring-
Optional file path for synchronization. Required when extracting audio from video files to maintain proper audio/video sync. Typically the same as
filenamefor video sources. streamNumberint-
The zero-based index of the audio stream to use from multi-stream files. Default is 0 (first stream).
ratedouble-
The playback rate multiplier. 1.0 = normal speed (100%), 2.0 = double speed (200%), 0.5 = half speed (50%). Valid range is typically 0.1 to 10.0.
Remarks
This constructor creates an audio source with a single continuous segment. For multiple non-contiguous segments, use the constructor that accepts a VisioForge.Core.Types.VideoEdit.FileSegment array.
AudioSource(string, FileSegment[], string, int, double)
Initializes a new instance of the VisioForge.Core.Types.VideoEdit.AudioSource class with multiple segments.
public AudioSource(string filename, FileSegment[] segments, string fileToSync = null, int streamNumber = 0, double rate = 1)Parameters
filenamestring-
The path to the audio file. Supports various formats including MP3, WAV, AAC, OGG, FLAC, and audio streams from video containers.
segmentsFileSegment[]-
An array of VisioForge.Core.Types.VideoEdit.FileSegment objects defining multiple portions of the audio file to use. Segments are played in the order they appear in the array.
fileToSyncstring-
Optional file path for synchronization. Required when extracting audio from video files to maintain proper audio/video sync. Typically the same as
filenamefor video sources. streamNumberint-
The zero-based index of the audio stream to use from multi-stream files. Default is 0 (first stream).
ratedouble-
The playback rate multiplier. 1.0 = normal speed (100%), 2.0 = double speed (200%), 0.5 = half speed (50%). Valid range is typically 0.1 to 10.0.
Remarks
This constructor allows creation of complex audio compositions by selecting multiple non-contiguous segments from a single audio file. Segments are played sequentially in the order they appear in the array.
This is useful for:
- Creating highlight reels or best-of compilations
- Removing unwanted sections (commercials, silence, etc.)
- Rearranging audio content non-linearly
Properties
FileToSync
Gets or sets the file path used for synchronization reference.
public string FileToSync { get; set; }Property Value
Remarks
This property is crucial when extracting audio from video files to maintain proper audio/video synchronization. It ensures that the audio timing matches the video timing from the source file, preventing sync issues.
Common scenarios requiring FileToSync:
- Extracting audio track from a video file
- Replacing audio in a video while maintaining sync
- Using audio from one video file with visuals from another
Filename
Gets or sets the path to the audio file.
public string Filename { get; set; }Property Value
Remarks
The file path can be absolute or relative. When extracting audio from video files, ensure the VisioForge.Core.Types.VideoEdit.AudioSource.StreamNumber property is set correctly to select the desired audio stream.
IgnorePlaybackCheck
Gets or sets a value indicating whether to bypass file validation and playback compatibility checks.
public bool IgnorePlaybackCheck { get; set; }Property Value
Remarks
When set to true, the system will attempt to process the audio file even if:
- The file format is not recognized
- The codec is not supported
- The file appears to be corrupted
- Required codecs are missing
Use this option with caution as it may lead to unexpected behavior or processing failures. It's primarily intended for advanced scenarios where you need to work with non-standard or proprietary formats.
Rate
Gets or sets the playback rate (speed) of the audio.
public double Rate { get; set; }Property Value
Remarks
Changing the playback rate affects both the speed and pitch of the audio unless pitch correction is applied. Values greater than 1.0 speed up playback, while values less than 1.0 slow it down.
Common use cases:
- Creating slow-motion effects (rate < 1.0)
- Creating fast-forward effects (rate > 1.0)
- Adjusting audio duration to match video timing
- Creating comedic or dramatic effects
Segments
Gets or sets the list of segments to be played from the audio file.
public FileSegment[] Segments { get; set; }Property Value
Remarks
Segments allow you to use specific portions of an audio file without modifying the original file. Multiple segments can be defined to create a non-linear playback sequence.
If segments overlap, they will be played sequentially, not simultaneously. To play the entire file, use a single segment with null start and stop times.
StreamNumber
Gets or sets the audio stream number to use from multi-stream files.
public int StreamNumber { get; set; }Property Value
Remarks
Many video files contain multiple audio streams (e.g., different languages, commentary tracks). This property allows selection of a specific audio stream when the source file contains multiple streams.
Use 0 for the first audio stream, 1 for the second, and so on. If the specified stream doesn't exist, the first available audio stream will be used.