soundgen readme
R package for sound synthesis and acoustic analysis.
Homepage with help, demos, etc: http://cogsci.se/soundgen.html
Source code on github: https://github.com/tatters/soundgen
Performs parametric synthesis of sounds with harmonic and noise components such as animal vocalizations or human voice. Also includes tools for spectral analysis, pitch tracking, audio segmentation, self-similarity matrices, morphing, etc.
Key functions
- Sound synthesis from R console:
soundgen()
- Shiny app for sound synthesis (opens in a browser):
soungen_app()
- Acoustic analysis of a wav/mp3 file:
analyze()
- Shiny app for editing intonation contours (opens in a browser):
pitch_app()
- Measuring syllables, pauses, and bursts in a wav/mp3 file:
segment()
For more information, please see the vignettes on sound synthesis and acoustic analysis:
vignette("sound_generation", package="soundgen")
vignette("acoustic_analysis", package="soundgen")
Or, to open the vignettes in a browser:RShowDoc('sound_generation', package = 'soundgen')
RShowDoc('acoustic_analysis', package = 'soundgen')
Example of sound synthesis
Use the soundgen()
function to create a breathy moan:
s = soundgen(
sylLen = 230, # duration of voiced part, ms
pitch = c(305, 280), # pitch, Hz (goes down from 305 to 380 Hz)
ampl = c(0, -20), # amplitude, dB (gradual fade-out by 20 dB)
rolloff = -30, # strong f0, weak harmonics
temperature = 0.05, # some stochasticity in generation
formants = c(260, 960, 1500, 2200, # F1-F8 formant frequencies, Hz
2600, 3600, 4200, 4500),
noise = data.frame(
time = c(-50, 120, 700), # time of noise anchors
value = c(-15, -5, -50) # noise amplitude, dB
),
rolloffNoise = 0, # flat noise spectrum before adding formants
addSilence = 0, samplingRate = 44100, pitchSamplingRate = 44100,
play = TRUE, plot = TRUE, osc = TRUE, ylim = c(0, 6)
)
Example of acoustic analysis
Use the analyze()
function to detect pitch and obtain other spectral
descriptives of the sound we have just synthesized:
a = analyze(s, 44100, ylim = c(0, 6))
a$detailed[1:5, c('pitch', 'peakFreq', 'harmHeight', 'HNR', 'ampl', 'loudness')]
#> pitch peakFreq harmHeight HNR ampl loudness
#> 1 NA NA NA NA 0.02638271 NA
#> 2 295.1621 300.1361 296.6386 5.621424 0.15939804 10.50662
#> 3 296.6386 300.1361 593.2772 13.417414 0.36515952 18.01119
#> 4 296.4598 300.1361 1185.8392 13.250932 0.47913904 23.01556
#> 5 292.8389 300.1361 1231.4125 11.141331 0.45389806 22.25239
colnames(a)
#> NULL
Installation
To install the current release from CRAN: install.packages("soundgen")
NB: Make sure all dependencies have been installed correctly! For problems with seewave, see https://rug.mnhn.fr/seewave/
On Macs, you may need to do the following:
- First install brew according to the instructions here: https://brew.sh/
- Then run the following from the terminal
brew install libsndfile
brew install fftw
- Finally, install soundgen in R:
install.packages("soundgen")