oscillator: General oscillator

View source: R/oscillators.R

oscillatorR Documentation

General oscillator

Description

Creates a soundSample using a oscillator.

Usage

oscillator(type = "sine", freq = 440, duration = 1, phase = 0, rate = 44100)

Arguments

type

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

freq

Numeric, note frequency in Hz

duration

Numeric, note duration in second

phase

Numeric, phase in radians (typically between 0 and 2*pi)

rate

Numeric, sampling rate in Hz

Value

An object of class 'soundSample'.

Examples

sam <- oscillator(type='saw',freq=220,duration=0.1)
plot(sam)
## 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(sam)
## End(Not run)

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