tone_detect.h File Reference

Go to the source code of this file.

Classes

struct  goertzel_descriptor_t
struct  goertzel_state_t

Defines

#define _SPANDSP_TONE_DETECT_H_
#define goertzel_preadjust_amp(amp)   ((float) amp)

Functions

void make_goertzel_descriptor (goertzel_descriptor_t *t, float freq, int samples)
 Create a descriptor for use with either a Goertzel transform.
goertzel_state_tgoertzel_init (goertzel_state_t *s, goertzel_descriptor_t *t)
 Initialise the state of a Goertzel transform.
void goertzel_reset (goertzel_state_t *s)
 Reset the state of a Goertzel transform.
int goertzel_update (goertzel_state_t *s, const int16_t amp[], int samples)
 Update the state of a Goertzel transform.
float goertzel_result (goertzel_state_t *s)
 Evaluate the final result of a Goertzel transform.
int periodogram_generate_coeffs (complexf_t coeffs[], float freq, int sample_rate, int window_len)
float periodogram_generate_phase_offset (complexf_t *offset, float freq, int sample_rate, int interval)
complexf_t periodogram (const complexf_t coeffs[], const complexf_t amp[], int len)
int periodogram_prepare (complexf_t sum[], complexf_t diff[], const complexf_t amp[], int len)
complexf_t periodogram_apply (const complexf_t coeffs[], const complexf_t sum[], const complexf_t diff[], int len)
float periodogram_freq_error (const complexf_t *phase_offset, float scale, const complexf_t *last_result, const complexf_t *result)


Detailed Description


Function Documentation

goertzel_state_t* goertzel_init ( goertzel_state_t s,
goertzel_descriptor_t t 
)

Initialise the state of a Goertzel transform.

Parameters:
s The Goertzel context. If NULL, a context is allocated with malloc.
t The Goertzel descriptor.
Returns:
A pointer to the Goertzel state.

References goertzel_state_t::current_sample, goertzel_descriptor_t::fac, goertzel_state_t::fac, goertzel_init(), goertzel_descriptor_t::samples, goertzel_state_t::samples, goertzel_state_t::v2, and goertzel_state_t::v3.

Referenced by bell_mf_rx_init(), dtmf_rx_init(), goertzel_init(), r2_mf_rx_init(), and super_tone_rx_init().

void goertzel_reset ( goertzel_state_t s  ) 

Reset the state of a Goertzel transform.

Parameters:
s The Goertzel context.

References goertzel_state_t::current_sample, goertzel_reset(), goertzel_state_t::v2, and goertzel_state_t::v3.

Referenced by goertzel_reset(), and goertzel_result().

float goertzel_result ( goertzel_state_t s  ) 

Evaluate the final result of a Goertzel transform.

Parameters:
s The Goertzel context.
Returns:
The result of the transform. The expected result for a pure sine wave signal of level x dBm0, at the very centre of the bin is: [Floating point] ((samples_per_goertzel_block*32768.0/1.4142)*10^((x - DBM0_MAX_SINE_POWER)/20.0))^2 [Fixed point] ((samples_per_goertzel_block*256.0/1.4142)*10^((x - DBM0_MAX_SINE_POWER)/20.0))^2

References goertzel_state_t::fac, goertzel_reset(), goertzel_result(), goertzel_state_t::v2, and goertzel_state_t::v3.

Referenced by bell_mf_rx(), dtmf_rx(), goertzel_result(), and r2_mf_rx().

int goertzel_update ( goertzel_state_t s,
const int16_t  amp[],
int  samples 
)

Update the state of a Goertzel transform.

Parameters:
s The Goertzel context.
amp The samples to be transformed.
samples The number of samples.
Returns:
The number of samples unprocessed

References goertzel_state_t::current_sample, goertzel_state_t::fac, goertzel_update(), goertzel_state_t::samples, goertzel_state_t::v2, and goertzel_state_t::v3.

Referenced by goertzel_update(), and super_tone_rx().

complexf_t periodogram ( const complexf_t  coeffs[],
const complexf_t  amp[],
int  len 
)

Evaluate a periodogram.

Parameters:
coeffs A set of coefficients generated by periodogram_generate_coeffs().
amp The complex amplitude of the signal.
len The length of the periodogram, in samples. This must be an even number.
Returns:
The periodogram result.

References complexf_t::im, periodogram(), and complexf_t::re.

Referenced by periodogram().

complexf_t periodogram_apply ( const complexf_t  coeffs[],
const complexf_t  sum[],
const complexf_t  diff[],
int  len 
)

Evaluate a periodogram, based on data prepared by periodogram_prepare(). This is more efficient than using periodogram() when several periodograms are to be applied to the same signal.

Parameters:
coeffs A set of coefficients generated by periodogram_generate_coeffs().
sum A vector of sums produced by periodogram_prepare().
diff A vector of differences produced by periodogram_prepare().
len The length of the periodogram, in samples. This must be an even number.
Returns:
The periodogram result.

References complexf_t::im, periodogram_apply(), and complexf_t::re.

Referenced by periodogram_apply().

float periodogram_freq_error ( const complexf_t phase_offset,
float  scale,
const complexf_t last_result,
const complexf_t result 
)

Apply a phase offset, to find the frequency error between periodogram evaluations. specified interval.

Parameters:
phase_offset A point to the expected phase offset.
scale The scaling factor to be used.
last_result A pointer to the previous periodogram result.
result A pointer to the current periodogram result.
Returns:
The frequency error, in Hz.

References complexf_t::im, periodogram_freq_error(), and complexf_t::re.

Referenced by periodogram_freq_error().

int periodogram_generate_coeffs ( complexf_t  coeffs[],
float  freq,
int  sample_rate,
int  window_len 
)

Generate a Hamming weighted coefficient set, to be used for a periodogram analysis.

Parameters:
coeffs The generated coefficients.
freq The frequency to be matched by the periodogram, in Hz.
sample_rate The sample rate of the signal, in samples per second.
window_len The length of the periodogram window. This must be an even number.
Returns:
The number of generated coefficients.

References complexf_t::im, periodogram_generate_coeffs(), and complexf_t::re.

Referenced by periodogram_generate_coeffs().

float periodogram_generate_phase_offset ( complexf_t offset,
float  freq,
int  sample_rate,
int  interval 
)

Generate the phase offset to be expected between successive periodograms evaluated at the specified interval.

Parameters:
offset A point to the generated phase offset.
freq The frequency being matched by the periodogram, in Hz.
sample_rate The sample rate of the signal, in samples per second.
interval The interval between periodograms, in samples.
Returns:
The scaling factor.

References complexf_t::im, periodogram_generate_phase_offset(), and complexf_t::re.

Referenced by periodogram_generate_phase_offset().

int periodogram_prepare ( complexf_t  sum[],
complexf_t  diff[],
const complexf_t  amp[],
int  len 
)

Prepare data for evaluating a set of periodograms.

Parameters:
sum A vector of sums of pairs of signal samples. This will be half the length of len.
diff A vector of differences between pairs of signal samples. This will be half the length of len.
amp The complex amplitude of the signal.
len The length of the periodogram, in samples. This must be an even number.
Returns:
The length of the vectors sum and diff.

References periodogram_prepare().

Referenced by periodogram_prepare().


Generated on Tue Oct 7 20:25:52 2008 for spandsp by  doxygen 1.5.6