15.1.8 Changing the sampling rate: resample
The resample command resamples a clip to a desired rate.
-
resample takes one mandatory argument and two
optional arguments:
-
A, an audio clip.
- Optionally, r, the target sample rate in Hz (by default
44100).
- Optionally, n, an integer specifying the quality level,
from 0 (poor) to 4 (best) (by default, 2).
- resample(A ⟨ r,n⟩)
returns the audio clip A resampled to rate r.
Giac does resampling by using the libsamplerate library
http://www.mega-nerd.com/libsamplerate/
written by Erik de Castro Lopo. For more information see the
library documentation.
Example.
Assuming that the directory sounds contains example.wav, a
wav file with a sample rate of 44100:
Input:
clip:=readwav("/path/to/sounds/example.wav"):; samplerate(clip)
Output:
44100
Input:
res:=resample(clip,48000):; samplerate(res)
Output:
48000