getSharpness: Get sharpness

View source: R/loudness_utilities.R

getSharpnessR Documentation

Get sharpness

Description

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.

Usage

getSharpness(
  specSone,
  method = c("aures", "DIN45692", "bismarck"),
  loudness = NULL,
  bark = NULL,
  barkWidth = NULL
)

Arguments

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 colSums(specSone * barkWidth). If NULL, it is calculated internally.

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.

Value

A numeric vector of sharpness values in acum, one per STFT frame.

Examples

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')

soundgen documentation built on Sept. 20, 2026, 5:07 p.m.