Learn R Programming

sequenceR (version 1.0.1)

getSynthNote: Single note from a synthesizer

Description

Creates one note with frequency freq from an additive, Hammond-inspired synth. Higher harmonics decay faster and have smaller sustain.

Usage

getSynthNote(
  freq,
  nHarmonics = 5,
  peak = 0.03,
  decay = 0.8,
  duration = 1,
  sustain = 0.25,
  decayPar = 1,
  sustainPar = 4,
  type = "sine"
)

Value

An object of class 'soundSample'.

Arguments

freq

Numeric, base frequency in Hz

nHarmonics

Integer >=1, number of 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

decayPar

Numeric, the higher the value the smaller the decay time for higher harmonics

sustainPar

Numeric, the higher the value the smaller the sustain volume for higher harmonics

type

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

Examples

Run this code
sam <- getSynthNote(440,nHarmonics=7)
plot(sam)
if (FALSE) {
# 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)}

Run the code above in your browser using DataLab