soundgen (version 1.5.0)

scaleSPL: Scale SPL

Description

Internal soundgen function

Usage

scaleSPL(x, scale = NULL, SPL_measured = 70, Pref = 2e-05)

Arguments

x

numeric vector ranging from -1 to +1

scale

the maximum possible value of x (only needed if x is a numeric vector, rather than an audio file); defaults to observed max(abs(x)) if it is greater than 1 and to 1 otherwise

SPL_measured

sound pressure level at which the sound is presented, dB

Pref

reference pressure, Pa

Details

Converts a sound from SPL on any scale to a desired level of dB SPL. See Timoney et al. (2004) "Implementing loudness models in MATLAB"

Examples

Run this code
# NOT RUN {
sound = rnorm(100) * getSmoothContour(c(0, 1, 0), len = 100)
sound = sound / max(abs(sound))
# plot(sound, type = 'l')
sound_scaled = soundgen:::scaleSPL(sound)
# plot(sound_scaled, type = 'l')

sound2 = sound / 3
range(soundgen:::scaleSPL(sound2, scale = NULL))
range(soundgen:::scaleSPL(sound2, scale = 1))
# }

Run the code above in your browser using DataLab