Learn R Programming

soundgen (version 2.0.0)

downsample: Simple downsampling

Description

Internal soundgen function

Usage

downsample(s, srNew = 10, srOld = 120, minLen = 3)

Arguments

s

a numeric vector

srNew

the new, required sampling rate

srOld

the original sampling rate

minLen

the minimum length of returned vector

Details

Takes a numeric vector and downsamples it to the required sampling rate by applying a low-pass filter and then decimating. If the new sampling rate is higher than the original, it does nothing.

Examples

Run this code
# NOT RUN {
s = rnorm(100); plot(s, type = 'l')
s1 = soundgen:::downsample(s, srNew = 5, srOld = 18)
plot(s1, type = 'l', col = 'red')
plot(soundgen:::downsample(s, srNew = 5, srOld = 40), type = 'b')
# }

Run the code above in your browser using DataLab