# Create an instrument
samples=list(oscillator(freq=110),oscillator(freq=220),oscillator(freq=261.63),
oscillator(freq=293.66),oscillator(freq=392))
notes=c('A2','A3','C4','D4','G4')
onTheMoon <- instrument(samples,notes)
# Play it
w=play.instrument(onTheMoon)
# View the result
tuneR::plot(w)
if (FALSE) {
# This line of code is wrapped in \dontrun{} since it relies
# on an external audio player to play the audio sample.
# See ?tuneR::setWavPlayer for setting a default player.
tuneR::play(w)}
# Use options
w=play.instrument(onTheMoon,time=c(0,0.2,0.4,0.6,0.8,0.9),
notes=c('A2','G4','D4','C4','A3','A2'),
volume=seq(0.2,1,length.out=6),pan=c(0,-1,1,-1,1,0),
fadeout=c(Inf,0.01,0.01,0.01,Inf,Inf))
# View the result
tuneR::plot(w)
if (FALSE) {
# This line of code is wrapped in \dontrun{} since it relies
# on an external audio player to play the audio sample.
# See ?tuneR::setWavPlayer for setting a default player.
tuneR::play(w)}
Run the code above in your browser using DataLab