resample | R Documentation |
Resample using sinc interpolation.#'
resample(sound, newfs, oldfs, precision = 50, filterorder = 6, n_passes = 4)
sound |
Either a numeric vector representing a sequence of samples taken from a sound wave or a sound object created with the loadsound() or makesound() functions. |
newfs |
The new desired sampling frequency. |
oldfs |
The original sampling frequency. If a 'sound' object is provided, this does not need to be specified. |
precision |
The number of samples before and after the current point to be used for interpolation. |
filterorder |
The number of taps to be used for the low-pass Butterworth filters used, where appropriate. |
n_passes |
The number of passes through the low pass filter. |
The resampled vector is returned. If a 'sound' object is passed, the resampled sound is returned as an object.
Santiago Barreda <sbarreda@ucdavis.edu>
## Not run:
data (sound)
# downsample and then upsample the sound back to
# its original sampling frequency
downsamped = resample (sound, 11025)
upsamped = resample (downsamped, 22050)
# compare a part of the waveforms for all three sounds
par (mfcol = c(3,2), mar = c(4,4,1,1))
plot (sound$sound[1:14000], type = 'l')
plot (downsamped$sound[1:7000], type = 'l', col = 4)
plot (upsamped$sound[1:14000], type = 'l', col = 2)
phonTools::spectralslice(sound, xlim = c(0,11025),ylim=c(-90,5))
phonTools::spectralslice(downsamped, xlim = c(0,11025),ylim=c(-90,5),col=4)
phonTools::spectralslice(upsamped, xlim = c(0,11025),ylim=c(-90,5),col=2)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.