Routines for FFT, IFFT, energy spectrum (magnitude squared) and power spectrum (root magnitude squared). All functions below return 0 for success, -1 for an error.
int FFT(EST_FVector &real, EST_FVector &imag)
In-place FFT. For real signals (i.e. most of them !), you should set
imag
to a vector of zeros. real
and imag
must have
the same number of elements, which must be a power of 2 (e.g. 1024).
int IFFT(EST_FVector &real, EST_FVector &imag)
In-place inverse FFT.
int power_spectrum(EST_FVector &real, EST_FVector &imag);
Returns power spectrum in real
(and sets imag = real
).
int energy_spectrum(EST_FVector &real, EST_FVector &imag);
Returns energy spectrum in real
(and sets imag = real
).
The cepstral analysis functions are not fully developed and no testing has been done to confirm that their results are correct.
More work is required with these functions.
Delta coefficients are an approximation to the derivative of a data
dequence. The functions described here should be distinguished from the
differentiate(EST_Track &c, float samp_int)
function (see the
header file, `include/EST_sigpr.h'.
The two functions available are :
void delta(EST_Track &track, int regression_length);
(see the header file, `include/sigpr.h')
This routine operates in-place and returns the first delta coefficient
(approximating differentiation). The delta coefficient for the first
frame is defined as zero. To generate the second delta coefficient
simply call delta(...)
example twice, and so on. The size of the
Track is unchanged. The name of the Track has "_d" appended each time
delta(...)
example is called.
The routines handle the variable number of points used at the start of
the data. As many points as available are passed to float
compute_gradient(float* x, int num_points)
, up to a maximum of
MAX_REGRESSION_LENGTH example which is defined in sigpr.h.
Both delta(...)
routines call compute_gradient(float* x,
int num_points)
to compute a delta coefficient by solving the
least-squares fit of a straight line to a sequence of points. This
function can only handle up to 4 points as the solutions are hard-wired.
This is for efficiency reasons - a general solution to the least squares
problem involves matrix inversion. The time between points is assumed to
be 1. If delta coefficients in terms of units-per-second are required,
call the function and then divide the result by the time between points
(typically the frame spacing).
compute_gradient(float* x, int num_points)
should not be called
directly.
EST_Option op; EST_Wave sig; // read sig and op ... Track cepstra, delta_cepstra, second_delta_cepstra; int regression_length = 4; cepstra = make_cepstra_unnorm(sig, op); delta_cepstra = cepstra; delta(delta_cepstra, regression_length); second_delta_cepstra = delta_cepstra; delta(second_delta_cepstra, regression_length); ...etc.
To be written.
To be written.
To be written.
All the smoothing functions smooth the track given as an argument, so you must copy the original if you don't want it changed.
void simple_med_smooth(EST_Track &c, int n)
Perform n-point median smoothing on track.
void simple_mean_smooth(EST_Track &c, int n)
Perform n-point mean (averaging) smoothing on track.
void time_mean_smooth(EST_Track &c, float x)
Perform mean smoothing. The order of the smoothing is worked out from
x which is a window size in seconds. If the track is specified in 10ms
intervals and x has a value of 0.15, 15 point smoothing will be
performed.
void time_med_smooth(EST_Track &c, float x)
Perform media smoothing. The order of the smoothing is worked out from
x which is a window size in seconds. If the track is specified in 0.01s
intervals and x has a value of 0.15, 15 point smoothing will be
performed.
void smooth(EST_Track &c, float x, EST_String stype)
A general smoothing function, over time x (given in seconds). stype
can be either "mean" or "median".
In all the follwing window generation functions, the parameter size
gives the number of points in the vector returned. If size
is odd, the middle value of the returned vector will be exactly 1.0; if size
is even, there is of course no middle value.
EST_FVector Triangular_window(int size)
Returns a triangular window.
EST_FVector Hanning_window(int size)
Returns the window 0.5 - 0.5 * cos(2 * PI * (i+0.5)/size), where i=0..size-1.
EST_FVector Hamming_window(int size)
Returns the window 0.54 - 046 * cos(2 * PI * (i+0.5)/size), where i=0..size-1.
When applying the same window many times, it is much more efficient to generate the window once and then apply it, like this (where data
is an array of FVectors):
EST_FVector w = Hamming_window(data[0].n()); for(i=...) window(data[i],v);
using the first of these functions. The remaining functions are convenient when only using a window once.
void window(EST_FVector &data, EST_FVector &window)
In-place application of window
to data
. Exactly the same
as element-wise multiplication of the two vectors. data
and
window
must have the same number of elements.
void Triangular_window(EST_FVector &data);
In-place triangular windowing of data
.
void Hanning_window(EST_FVector &data)
In-place Hanning windowing of data
.
void Hamming_window(EST_FVector &data)
In-place Hamming windowing of data
.
Functions for applying FIR filters to Wave (See section Waveform C++ class) objects, and for designing filters for a given frequency response. Currently limited to FIR (all-zero) filters.
EST_Wave FIRfilter(EST_Wave &sigin, EST_FVector numerator, int delay_correction=0);
Apply the FIR filter whose co-efficients are in numerator, to the
EST_Wave
. If delay_correction is given, the output wave is
shifted to compensate for filter delay. delay_correction must be
positive.
EST_Wave FIRlowpass_filter(EST_Wave &sigin, int cutoff_frequency, int order);
Lowpass filter the Wave with an FIR filter with order coefficients. The
filter is designed using design_lowpass_FIR_filter()
.
EST_Wave FIRhighpass_filter(EST_Wave &sigin, int cutoff_frequency, int order);
Similar to FIRlowpass_filter
.
EST_FVector design_FIR_filter(EST_FVector frequency_response, int filter_order)
Compute the coefficients of a FIR filter with filter_order coefficients,
given the desired frequency response. The frequency response must be a
vector of dimension 2^N (N is an integer). Care should be taken to
provide a frequency response vector of large enough dimension when
computing higher order filters.
EST_FVector design_lowpass_FIR_filter(int sample_rate, int cutoff_freq, int order)
Wrapper for design_FIR_filter()
.
EST_FVector design_highpass_FIR_filter(int sample_rate, int cutoff_freq, int order)
Wrapper for design_FIR_filter
.
Useful utility functions for tracks.
float average(EST_Track &a)
Return the average value of the track.
void meansd(EST_Track &tr, float &mean, float &sd)
Return the mean and standard deviation of the values in the track.
void normalise(EST_Track &tr, float mean, float sd)
Normalise the track so as nearly all values lie in the range -1 to
+1. This is achieved by subtracing the mean and dividing by
twice the standard deviation. (Note that this may be changed in
a later version)
void normalise(EST_Track &tr)
As above, but the mean and standard deviation are calculated within the
function.
EST_Track error(EST_Track &ref, EST_Track &test, int relax)
Return a track which is representative of the "error" between the
ref (reference) and test track. Both the input tracks are
assumed to be in the range 0 to 1. If the reference track is above 0.5
and the test track is above 0.6, or, the reference track is below 0.5
and the test track is below 0.4, the error track is given a value of 1,
Otherwise the error track value is set to 0. (A future addition to this
function will alow the 0.4 and 0.6 values to be changed by the user)
The relax argument can be used to ignore values near state
changesin the reference track (i.e. when the value changes from 1 to 0
or from 0 to 1). The argument specifies the number of frames to be
ignored at such a state changed.
EST_Track difference(EST_Track &a, EST_Track &b)
Subtract the values in contour b from contour a. This will eventually be
implemented as an overloaded minus operator.
EST_Track differentiate(EST_Track &c, float samp_int)
Differentiate the track. This function differentiates using the previous
value only: a more sophistiaced technique is given in the delta function
delta.
void absolute(EST_Track &tr)
Calculate an absolute version of the track whereby each value is
positive.
Go to the first, previous, next, last section, table of contents.