soundgen (version 1.5.0)

getLoudnessPerFrame: Get loudness per frame

Description

Internal soundgen function

Usage

getLoudnessPerFrame(spec, samplingRate, spreadSpectrum = TRUE)

Arguments

samplingRate

sampling rate of x (only needed if x is a numeric vector, rather than an audio file), must be > 2000 Hz

spreadSpectrum

if TRUE, applies a spreading function to account for frequency masking

Details

Takes as input the absolute (not power) spectrum of a single STFT frame and estimates its loudness in sone. See getLoudness for details.

Examples

Run this code
# NOT RUN {
sound = sin(2*pi*1000/16000*(1:1000))
sound_scaled = soundgen:::scaleSPL(sound, SPL_measured = 40)
spec = spectrogram(
  sound_scaled, samplingRate = 16000, windowLength = 10,
  normalize = FALSE, output = 'original')[, 10]
# plot(spec, type = 'l')
soundgen:::getLoudnessPerFrame(spec, samplingRate = 16000)  # 1 sone
# }

Run the code above in your browser using DataCamp Workspace