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

smoothw

A function to tentativily smooth a time wave


Description

This function tries to smooth with a sum sliding window a time wave, and then to remove residual noise.

Usage

smoothw(wave, f, channel = 1, wl, padding=TRUE, output = "matrix")

Arguments

wave

an R object.

f

sampling frequency of wave (in Hz). Does not need to be specified if embedded in wave.

channel

channel of the R object, by default left channel (1).

wl

window length in number of points (samples).

padding

a logical, if TRUE add 0 values at the start and end of the file to match wave length (duration).

output

character string, the class of the object to return, either "matrix", "Wave", "Sample", "audioSample" or "ts".

Details

A window slides along the signal and sums up the sample amplitude values. Zero values are added at the end of the wave to keep wave length (duration).

Value

A new wave is returned. The class of the returned object is set with the argument output. If padding is TRUE, the new wave starts and ends up with 0 values to match the size of wave.

Warning

This function should be used with care as this kind of filter may change the frequency content of the sound. See the examples section for an illustration.

Author(s)

Jerome Sueur

See Also

Examples

# An example to show that smoothw() may change
# the frequency content of your sound
data(orni)
orni2 <- smoothw(orni, wl=2, out="Wave")
orni10 <- smoothw(orni, wl=10, out="Wave")
orni50 <- smoothw(orni, wl=50, out="Wave")
orni100 <- smoothw(orni, wl=100, out="Wave")
meanspec(orni)
lines(meanspec(orni2, plot=FALSE), col=2)
lines(meanspec(orni10, plot=FALSE), col=3)
lines(meanspec(orni50, plot=FALSE), col=4)
lines(meanspec(orni100, plot=FALSE), col=5)
legend("topright", col=1:5, lty=1, legend=c("original","wl=2","wl=10","wl=50","wl=100"))

seewave

Sound Analysis and Synthesis

v2.1.6
GPL (>= 2)
Authors
Jerome Sueur <sueur@mnhn.fr> [cre, au], Thierry Aubin [au], Caroline Simonis [au], Laurent Lellouch [main ctrb], Ethan C. Brown [ctrb], Marion Depraetere [ctrb], Camille Desjonqueres [ctrb], Francois Fabianek [ctrb], Amandine Gasc [ctrb], Eric Kasten [ctrb], Stefanie LaZerte [ctrb], Jonathan Lees [ctrb], Jean Marchal [ctrb], Andre Mikulec [ctrb], Sandrine Pavoine [ctrb], David Pinaud [ctrb], Alicia Stotz [ctrb], Luis J. Villanueva-Rivera [ctrb], Zev Ross [ctrb], Carl G. Witthoft [ctrb], Hristo Zhivomirov [ctrb].
Initial release
2020-06-28

We don't support your browser anymore

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