sinetone {gsignal}R Documentation

Sine tone

Description

Generate discrete sine tone.

Usage

sinetone(freq, rate = 8000, sec = 1, ampl = 64)

Arguments

freq

frequency of the tone, specified as a vector of positive numeric values. The length of freq should equal the length of the ampl vector; the shorter of the two is recycled to the longer vector.

rate

sampling frequency, specified as a positive scalar. Default: 8000.

sec

length of the generated tone in seconds. Default: 1

ampl

amplitude of the tone, specified as a vector of positive numeric values. The length of ampl should equal the length of the freq vector; the shorter of the two is recycled to the longer vector. Default: 64.

Value

Sine tone, returned as a vector of length rate * sec, or as a matrix with rate * sec columns and max(length(freq), length(ampl)) columns.

Author(s)

Friedrich Leisch.
Conversion to R by Geert van Boxtel, G.J.M.vanBoxtel@gmail.com.

Examples

fs <- 1000
sec <- 2
y <- sinetone(10, fs, sec, 1)
plot(seq(0, sec, length.out = sec * fs), y, type = "l", xlab = "", ylab = "")

y <- sinetone(c(10, 15), fs, sec, c(1, 2))
matplot(seq(0, sec, length.out = sec * fs), y, type = "l",
        xlab = "", ylab = "")


[Package gsignal version 0.3-5 Index]