Learn R Programming

seewave (version 1.7.0)

synth: Synthesis of time wave (additive model)

Description

This functions synthesizes pure tone sound with amplitude modulation (am) and/or frequency modulation (fm).

Usage

synth(f, d, cf, a = 1, shape = NULL, p = 0,
am = c(0, 0), fm = c(0, 0, 0),
plot = FALSE, listen = FALSE, output = "matrix",...)

Arguments

Value

  • If plot is FALSE, a new wave is returned. The class of the returned object is set with the argument output.

Details

shape allows to modify the whole amplitude shape of the wave. There are four options to be given as as character string: (i) "incr" : linear increase (ii) "decr" : linear decrease (iii) "sine" : sinusoid-like shape (iv) "tria" : triangular shape

am is a vector of length 2 including: (1) the amplitude modulation depth (in %), (2) the frequency of the amplitude modulation. fm is a vector of length 3 including: (1) the maximum excursion of a sinusoidal frequency modulation (in Hz), (2) the frequency of a sinusoidal frequency modulation, (3) the maximum excursion of a linear frequency modulation (in Hz).

References

Hartmann, W. M. 1998 Signals, sound and sensation. New York: Springer.

See Also

synth2, noisew, pulse, echo

Examples

Run this code
# pure tone
synth(f=22050,d=1,cf=4000,plot=TRUE)
# pure tone with sinusoid-like overall shape
synth(f=22050,d=1,cf=4000,shape="sine",plot=TRUE,osc=TRUE)
# pure tones with am
synth(f=22050,d=1,cf=4000,am=c(50,10),plot=TRUE,osc=TRUE)
# pure tone with +2000 Hz linear fm 
synth(f=22050,d=1,cf=4000,fm=c(0,0,2000),plot=TRUE)
# pure tone with sinusoidal fm
# (maximum excursion of 1000 Hz, frequency of 10 Hz)
synth(f=22050,d=1,cf=4000,fm=c(1000,10,0),plot=TRUE,wl=256,ovlp=75)
# pure tone with sinusoidal am
# (maximum excursion of 1000 Hz, frequency of 10 Hz)
# and linear fm (maximum excursion of 1000 Hz)
synth(f=22050,d=1,cf=4000,fm=c(1000,10,1000),plot=TRUE,wl=256,ovlp=75)
# the same with am
synth(f=22050,d=1,cf=4000,am=c(50,10),
    fm=c(1000,10,1000),plot=TRUE,wl=256,ovlp=75,osc=TRUE)
# the same with am and a triangular overall shape 
synth(f=22050,d=1,cf=4000,shape="tria",am=c(50,10),
    fm=c(1000,10,1000),plot=TRUE,wl=256,ovlp=75,osc=TRUE)   
# more complex sound
F1<-synth(f=22050,cf=2000,d=1,fm=c(500,5,0))
F2<-synth(f=22050,a=0.8,cf=4000,d=1,fm=c(500,5,0))
F3<-synth(f=22050,a=0.6,cf=6000,d=1,fm=c(500,5,0))
F4<-synth(f=22050,a=0.4,cf=8000,d=1,fm=c(500,5,0))
final1<-F1+F2+F3+F4
spectro(final1,f=22050,wl=512,ovlp=75,scale=FALSE)

Run the code above in your browser using DataLab