Resample
korvax.resample
resample(
x,
/,
orig_sr,
target_sr,
lowpass_filter_width=6,
rolloff=0.99,
resampling_method="sinc_interp_hann",
beta=None,
scale=False,
)
Resample a waveform using sinc interpolation.
This function is a JAX port of torchaudio.resample.
When jitted, it is just as fast as soxr (HQ) on CPU,
but the JAX implementation is also fully differentiable and works on GPU/TPU.
Note: Unlike the rest of korvax, this function requires sampling rates to be specified as integers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Float[Array, '*channels old_n_samples']
|
The input signal of dimension |
required |
orig_sr
|
int
|
The original frequency of the signal. |
required |
target_sr
|
int
|
The desired frequency. |
required |
lowpass_filter_width
|
int
|
Controls the sharpness of the filter.
A larger value gives a sharper filter but is less efficient. Defaults to |
6
|
rolloff
|
float
|
The roll-off frequency of the filter as a
fraction of the Nyquist frequency. Lower values reduce aliasing but
also attenuate high frequencies. Defaults to |
0.99
|
resampling_method
|
str
|
The windowing function to use.
Options: [ |
'sinc_interp_hann'
|
beta
|
float | None
|
The shape parameter for the Kaiser window.
Only used if |
None
|
Returns:
| Type | Description |
|---|---|
Float[Array, '*channels new_n_samples']
|
The waveform at the new frequency. The new shape is |
Source code in src/korvax/_resample.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |