TimeStretch

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
m (*** TODO "channels are processed independently" ***)
m (*** TODO "an updated SoundTouch library is used" ***)
Line 122: Line 122:
 
* This is NOT a sample exact plugin. If you use it, slight inaccuracies might occur.{{Clarify}} Since we are dealing with float values rounding errors might occur, especially on large samples. In general however inaccuracies should not exceed a few 10's of milliseconds for movielength samples.
 
* This is NOT a sample exact plugin. If you use it, slight inaccuracies might occur.{{Clarify}} Since we are dealing with float values rounding errors might occur, especially on large samples. In general however inaccuracies should not exceed a few 10's of milliseconds for movielength samples.
  
* In '''TimeStretch''' 2.61 an updated [http://www.surina.net/soundtouch/ SoundTouch] library is used which supports multichannel audio. Prior versions supported stereo only. See this thread for details :- [http://forum.doom9.org/showthread.php?t=71632 ''TimeStretch in AVISynth 2.5.5 Alpha - Strange stereo effects?'']
+
* In 2.61 an updated [http://www.surina.net/soundtouch/ SoundTouch] library is used which supports multichannel audio. Prior versions supported stereo only. See this thread for details :- [http://forum.doom9.org/showthread.php?t=71632 ''TimeStretch in AVISynth 2.5.5 Alpha - Strange stereo effects?'']  
 +
:* [[TODO]] ''(this statement was unclear at the time of updating this documentation)''
 
</div>
 
</div>
  

Revision as of 05:46, 19 February 2016

Change the audio speed and/or pitch:

tempo adjusts speed while maintaining pitch.
rate adjusts speed while allowing pitch to rise or fall.
pitch adjusts pitch while maintaining speed.

You can use these parameters in any combination – for example, 104% tempo with 95% pitch.


Contents


Syntax and Parameters

TimeStretch(clip clip [, float tempo, float rate, float pitch,
      int sequence, int seekwindow, int overlap, bool quickseek, int aa ] )

clip
Audio sample type is automatically converted to Float.
If clip.AudioChannels=2, special processing is used to preserve stereo imaging. Otherwise, channels are processed independently. Independent processing works well for unrelated audio tracks, for not very well for surround sound; for that, try TimeStretchPlugin instead. * TODO (this information may not be up to date)
 Tempo, Rate and Pitch
float  tempo = 100.0
Changes speed and clip.AudioLength while maintaining the original pitch.
If tempo=200, the audio will play twice (200%) as fast; if tempo=50, the audio will play half (50%) as fast.
float  rate = 100.0
Changes speed and clip.AudioLength while allowing pitch to rise or fall.
Adjusting rate is equivalent to adjusting the speed of a record player or tape recorder.
If rate=200, the audio will play twice (200%) as fast; if rate=50, the audio will play half (50%) as fast.
By the way, the following script:
TimeStretch(rate=105)
is equivalent to
ar=AudioRate 
AssumeSampleRate(Round(ar*1.05))
ResampleAudio(ar)
float  pitch = 100.0
Changes pitch while maintaining the length of the original sample: clip.AudioLength is not changed.
(within a small tolerance – see Notes below)
Tempo, rate and pitch can all be adjusted independently, in which case their effects are added together.
 Advanced Parameters
The time-stretch algorithm has a few parameters that can be tuned to optimize sound quality for certain applications. The current default parameters have been chosen by iterative if-then analysis (read: "trial and error") to obtain the best subjective sound quality in pop/rock music processing, but in applications processing different kind of sound the default parameter set may return a sub-optimal result.
int  sequence = 82 *
This is the length of a single processing sequence in milliseconds, which determines how the original sound is chopped in the time-stretch algorithm. Larger values mean fewer, and longer, sequences are used. In general,
  • a larger sequence value sounds better with a lower tempo and/or pitch;
  • a smaller sequence value sounds better with a higher tempo and/or pitch.
int  seekwindow = 28 *
The length in milliseconds for the algorithm that searches for the best possible overlap location. For larger seekwindow values, the possibility of finding a better mixing position increases, but too-large seekwindow values may cause a "drifting" sound (a disturbing artifact where what should be steady frequencies – such as piano notes – seem to drifting around) because neighboring sequences may be chosen at more uneven intervals.
int  overlap = 12 *
The overlap length in milliseconds. When the sound sequences are mixed back together to form a continuous sound stream again, overlap defines how much of the ends of the consecutive sequences will be overlapped. This shouldn't be a critical parameter. If you reduce the sequence by a large amount, you might wish to try a smaller overlap.
bool  quickseek = true? *
The time-stretch routine has a 'quick' mode that substantially speeds up the algorithm but may degrade the sound quality.
int  aa = ? *
Controls the number of taps the anti-alias filter uses. Set to 0 to disable the filter. Must be a multiple of 4.
* TODO ( default values are under investigation at the time of updating this documentation )


This table summarizes how these parameters can be adjusted for different applications:
Parameter Default value If larger... If smaller... Music Speech CPU burden
sequence Relatively large, chosen for slowing music tempo. Usually better for slowing tempo. You might need less overlap. Accelerates "echoing" artifact when slowing down the tempo. Default value usually good. A smaller value might be better. Smaller value increases CPU burden.
seekwindow  Relatively large, chosen for slowing music tempo. Eases finding a good mixing position, but may cause "drifting" artifact. Makes finding a good mixing position more difficult. Default usually good, unless "drifting" is a problem. Default usually good. Larger value increases CPU burden.
overlap Relatively large, chosen to suit above parameters. Larger value increases CPU burden.


Notes

  • This is NOT a sample exact plugin. If you use it, slight inaccuracies might occur.[clarification needed] Since we are dealing with float values rounding errors might occur, especially on large samples. In general however inaccuracies should not exceed a few 10's of milliseconds for movielength samples.
  • TODO (this statement was unclear at the time of updating this documentation)

Examples

  • Raise pitch one octave, while preserving the length of the original sample.
TimeStretch(pitch=200) 
  • Raise pitch one semi-tone, while preserving the length of the original sample.
## (pitch changes 
TimeStretch(pitch=100.0*pow(2.0, 1.0/12.0)) 
  • Change playback tempo from NTSC Film speed (23.97 fps) to PAL speed (25 fps) without changing pitch.
TimeStretch(tempo=100.0*25.0/(24000.0/1001.0))

Credits

This function uses SoundTouch Audio Processing Library
Copyright © Olli Parviainen
surina.net/soundtouch

Changelog

v2.61 Updated SoundTouch library to 1.9.0. Fixes multichannel issues.
v2.57 Expose soundtouch parameters
v2.55 Initial Release (based on SoundTouch library 1.4.0?)
Personal tools