Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

resample

Resample data


Description

Resample numeric data to a different rate.

Usage

resample(x, source.rate, target.rate, ...)

Arguments

x

A numeric vector that needs to be resampled.

source.rate

The rate at which x was sampled in Hz (or another unit, as long as it is in the same unit as target.rate).

target.rate

The desired target sampling rate in Hz (or another unit, as long as it is in the same unit as source.rate).

...

Arguments passed on to approx. To simulate the Commodore Amiga hardware, it's best to use 'method = "constant" for resampling 8 bit samples.

Details

This function resamples numeric data (i.e., audio data) from a source sample rate to a target sample rate. At the core it uses the approx function.

Value

Returns a resampled numeric vector of length round(length(x) * target.rate / source.rate) based on x.

Author(s)

Pepijn de Vries

Examples

some.data <- 1:100

## assume that the current (sample) rate
## of 'some.data' is 100, and we want to
## resample this data to a rate of 200:
resamp.data <- resample(some.data, 100, 200, method = "constant")

ProTrackR

Manipulate and Play 'ProTracker' Modules

v0.3.7
GPL-3
Authors
Pepijn de Vries [aut, cre, dtc]
Initial release
2020-02-03

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.