spandsp  0.0.6
dds_int.c File Reference
#include <inttypes.h>
#include "floating_fudge.h"
#include "spandsp/telephony.h"
#include "spandsp/complex.h"
#include "spandsp/dds.h"

Macros

#define SLENK   8
 
#define DDS_STEPS   (1 << SLENK)
 
#define DDS_SHIFT   (32 - 2 - SLENK)
 

Functions

int32_t dds_phase_rate (float frequency)
 Find the phase rate value to achieve a particular frequency. More...
 
float dds_frequency (int32_t phase_rate)
 Find the frequency, in Hz, equivalent to a phase rate. More...
 
int16_t dds_scaling_dbm0 (float level)
 Find the scaling factor needed to achieve a specified level in dBm0. More...
 
int16_t dds_scaling_dbov (float level)
 Find the scaling factor needed to achieve a specified level in dBmov. More...
 
int16_t dds_lookup (uint32_t phase)
 Lookup the integer value of a specified phase. More...
 
int16_t dds_offset (uint32_t phase_acc, int32_t phase_offset)
 Find the amplitude for a particular phase offset from an accumulated phase. More...
 
void dds_advance (uint32_t *phase_acc, int32_t phase_rate)
 Advance the phase, without returning any new signal sample. More...
 
int16_t dds (uint32_t *phase_acc, int32_t phase_rate)
 Generate an integer tone sample. More...
 
int16_t dds_mod (uint32_t *phase_acc, int32_t phase_rate, int16_t scale, int32_t phase)
 Generate an integer tone sample, with modulation. More...
 
complexi_t dds_lookup_complexi (uint32_t phase)
 Lookup the complex integer value of a specified phase. More...
 
complexi_t dds_complexi (uint32_t *phase_acc, int32_t phase_rate)
 Generate a complex integer tone sample. More...
 
complexi_t dds_complexi_mod (uint32_t *phase_acc, int32_t phase_rate, int16_t scale, int32_t phase)
 Generate a complex integer tone sample, with modulation. More...
 
complexi16_t dds_lookup_complexi16 (uint32_t phase)
 Generate a complex 16 bit integer tone sample. More...
 
complexi16_t dds_complexi16 (uint32_t *phase_acc, int32_t phase_rate)
 Generate a complex 16 bit integer tone sample. More...
 
complexi16_t dds_complexi16_mod (uint32_t *phase_acc, int32_t phase_rate, int16_t scale, int32_t phase)
 Generate a complex 16bit integer tone sample, with modulation. More...
 
complexi32_t dds_lookup_complexi32 (uint32_t phase)
 Generate a complex 32 bit integer tone sample. More...
 
complexi32_t dds_complexi32 (uint32_t *phase_acc, int32_t phase_rate)
 Generate a complex 32 bit integer tone sample. More...
 
complexi32_t dds_complexi32_mod (uint32_t *phase_acc, int32_t phase_rate, int16_t scale, int32_t phase)
 Generate a complex 32 bit integer tone sample, with modulation. More...
 

Function Documentation

◆ dds()

int16_t dds ( uint32_t *  phase_acc,
int32_t  phase_rate 
)

Generate an integer tone sample.

Parameters
phase_accA pointer to a phase accumulator value.
phase_rateThe phase increment to be applied.
Returns
The signal amplitude, between -32767 and 32767.

◆ dds_advance()

void dds_advance ( uint32_t *  phase_acc,
int32_t  phase_rate 
)

Advance the phase, without returning any new signal sample.

Parameters
phase_accA pointer to a phase accumulator value.
phase_rateThe phase increment to be applied.

◆ dds_complexi()

complexi_t dds_complexi ( uint32_t *  phase_acc,
int32_t  phase_rate 
)

Generate a complex integer tone sample.

Parameters
phase_accA pointer to a phase accumulator value.
phase_rateThe phase increment to be applied.
Returns
The complex signal amplitude, between (-32767, -32767) and (32767, 32767).

◆ dds_complexi16()

complexi16_t dds_complexi16 ( uint32_t *  phase_acc,
int32_t  phase_rate 
)

Generate a complex 16 bit integer tone sample.

Parameters
phase_accA pointer to a phase accumulator value.
phase_rateThe phase increment to be applied.
Returns
The complex signal amplitude, between (-32767, -32767) and (32767, 32767).

◆ dds_complexi16_mod()

complexi16_t dds_complexi16_mod ( uint32_t *  phase_acc,
int32_t  phase_rate,
int16_t  scale,
int32_t  phase 
)

Generate a complex 16bit integer tone sample, with modulation.

Parameters
phase_accA pointer to a phase accumulator value.
phase_rateThe phase increment to be applied.
scaleThe scaling factor.
phaseThe phase offset.
Returns
The complex signal amplitude, between (-32767, -32767) and (32767, 32767).

◆ dds_complexi32()

complexi32_t dds_complexi32 ( uint32_t *  phase_acc,
int32_t  phase_rate 
)

Generate a complex 32 bit integer tone sample.

Parameters
phase_accA pointer to a phase accumulator value.
phase_rateThe phase increment to be applied.
Returns
The complex signal amplitude, between (-32767, -32767) and (32767, 32767).

◆ dds_complexi32_mod()

complexi32_t dds_complexi32_mod ( uint32_t *  phase_acc,
int32_t  phase_rate,
int16_t  scale,
int32_t  phase 
)

Generate a complex 32 bit integer tone sample, with modulation.

Parameters
phase_accA pointer to a phase accumulator value.
phase_rateThe phase increment to be applied.
scaleThe scaling factor.
phaseThe phase offset.
Returns
The complex signal amplitude, between (-32767, -32767) and (32767, 32767).

◆ dds_complexi_mod()

complexi_t dds_complexi_mod ( uint32_t *  phase_acc,
int32_t  phase_rate,
int16_t  scale,
int32_t  phase 
)

Generate a complex integer tone sample, with modulation.

Parameters
phase_accA pointer to a phase accumulator value.
phase_rateThe phase increment to be applied.
scaleThe scaling factor.
phaseThe phase offset.
Returns
The complex signal amplitude, between (-32767, -32767) and (32767, 32767).

◆ dds_frequency()

float dds_frequency ( int32_t  phase_rate)

Find the frequency, in Hz, equivalent to a phase rate.

Parameters
phase_rateThe phase rate.
Returns
The equivalent frequency, in Hz.

◆ dds_lookup()

int16_t dds_lookup ( uint32_t  phase)

Lookup the integer value of a specified phase.

Find the amplitude for a particular phase.

Parameters
phaseThe phase accumulator value to be looked up.
Returns
The signal amplitude, between -32767 and 32767.

Referenced by dds_offset().

◆ dds_lookup_complexi()

complexi_t dds_lookup_complexi ( uint32_t  phase)

Lookup the complex integer value of a specified phase.

Parameters
phaseThe phase accumulator value to be looked up.
Returns
The complex signal amplitude, between (-32767, -32767) and (32767, 32767).

◆ dds_lookup_complexi16()

complexi16_t dds_lookup_complexi16 ( uint32_t  phase)

Generate a complex 16 bit integer tone sample.

Parameters
phase_accA pointer to a phase accumulator value.
phase_rateThe phase increment to be applied.
Returns
The complex signal amplitude, between (-32767, -32767) and (32767, 32767).

◆ dds_lookup_complexi32()

complexi32_t dds_lookup_complexi32 ( uint32_t  phase)

Generate a complex 32 bit integer tone sample.

Parameters
phase_accA pointer to a phase accumulator value.
phase_rateThe phase increment to be applied.
Returns
The complex signal amplitude, between (-32767, -32767) and (32767, 32767).

◆ dds_mod()

int16_t dds_mod ( uint32_t *  phase_acc,
int32_t  phase_rate,
int16_t  scale,
int32_t  phase 
)

Generate an integer tone sample, with modulation.

Parameters
phase_accA pointer to a phase accumulator value.
phase_rateThe phase increment to be applied.
scaleThe scaling factor.
phaseThe phase offset.
Returns
The signal amplitude, between -32767 and 32767.

◆ dds_offset()

int16_t dds_offset ( uint32_t  phase_acc,
int32_t  phase_offset 
)

Find the amplitude for a particular phase offset from an accumulated phase.

Parameters
phase_accThe accumulated phase.
phase_offsetThe phase offset.
Returns
The signal amplitude.

References dds_lookup().

◆ dds_phase_rate()

int32_t dds_phase_rate ( float  frequency)

Find the phase rate value to achieve a particular frequency.

Parameters
frequencyThe desired frequency, in Hz.
Returns
The phase rate which while achieve the desired frequency.

◆ dds_scaling_dbm0()

int16_t dds_scaling_dbm0 ( float  level)

Find the scaling factor needed to achieve a specified level in dBm0.

Parameters
levelThe desired signal level, in dBm0.
Returns
The scaling factor.

◆ dds_scaling_dbov()

int16_t dds_scaling_dbov ( float  level)

Find the scaling factor needed to achieve a specified level in dBmov.

Parameters
levelThe desired signal level, in dBmov.
Returns
The scaling factor.