View source: R/invertModulSpec.R
filterMS | R Documentation |
Filters a modulation spectrum by removing a certain range of amplitude
modulation (AM) and frequency modulation (FM) frequencies. Conditions can be
specified either separately for AM and FM with amCond = ..., fmCond =
...
, implying an OR combination of conditions, or jointly on AM and FM with
jointCond
. jointCond
is more general, but using
amCond/fmCond
is ~100 times faster.
filterMS(
ms,
amCond = NULL,
fmCond = NULL,
jointCond = NULL,
action = c("remove", "preserve")[1],
plot = TRUE
)
ms |
a modulation spectrum as returned by
|
amCond , fmCond |
character strings with valid conditions on amplitude and frequency modulation (see examples) |
jointCond |
character string with a valid joint condition amplitude and frequency modulation |
action |
should the defined AM-FM region be removed ('remove') or preserved, while everything else is removed ('preserve')? |
plot |
if TRUE, plots the filtered modulation spectrum |
Returns the filtered modulation spectrum - a matrix of the original dimensions, real or complex.
ms = modulationSpectrum(soundgen(), samplingRate = 16000,
returnComplex = TRUE)$complex
# Remove all AM over 25 Hz
ms_filt = filterMS(ms, amCond = 'abs(am) > 25')
# amCond and fmCond are OR-conditions
filterMS(ms, amCond = 'abs(am) > 15', fmCond = 'abs(fm) > 5', action = 'remove')
filterMS(ms, amCond = 'abs(am) > 15', fmCond = 'abs(fm) > 5', action = 'preserve')
filterMS(ms, amCond = 'abs(am) > 10 & abs(am) < 25', action = 'remove')
# jointCond is an AND-condition
filterMS(ms, jointCond = 'am * fm < 5', action = 'remove')
filterMS(ms, jointCond = 'am^2 + (fm*3)^2 < 200', action = 'preserve')
# So:
filterMS(ms, jointCond = 'abs(am) > 5 | abs(fm) < 5') # slow but general
# ...is the same as:
filterMS(ms, amCond = 'abs(am) > 5', fmCond = 'abs(fm) < 5') # fast
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.