Previous Up Next

5.24.8  Changing the sampling rate : resample

resample takes an audio clip as its first argument. The target sample rate can be passed as the second argument (by default 44100 Hz), optionally followed by a quality level specification (an integer). The return value is the input audio clip resampled to the desired rate. The quality level can range from 0 (poor) to 4 (best). By default, it is set to 2.

Giac does resampling by using libsamplerate library written by Erik de Castro Lopo. For more information see the library documentation.

For example, assume that the directory sounds contains a WAV file example.wav. Input :

clip:=readwav("/path/to/sounds/example.wav"):; samplerate(clip)

Output :

44100

Input :

res:=resample(clip,48000):; samplerate(res)

Output :

48000

Previous Up Next