Util
- utility functions
DSP.Util.unwrap
— Function.unwrap(m, dim=ndims(m); range=2pi)
Assumes m (along dimension dim) to be a sequences of values that have been wrapped to be inside the given range (centered around zero), and undoes the wrapping by identifying discontinuities. If dim is not given, the last dimension is used.
A common usage is for a phase measurement over time, such as when comparing successive frames of a short-time-fourier-transform, as each frame is wrapped to stay within (-pi, pi].
DSP.Util.unwrap!
— Function.unwrap!(m, dim=ndims(m); range=2pi)
In-place version of unwrap(m, dim, range)
DSP.Util.hilbert
— Function.hilbert(x)
Computes the analytic representation of x, $x_a = x + j \hat{x}$, where $\hat{x}$ is the Hilbert transform of x, along the first dimension of x.
DSP.Util.fftfreq
— Function.fftfreq(n, fs=1)
Return discrete fourier transform sample frequencies. The returned Frequencies object is an AbstractVector containing the frequency bin centers at every sample point. fs
is the sample rate of the input signal.
DSP.Util.rfftfreq
— Function.rfftfreq(n, fs=1)
Return discrete fourier transform sample frequencies for use with rfft
. The returned Frequencies object is an AbstractVector containing the frequency bin centers at every sample point. fs
is the sample rate of the input signal.
DSP.Util.nextfastfft
— Function.nextfastfft(n)
Return the closest product of 2, 3, 5, and 7 greater than or equal to n
. FFTW contains optimized kernels for these sizes and computes Fourier transforms of input that is a product of these sizes faster than for input of other sizes.
DSP.Util.pow2db
— Function.pow2db(a)
Convert a power ratio to dB (decibel), or $10\log_{10}(a)$. The inverse of db2pow
.
DSP.Util.amp2db
— Function.amp2db(a)
Convert an amplitude ratio to dB (decibel), or $20 \log_{10}(a)=10\log_{10}(a^2)$. The inverse of db2amp
.
DSP.Util.db2pow
— Function.db2pow(a)
Convert dB to a power ratio. This function call also be called using a*dB
, i.e. 3dB == db2pow(3)
. The inverse of pow2db
.
DSP.Util.db2amp
— Function.db2amp(a)
Convert dB to an amplitude ratio. This function call also be called using a*dBa
, i.e. 3dBa == db2amp(3)
. The inverse of amp2db
.
DSP.Util.rms
— Function.rms(s)
Return the root mean square of signal s
.
DSP.Util.rmsfft
— Function.rmsfft(f)
Return the root mean square of signal s
given the FFT transform f = fft(s)
. Equivalent to rms(ifft(f))
.
DSP.Util.meanfreq
— Function.meanfreq(x, fs)
Calculate the mean power frequency of x
with a sampling frequency of fs
, defined as:
where $F$ is the Nyquist frequency, and $X$ is the power spectral density.