spandsp 0.0.6
|
#include <inttypes.h>
#include <stdlib.h>
#include "floating_fudge.h"
#include <string.h>
#include <stdio.h>
#include <time.h>
#include <fcntl.h>
#include "spandsp/telephony.h"
#include "spandsp/complex.h"
#include "spandsp/complex_vector_float.h"
#include "spandsp/tone_detect.h"
#include "spandsp/tone_generate.h"
#include "spandsp/private/tone_detect.h"
Macros | |
#define | M_PI 3.14159265358979323846264338327 |
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_t * | goertzel_init (goertzel_state_t *s, goertzel_descriptor_t *t) |
Initialise the state of a Goertzel transform. More... | |
int | goertzel_release (goertzel_state_t *s) |
int | goertzel_free (goertzel_state_t *s) |
void | goertzel_reset (goertzel_state_t *s) |
Reset the state of a Goertzel transform. More... | |
int | goertzel_update (goertzel_state_t *s, const int16_t amp[], int samples) |
Update the state of a Goertzel transform. More... | |
float | goertzel_result (goertzel_state_t *s) |
Evaluate the final result of a Goertzel transform. More... | |
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) |
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) |
float | periodogram_freq_error (const complexf_t *phase_offset, float scale, const complexf_t *last_result, const complexf_t *result) |
goertzel_state_t * goertzel_init | ( | goertzel_state_t * | s, |
goertzel_descriptor_t * | t | ||
) |
Initialise the state of a Goertzel transform.
s | The Goertzel context. If NULL, a context is allocated with malloc. |
t | The Goertzel descriptor. |
void goertzel_reset | ( | goertzel_state_t * | s | ) |
Reset the state of a Goertzel transform.
s | The Goertzel context. |
Referenced by dtmf_rx_fillin(), and goertzel_result().
float goertzel_result | ( | goertzel_state_t * | s | ) |
Evaluate the final result of a Goertzel transform.
s | The Goertzel context. |
References goertzel_reset().
int goertzel_update | ( | goertzel_state_t * | s, |
const int16_t | amp[], | ||
int | samples | ||
) |
Update the state of a Goertzel transform.
s | The Goertzel context. |
amp | The samples to be transformed. |
samples | The number of samples. |
complexf_t periodogram | ( | const complexf_t | coeffs[], |
const complexf_t | amp[], | ||
int | len | ||
) |
Evaluate a periodogram.
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. |
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.
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. |
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.
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. |
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.
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. |
References complexf_t::im, and complexf_t::re.
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.
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. |
References complexf_t::im, and complexf_t::re.
int periodogram_prepare | ( | complexf_t | sum[], |
complexf_t | diff[], | ||
const complexf_t | amp[], | ||
int | len | ||
) |
Prepare data for evaluating a set of periodograms.
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. |