View source: R/modulationSpectrum_utilities.R
| specToMS | R Documentation |
specToMS() takes a spectrogram (complex or magnitude) and returns its
2D Fourier transform - the modulation spectrum (MS). msToSpec() is the
inverse: it takes a full, complex modulation spectrum and reconstructs the
magnitude spectrogram.
specToMS(spec, center = TRUE)
msToSpec(ms)
spec |
target spectrogram (numeric matrix, frequency in rows, time in columns), with frequency labels (kHz) in rownames and time labels (ms) in colnames |
center |
if TRUE, the MS is centered with DC in the middle |
ms |
centered modulation spectrum (complex matrix, spectral modulation
in rows, temporal modulation in columns), as returned by |
Both functions assume that the input carries valid labels: a spectrogram must
have frequency labels (kHz) in its rownames and time labels (ms) in its
colnames, and a modulation spectrum must have spectral modulation labels in
its rownames and temporal modulation labels in its colnames. This is the case
for objects produced by soundgen functions (e.g. spectrogram,
stft_simple, modulationSpectrum), and it also
ensures that zero-padding is reflected correctly in the labels.
specToMS() returns a list with $ms (the uncentered MS)
and $ms_centered (the centered MS, or NULL if center = FALSE).
Both are complex matrices of the same dimension as spec, with
spectral modulation (FM) in rows and temporal modulation (AM) in columns.
msToSpec() returns a magnitude spectrogram (real matrix, frequency in
rows, time in columns).
modulationSpectrum, plotMS
s = soundgen(sylLen = 200, amFreq = 25, amDep = 50, pitch = 250,
addSilence = 0, samplingRate = 16000)
spec = spectrogram(s, samplingRate = 16000, windowLength = 25, step = 5,
plot = FALSE)
image(t(spec))
ms = specToMS(spec)
plotMS(log(Mod(ms$ms_centered)), quantiles = NULL)
# round-trip: reconstruct the magnitude spectrogram
spec_new = msToSpec(ms$ms_centered)
image(t(spec_new))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.