View source: R/loudness_utilities.R
| getSharpness | R Documentation |
Takes a sone-spectrogram and calculates the sharpness of each frame as the first moment of specific loudness on the Bark scale:
S = 0.11 * \frac{\int z * g(z) * N'(z) dz}{\int N'(z) dz}
By default, it is assumed that each row corresponds to 1 Bark. If rows are
spaced differently (e.g. an auditory filter bank), supply bark and
barkWidth.
getSharpness(
specSone,
method = c("aures", "DIN45692", "bismarck"),
loudness = NULL,
bark = NULL,
barkWidth = NULL
)
specSone |
a matrix of specific loudness per bin and STFT frame created by .getLoudness: time in columns and specific loudness (sones per bark) in rows |
method |
the method of calculating sharpness (mostly differ in weighting functions; only "aures" uses level-dependent weights) |
loudness |
optional total loudness per frame, usually
|
bark |
optional numeric vector of critical-band centers in Bark. If NULL, defaults to 1:nrow(specSone). |
barkWidth |
optional numeric vector of critical-band widths in Bark. If NULL, defaults to 1 for each row. |
A numeric vector of sharpness values in acum, one per STFT frame.
s1 = cos(2*pi*1000*(1:8000)/16000)
l1 = getLoudness(s1, 16000, SPL_measured = 60, sharpnessMethod = 'aures')
# image(t(l1$detailed$specSone))
l1$detailed$sharpness
soundgen:::getSharpness(l1$detailed$specSone, method = 'aures') # same
s2 = soundgen()
l2 = getLoudness(s2, 16000, SPL_measured = 60, sharpnessMethod = 'aures')
# image(t(l2$detailed$specSone))
plot(l2$detailed$sharpness, type = 'b', ylim = c(0, 5))
points(soundgen:::getSharpness(l2$detailed$specSone, method = 'DIN45692'),
type = 'l', col = 'blue')
points(soundgen:::getSharpness(l2$detailed$specSone, method = 'bismarck'),
type = 'l', col = 'green')
points(soundgen:::getSharpness(l2$detailed$specSone, method = 'aures'),
type = 'l', col = 'orange')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.