Ops.Sample {sound} | R Documentation |
Basic Operations for Sample Objects
Description
These functions apply the basic operations pointwise to the waveforms of the samples.
Usage
e1 + e2
## S3 method for class 'Sample'
Ops(e1,e2)
e1 - e2
## S3 method for class 'Sample'
sum(e1, e2, ...)
## S3 method for class 'Sample'
prod(e1, e2, ...)
Arguments
e1 , e2 , ... |
For |
Details
The sum of two Sample objects corresponds to the sound when both samples are played at a time. The product of two samples causes an effect called ringmodulation, but it can also be used to add some vibrato to a sound (see the examples).
If the samples have different sample parameters (bits, rate and channels), the system uses the command fitSampleParameters
to adjust them before the waveforms are combined.
Be careful to make sure that the resulting waveform does not exceed the interval [-1,1] when it is played or saved to disk, otherwise you will lose information and hear cracks in the sound. To avoid this, you can use const * s
or the normalize
command.
In prod
and sum
also the names of wavefiles can be used. Other forms like e1+e2
do not accept filenames as arguments. If the first argument e1
is a filename, the explicit forms sum.Sample
and prod.Sample
must be used.
Value
a Sample object.
Author(s)
Author: Matthias Heymann [aut], Stefan Langenberg [cre] (<https://orcid.org/0000-0001-5817-5469>)
Maintainer: Stefan Langenberg <langenberg@uni-bonn.de>
See Also
Examples
## Not run:
const <- 2.0
e1 <- Sine(440,1)
e2 <- Sine(220,1)
play((e1+e2)/2) # both samples at a time
play(Sine(440,1)*Sine(5,1)) # vibrato
e1 * e2
const * e1
e1 * const
e2 / const
## End(Not run)