| hilbert_exact | R Documentation |
hilbert_exact treats the input as one period of an infinite periodic
signal (circular convolution), while hilbert_approx pads the input on
both sides to a good length for FFT, which is faster at the cost of possible
slight artifacts at the edges (~linear convolution). If the input is <3
samples long, the envelope is calculated simply as Mod(x). Note: only
hilbert_approx is fast enough to be used for extracting the envelopes
of typical audio.
hilbert_exact(x)
hilbert_approx(x)
x |
numeric vector |
A list with two components:
Hilbert transform
Instantaneous amplitude of the analytic signal (envelope)
# signal: amplitude-modulated sine wave
t = seq(0, 1, length.out = 477)
carrier = cos(2 * pi * 50 * t)
modulator = 1 + 0.5 * cos(2 * pi * 5 * t)
s = modulator * carrier # amplitude modulated signal
hil_exact = hilbert_exact(s)
hil_approx = hilbert_approx(s)
plot(s, type = 'l')
points(hil_exact$envelope, type = 'l', col = 'blue')
points(hil_approx$envelope, type = 'l', col = 'red')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.