Class ScaleTempoAudioEffect
- Namespace
- VisioForge.Core.Types.X.AudioEffects
- Assembly
- VisioForge.Core.dll
Scale tempo audio effect keeps the pitch of audio when the playback rate changes.
Uses the GStreamer 'scaletempo' element with WSOLA (Waveform Similarity Overlap-Add) algorithm.
In Media Blocks and MediaPlayerCoreX the speed comes from the playback rate (Rate_SetAsync);
at a rate of 1.0 the audio passes through unchanged. In VideoEditCoreX the speed is VisioForge.Core.Types.X.AudioEffects.ScaleTempoAudioEffect.Rate.
public class ScaleTempoAudioEffect : BaseAudioEffect, ISharedAudioEffectX, IVideoEditXAudioEffectInheritance
Implements
Inherited Members
Remarks
GStreamer element: scaletempo Properties:
- rate: read-only, follows the playback rate
- stride: Length of audio segments processed (in milliseconds)
- overlap: Percentage of segment overlap for smooth transitions
- search: Time window for finding best overlap position (in milliseconds)
WSOLA Algorithm:
- Divides audio into overlapping segments (stride length)
- Searches for best position to overlap segments (search window)
- Cross-fades overlapping portions (overlap percentage)
- Reconstructs audio at new tempo
Quality vs Efficiency trade-offs:
- Larger stride = faster processing, but more artifacts
- Larger search = better quality, but slower processing
- More overlap = smoother, but more CPU intensive
Best for:
- Speech (podcasts, audiobooks): stride=30-50ms, search=14ms
- Music: stride=15-30ms, search=20-30ms for better quality
- Real-time: smaller stride and search for lower latency
Constructors
ScaleTempoAudioEffect(double)
Initializes a new instance of the VisioForge.Core.Types.X.AudioEffects.ScaleTempoAudioEffect class.
public ScaleTempoAudioEffect(double rate = 1)Parameters
ratedouble-
The tempo multiplier, see VisioForge.Core.Types.X.AudioEffects.ScaleTempoAudioEffect.Rate.
Properties
Overlap
Gets or sets the percentage of stride length to overlap between adjacent segments. Higher overlap creates smoother transitions but requires more processing. Range: 0.0 (no overlap) to 1.0. Default: 0.2 (20%).
Typical values:
- 0.1-0.15: Minimal overlap, efficient but may have artifacts
- 0.2-0.3: Balanced quality and performance (default: 0.2)
- 0.4-0.6: High overlap, smoother but more CPU intensive
Increase for:
- More complex material (music with harmonics)
- Higher quality requirements
Decrease for:
- Real-time processing
- Simple material (speech, single instruments)
public double Overlap { get; set; }Property Value
Rate
Gets or sets the tempo multiplier. Used by VideoEditCoreX only, see the remarks.
public double Rate { get; set; }Property Value
Remarks
VideoEditCoreX: a rate other than 1.0 plays each clip the effect is applied to at that tempo with the
pitch kept, through the GStreamer pitch element, and its video at the same speed. 1.5 renders 6 s of
source in 4 s, and the clips after it move to follow. Only clips with audio change: a video-only clip, such as
one paired with a separate audio file, keeps its speed, so use a file with both for picture in step. A clip
on the same layer that starts inside the one that changed, an overlap for a transition, moves with its end,
so the overlap is kept; an overlap that does not fit in the new duration raises OnError, and that clip
plays at its original speed. VisioForge.Core.Types.X.AudioEffects.ScaleTempoAudioEffect.Stride, VisioForge.Core.Types.X.AudioEffects.ScaleTempoAudioEffect.Search and VisioForge.Core.Types.X.AudioEffects.ScaleTempoAudioEffect.Overlap do not
apply then. A rate outside 0.1-10 raises OnError and the effect is left out.
Media Blocks and MediaPlayerCoreX ignore it: the scaletempo element exposes its rate as
read-only, the speed comes from the playback rate (MediaBlocksPipeline.Rate_SetAsync,
MediaPlayerCoreX.Rate_SetAsync), and the effect keeps the pitch at that rate.
Search
Gets or sets the length of the search window for finding the best overlap position. Larger search windows find better matches but require more processing time. Default: 14 milliseconds.
Typical values:
- 5-10 ms: Fast, lower quality (real-time applications)
- 14-20 ms: Balanced (default: 14ms for speech)
- 20-40 ms: High quality (music, offline processing)
Increase for:
- Music or harmonic content
- When quality is priority over speed
Decrease for:
- Real-time or low-latency requirements
- Simple material like speech
public TimeSpan Search { get; set; }Property Value
Stride
Gets or sets the length of each audio segment (stride) to be processed. Determines the granularity of the time-stretching operation. Default: 30 milliseconds.
Typical values:
- 15-25 ms: Fine-grained, better for music
- 30-40 ms: Balanced (default: 30ms for speech)
- 50-100 ms: Coarse, efficient but may have noticeable artifacts
Shorter strides:
- Better quality for complex material
- More CPU intensive
- Better for music
Longer strides:
- More efficient processing
- Adequate for speech
- May produce audible artifacts in music
Note: Stride length affects perceived quality more than search or overlap.
public TimeSpan Stride { get; set; }Property Value
Methods
GenerateDescription()
Generates the description.
public string GenerateDescription()Returns
- string
-
System.String.