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

prepComb

Preparing the combination/concatenation of Wave or WaveMC objects


Description

Preparing objects of class Wave or class WaveMC for binding/combination/concatenation by removing small amounts at the beginning/end of the Wave or WaveMC in order to make the transition smooth by avoiding clicks.

Usage

prepComb(object, zero = 0, where = c("both", "start", "end"))

Arguments

object

Object of class Wave or class WaveMC.

zero

The zero level (default: 0) at which ideal cut points are determined (see Details). A typical alternative would be 127 for 8 bit Wave or WaveMC objects. If zero = NA, the mean of the left Wave channel (for a Wave object) or the mean of the first channel (for a WaveMC object) is taken as zero level.

where

One of "both" (default), "start", or "end" indicating at where to prepare the Wave or WaveMC object for concatenation.

Details

This function is useful to prepare objects of class Wave or class WaveMC for binding/combination/concatenation. At the side(s) indicated by where small amounts of the Wave or WaveMC are removed in order to make the transition between two Waves or WaveMCs smooth (avoiding clicks).

This is done by dropping all values at the beginning of a Wave or WaveMC before the first positive point after the zero level is crossed from negative to positive. Analogously, at the end of a Wave or WaveMC all points are cut after the last negative value before the last zero level crossing from negative to positive.

Value

An object of class Wave or class WaveMC.

Note

If stereo (for Wave), only the left channel is analyzed while the right channel will simply be cut at the same locations. If multi channel (for WaveMC), only the first channel is analyzed while all other channels will simply be cut at the same locations.

Author(s)

Uwe Ligges ligges@statistik.tu-dortmund.de, Sarah Schnackenberg, based on code from Matthias Heymann's former package ‘sound’.

See Also

Examples

Wobj1 <- sine(440, duration = 520)
Wobj2 <- extractWave(sine(330, duration = 500), from = 110, to = 500)
par(mfrow = c(2,1))
plot(bind(Wobj1, Wobj2), xunit = "samples")
abline(v = 520, col = "red")  # here is a "click"!

# now remove the "click" by deleting a minimal amount of information:
Wobj1 <- prepComb(Wobj1, where = "end")
Wobj2 <- prepComb(Wobj2, where = "start")
plot(bind(Wobj1, Wobj2), xunit = "samples")

tuneR

Analysis of Music and Speech

v1.3.3
GPL-2 | GPL-3
Authors
Uwe Ligges <ligges@statistik.tu-dortmund.de> with contributions from Sebastian Krey, Olaf Mersmann, Sarah Schnackenberg, Guillaume Guenard, Andrea Preusser, Anita Thieler, Johanna Mielke and Claus Weihs, as well as code fragments and ideas from the former package 'sound' by Matthias Heymann and functions from 'rastamat' by Daniel P. W. Ellis. The included parts of the libmad MPEG audio decoder library are authored by Underbit Technologies.
Initial release
2018-07-03

We don't support your browser anymore

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