Learn R Programming

tuneR (version 0.2-6)

Waveforms: Create Wave Objects of Special Waveforms

Description

Create a Wave object of special waveform such as silcence, (white/pink) noise, sawtooth, sine, and square.

Usage

noise(kind = c("white", "pink"), duration = samp.rate, 
        samp.rate = 44100, bit = 1, stereo = FALSE, 
        xunit = c("samples", "time"), ...)

sawtooth(freq, duration = samp.rate, from = 0, samp.rate = 44100, bit = 1, 
        stereo = FALSE, xunit = c("samples", "time"), reverse = FALSE, ...)

silence(duration = samp.rate, from = 0, samp.rate = 44100, bit = 1, 
        stereo = FALSE, xunit = c("samples", "time"), ...)

sine(freq, duration = samp.rate, from = 0, samp.rate = 44100, bit = 1,
        stereo = FALSE, xunit = c("samples", "time"), ...)

square(freq, duration = samp.rate, from = 0, samp.rate = 44100, bit = 1, 
        stereo = FALSE, xunit = c("samples", "time"), up = 0.5, ...)

Arguments

kind
The kind of noise, either white or pink (the latter is not dB adjusted (!) but linear decreasing on a log-log scale).
freq
The frequency (in Hertz) to be generated.
duration
Duration of the Wave in xunit.
from
Starting value of the Wave in xunit.
samp.rate
Sampling rate of the Wave.
bit
Resolution of the Wave and rescaling unit. This may be 1 (default) for rescaling to real values in [-1,1], 8 (i.e. 8-bit) for rescaling to integers in [0, 254], 16 (i.e. 16-bit) for rescaling to integers
stereo
Logical, if TRUE, a stereo sample will be generated. The right channel is identical to the left one for sawtooth, silence, sine, and square. For noise, both channel ar
xunit
Character indicating which units are used (both in arguments duration and from). If xunit = "time", the unit is time in seconds, otherwise the number of samples.
reverse
Logical, if TRUE, the waveform will be mirrored vertically.
up
A number between 0 and 1 giving the percentage of the waveform at max value (= 1 - percentage of min value).
...
Further arguments to be passed to Wave through the internal function postWaveform.

Value

concept

  • Wave
  • sound
  • waveform
  • silcence
  • sample

See Also

Wave, normalize, noSilence

Examples

Run this code
Wobj <- sine(440, bit = 16, duration = 1000)
Wobj2 <- noise(bit = 16, duration = 1000)
plot(Wobj)
plot(Wobj2)

Run the code above in your browser using DataLab