# synthesize a sound with gradually increasing hissing noise
sound = soundgen(sylLen = 200, temperature = 0.001,
noise = list(time = c(0, 350), value = c(-40, 0)),
formantsNoise = list(f1 = list(freq = 5000, width = 10000)),
addSilence = 25)
# playme(sound, samplingRate = 16000)
# auditory spectrogram
as = audSpectrogram(sound, samplingRate = 16000, nFilters = 48)
dim(as$audSpec)
# compare to FFT-based spectrogram with similar time and frequency resolution
fs = spectrogram(sound, samplingRate = 16000, yScale = 'bark',
windowLength = 5, step = 1)
dim(fs)
if (FALSE) {
# add bells and whistles
audSpectrogram(sound, samplingRate = 16000,
filterType = 'butterworth',
nFilters = 128,
yScale = 'ERB',
bandwidth = 1/6,
dynamicRange = 150,
osc = 'dB', # plot oscillogram in dB
heights = c(2, 1), # spectro/osc height ratio
contrast = .4, # increase contrast
brightness = -.2, # reduce brightness
# colorTheme = 'heat.colors', # pick color theme...
col = hcl.colors(100, palette = 'Plasma'), # ...or specify the colors
cex.lab = .75, cex.axis = .75, # text size and other base graphics pars
grid = 5, # to customize, add manually with graphics::grid()
ylim = c(0.05, 8), # always in kHz
main = 'My auditory spectrogram' # title
# + axis labels, etc
)
# NB: frequency resolution is controlled by both nFilters and bandwidth
audSpectrogram(sound, 16000, nFilters = 15, bandwidth = 1/2)
audSpectrogram(sound, 16000, nFilters = 15, bandwidth = 1/10)
audSpectrogram(sound, 16000, nFilters = 100, bandwidth = 1/2)
audSpectrogram(sound, 16000, nFilters = 100, bandwidth = 1/10)
audSpectrogram(sound, 16000, nFilters_oct = 5, bandwidth = 1/10)
# remove the oscillogram
audSpectrogram(sound, samplingRate = 16000, osc = 'none')
# save auditory spectrograms of all audio files in a folder
audSpectrogram('~/Downloads/temp',
savePlots = '~/Downloads/temp/audSpec', cores = 4)
}
Run the code above in your browser using DataLab