| sox | R Documentation |
This function calls SoX, the Swiss Army knife of sound processing programs.
sox(command, exename = NULL, path2exe = NULL, option = NULL,
shQuote_type = NULL)
command |
the SoX command to invoke. |
exename |
a character string specifying the name of the SoX binary file. If |
path2exe |
a character string giving the path to the SoX binary file |
g
option |
option to be passed to the SoX command |
shQuote_type |
type of shell quotes ("cmd" or "cmd2", for Windows OS; "sh" or "csh" Unix OS) |
See the documentation of SoX for proper use.
Sox must be installed to use this function but not to install the
package seewave. As mentioned on the SoX webpage, the primary development
platform is Linux. Using SoX with Windows from R might not be
straightforward. In particular, it is advisable to pay attention to file path and exe name.
Jerome Sueur, Stefanie LaZerte, Andre Mikulec
https://en.wikipedia.org/wiki/SoX
## Not run:
##########
## data ##
##########
## Generate a simple sound file at 440 Hz
s <- synth(cf=440, f=8000, d=1, fm=c(0,0,1000,0,0), output="Wave")
savewav(s, file="mysound.wav")
##############
## Linux OS ##
##############
## Play the file
sox("mysound.wav", exename="play")
## Slow down the audio tempo (but not its pitch)
sox("mysound.wav myslowsound.wav tempo 0.5")
## Cut the file
sox("myslowsound.wav myslowcutsound.wav trim 0.25 0.75")
################
## Windows OS ##
################
## path with simple slash
path <- "C:/Program Files (x86)/sox-14-4-2"
## or path with double backslash
## path <- "C:\Program Files (x86)\sox-14-4-2"
sox("mysound.wav", path2exe=path, option="-t waveaudio")
## with the option directly passed to the command
sox("mysound.wav -t waveaudio", path2exe=path)
## Slow down the audio tempo (but not its pitch)
sox("mysound.wav myslowsound.wav tempo 0.5", path2exe=path)
## Cut the file
sox("myslowsound.wav myslowcutsound.wav trim 0.25 0.75", path2exe=path)
###########
## clean ##
###########
file.remove("mysound.wav", "myslowsound.wav", "myslowcutsound.wav")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.