00001 /* 00002 * SpanDSP - a series of DSP components for telephony 00003 * 00004 * dds.h 00005 * 00006 * Written by Steve Underwood <steveu@coppice.org> 00007 * 00008 * Copyright (C) 2003 Steve Underwood 00009 * 00010 * All rights reserved. 00011 * 00012 * This program is free software; you can redistribute it and/or modify 00013 * it under the terms of the GNU General Public License version 2, as 00014 * published by the Free Software Foundation. 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU General Public License 00022 * along with this program; if not, write to the Free Software 00023 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00024 * 00025 * $Id: dds.h,v 1.13 2007/05/07 13:11:47 steveu Exp $ 00026 */ 00027 00028 /*! \file */ 00029 00030 #if !defined(_SPANDSP_DDS_H_) 00031 #define _SPANDSP_DDS_H_ 00032 00033 #include "complex.h" 00034 00035 #if defined(__cplusplus) 00036 extern "C" 00037 { 00038 #endif 00039 00040 /*! \brief Find the phase rate value to achieve a particular frequency. 00041 \param frequency The desired frequency, in Hertz. 00042 \return The phase rate which while achieve the desired frequency. 00043 */ 00044 int32_t dds_phase_rate(float frequency); 00045 00046 float dds_frequency(int32_t phase_rate); 00047 00048 /*! \brief Find the scaling factor needed to achieve a specified level in dBm0. 00049 \param level The desired signal level, in dBm0. 00050 \return The scaling factor. 00051 */ 00052 int dds_scaling_dbm0(float level); 00053 00054 int dds_scaling_dbov(float level); 00055 00056 /*! \brief Find the amplitude for a particular phase. 00057 \param phase The desired phase 32 bit phase. 00058 \return The signal amplitude. 00059 */ 00060 int16_t dds_lookup(uint32_t phase); 00061 00062 /*! \brief Find the amplitude for a particular phase offset from an accumulated phase. 00063 \param phase_acc The accumulated phase. 00064 \param phase_offset The phase offset. 00065 \return The signal amplitude. 00066 */ 00067 int16_t dds_offset(uint32_t phase_acc, int32_t phase_offset); 00068 00069 /*! \brief Generate an integer tone sample. 00070 \param phase_acc A pointer to a phase accumulator value. 00071 \param phase_rate The phase increment to be applied. 00072 \return The signal amplitude, between -32767 and 32767. 00073 */ 00074 int16_t dds(uint32_t *phase_acc, int32_t phase_rate); 00075 00076 /*! \brief Generate an integer tone sample, with modulation. 00077 \param phase_acc A pointer to a phase accumulator value. 00078 \param phase_rate The phase increment to be applied. 00079 \param scale The scaling factor. 00080 \param phase The phase offset. 00081 \return The signal amplitude. 00082 */ 00083 int16_t dds_mod(uint32_t *phase_acc, int32_t phase_rate, int scale, int32_t phase); 00084 00085 /*! \brief Generate a complex integer tone sample. 00086 \param phase_acc A pointer to a phase accumulator value. 00087 \param phase_rate The phase increment to be applied. 00088 \return The complex signal amplitude, between -32767 and 32767. 00089 */ 00090 complexi_t dds_complexi(uint32_t *phase_acc, int32_t phase_rate); 00091 00092 /*! \brief Generate a complex integer tone sample, with modulation. 00093 \param phase_acc A pointer to a phase accumulator value. 00094 \param phase_rate The phase increment to be applied. 00095 \param scale The scaling factor. 00096 \param phase The phase offset. 00097 \return The complex signal amplitude. 00098 */ 00099 complexi_t dds_complexi_mod(uint32_t *phase_acc, int32_t phase_rate, int scale, int32_t phase); 00100 00101 int32_t dds_phase_ratef(float frequency); 00102 00103 float dds_frequencyf(int32_t phase_rate); 00104 00105 float dds_scaling_dbm0f(float level); 00106 00107 float dds_scaling_dbovf(float level); 00108 00109 /*! \brief Generate a floating point tone sample. 00110 \param phase_acc A pointer to a phase accumulator value. 00111 \param phase_rate The phase increment to be applied. 00112 \return The signal amplitude, between -32767 and 32767. 00113 */ 00114 float ddsf(uint32_t *phase_acc, int32_t phase_rate); 00115 00116 /*! \brief Generate a floating point tone sample, with modulation. 00117 \param phase_acc A pointer to a phase accumulator value. 00118 \param phase_rate The phase increment to be applied. 00119 \param scale The scaling factor. 00120 \param phase The phase offset. 00121 \return The signal amplitude. 00122 */ 00123 float dds_modf(uint32_t *phase_acc, int32_t phase_rate, float scale, int32_t phase); 00124 00125 /*! \brief Generate a complex floating point tone sample. 00126 \param phase_acc A pointer to a phase accumulator value. 00127 \param phase_rate The phase increment to be applied. 00128 \return The complex signal amplitude, between -32767 and 32767. 00129 */ 00130 complexf_t dds_complexf(uint32_t *phase_acc, int32_t phase_rate); 00131 00132 /*! \brief Generate a complex floating point tone sample, with modulation. 00133 \param phase_acc A pointer to a phase accumulator value. 00134 \param phase_rate The phase increment to be applied. 00135 \param scale The scaling factor. 00136 \param phase The phase offset. 00137 \return The complex signal amplitude. 00138 */ 00139 complexf_t dds_complex_modf(uint32_t *phase_acc, int32_t phase_rate, float scale, int32_t phase); 00140 00141 #if defined(__cplusplus) 00142 } 00143 #endif 00144 00145 #endif 00146 /*- End of file ------------------------------------------------------------*/