Changing the sampling rate of an audio clip

### 28.2.11 Changing the sampling rate of an audio clip

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 r=44100).
  - Optionally, n, an integer specifying the quality level, from 0 (poor) to 4 (best) (by default, n=2).
- resample(A ⟨,r,n⟩) returns the audio clip A resampled to rate r.
- Xcas does resampling by using the libsamplerate library. 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:

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

44100 |  |  |  |  |  |  |  |  |  |

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

48000 |  |  |  |  |  |  |  |  |  |