ResampleAudio

From Avisynth wiki
Revision as of 22:05, 29 March 2006 by Wilbert (Talk)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

ResampleAudio(clip, int new_rate_numerator [, int new_rate_denominator])

ResampleAudio performs a high-quality change of audio sample rate. The conversion is skipped if the samplerate is already at the given rate.

When using fractional resampling the output audio samplerate is given by :

int(new_rate_numerator / new_rate_denominator + 0.5)

However the internally the resampling factor used is :

new_rate_numerator / (new_rate_denominator * old_sample_rate)

This causes the audio duration to vary slightly (which is generally what is desired).

Starting from v2.53 ResampleAudio accepts any number of channels. Starting from v2.56 ResampleAudio process float samples directly. Support fractional resampling.

# Resamples audio to 48 kHz:
source = AviSource("c:\audio.wav")
return ResampleAudio(source, 48000)


# Exact 4% speed up for PAL telecine:
Nfr_num = 25
Nfr_den = 1
AviSource("C:\Film.avi") # 23.976 fps, 44100Hz
Ar = Audiorate()
ResampleAudio(Ar*FramerateNumerator()*Nfr_den, FramerateDenominator()*Nfr_num)
AssumeSampleRate(Ar)
AssumeFPS(Nfr_num, Nfr_den, False)

For exact resampling the intermediate samplerate needs to be 42293.706293 which if rounded to 42294 would causes about 30ms per hour variation.

Changes:

v2.56 Added new_sample_rate=float.
Personal tools