Learn R Programming

seewave (version 2.1.8)

pastew: Paste a time wave to another one

Description

This function pastes a first time wave to a second one. The time wave to be pasted, the time wave to be completed and the resulting time wave can be displayed in a three-frame oscillographic plot.

Usage

pastew(wave1, wave2, f, channel = c(1,1), at = "end",
join = FALSE, tjunction = 0,
choose = FALSE, plot = FALSE,
marks = TRUE, output = "matrix", ...)

Arguments

wave1

a first R object.

wave2

a second R object.

f

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

channel

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

at

wave2 position in seconds where wave1 will be pasted into. Can be also specified as "start", "middle" or "end".

join

if TRUE the two waves will be pasted and jointed by removing the last point of wave2. See examples.

tjunction

a numeric vector to remove clicks at the junction of <U+2018>wave1<U+2019> and <U+2018>wave2<U+2019>. The value specifies the duration in seconds where the real vales will be replaced by a linear interpolation. This duration should be a few milliseconds.

choose

logical, if TRUE the point where wave1 will be pasted into wave2 (=at) can be graphically chosen with a cursor.

plot

logical, if TRUE returns an oscillographic plot of wave1, wave2 and wave1 + wave2 (by default FALSE).

marks

logical, if TRUE shows where wave1 has been pasted (by default TRUE).

output

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

other oscillo graphical parameters.

Value

If plot is FALSE, a new wave is returned. The class of the returned object is set with the argument output.

Details

If plot is TRUE returns a two-frame plot with three waves: (1) the wave to be pasted (wave1), (2) the wave to be completed (wave2), (3) the resulting wave.

See Also

oscillo, addsilw, cutw, deletew, fadew, mutew , revw, repw, timelapse , zapsilw

Examples

Run this code
# NOT RUN {
data(tico)
# double a data set describing a bird song
a<-pastew(tico,tico,f=22050)
oscillo(a,f=22050)
# a direct way to see what has been pasted
pastew(tico,tico,f=22050,plot=TRUE)
# cut a section and then paste it at the beginning
a<-cutw(tico, f=22050, from=0.5, to=0.9)
pastew(a,tico,f=22050,at="start",plot=TRUE)
# or paste it at a specific location
pastew(a,tico,f=22050,at=1.4,plot=TRUE)
# setting the argument 'join' to TRUE might be useful
# to smooth pasting when some phase problem occur
# generate two sine waves
a <- synth(cf=50, f=400, d=0.1)
b <- synth(cf=100, f=400, d=0.1)
# paste it with 'join' turned to FALSE
# there is a click at the junction between the two waves
pastew(a, b, f=400, plot=TRUE)
# that can be removed by setting 'join' to TRUE
pastew(a, b, f=400, join=TRUE, plot=TRUE)
# or by using the argument 'tjunction'
pastew(a, b, f=400, tjunction=0.01, plot=TRUE)
# }

Run the code above in your browser using DataLab