getHarmonics: Harmonics sound sample

View source: R/synthesizers.R

getHarmonicsR Documentation

Harmonics sound sample

Description

Creates a sound sample corresponding to the kth harmonics of a given frequency

Usage

getHarmonics(
  freq,
  k,
  peak = 0.03,
  decay = 0.8,
  duration = 1,
  sustain = 0.25,
  type = "sine"
)

Arguments

freq

Numeric, base frequency in Hz

k

Integer >=1, kth harmonics

peak

Numeric, peak time in seconds

decay

Numeric, end-of-decay time in seconds

duration

Numeric, total duration in seconds

sustain

Numeric, sustain volume

type

String, oscillator type, one of 'sine', 'saw', 'square' or 'triangle'. If an unknowm string is provided, a sine oscillator will be used.

Value

An object of class 'soundSample'.

Examples

sam1 <- getHarmonics(440,1)
plot(sam1)
sam2 <- getHarmonics(440,3)
plot(sam2)
## Not run: 
# This line of code is wrapped in \dontrun{} since it relies
# on an external audio player to listen to the audio sample.
# See ?tuneR::setWavPlayer for setting a default player.
listen(sam2)
## End(Not run)

benRenard/sequenceR documentation built on Jan. 11, 2025, 2:33 a.m.