# NOT RUN {
# 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)
# }
# NOT RUN {
# add bells and whistles
audSpectrogram(sound, samplingRate = 16000,
yScale = 'log',
osc = 'dB', # plot oscillogram in dB
heights = c(2, 1), # spectro/osc height ratio
brightness = -.1, # reduce brightness
colorTheme = 'heat.colors', # pick color theme
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.1, 5), # always in kHz
main = 'My auditory spectrogram' # title
# + axis labels, etc
)
# change dynamic range
audSpectrogram(sound, samplingRate = 16000, dynamicRange = 40)
audSpectrogram(sound, samplingRate = 16000, dynamicRange = 120)
# 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')
# }
Run the code above in your browser using DataLab