sinetone function

Sine tone

Sine tone

Generate discrete sine tone.

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.

Returns

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.

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 = "")

Author(s)

Friedrich Leisch.

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

  • Maintainer: Geert van Boxtel
  • License: GPL-3
  • Last published: 2024-09-11