dds.h

Go to the documentation of this file.
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 Lesser General Public License version 2.1,
00014  * as 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 Lesser General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Lesser General Public
00022  * License 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.21 2008/09/11 15:13:42 steveu Exp $
00026  */
00027 
00028 /*! \file */
00029 
00030 #if !defined(_SPANDSP_DDS_H_)
00031 #define _SPANDSP_DDS_H_
00032 
00033 #if defined(__cplusplus)
00034 extern "C"
00035 {
00036 #endif
00037 
00038 /*! \brief Find the phase rate value to achieve a particular frequency.
00039     \param frequency The desired frequency, in Hz.
00040     \return The phase rate which while achieve the desired frequency.
00041 */
00042 int32_t dds_phase_rate(float frequency);
00043 
00044 /*! \brief Find the frequency, in Hz, equivalent to a phase rate.
00045     \param phase_rate The phase rate.
00046     \return The equivalent frequency, in Hz.
00047 */
00048 float dds_frequency(int32_t phase_rate);
00049 
00050 /*! \brief Find the scaling factor needed to achieve a specified level in dBm0.
00051     \param level The desired signal level, in dBm0.
00052     \return The scaling factor.
00053 */
00054 int dds_scaling_dbm0(float level);
00055 
00056 /*! \brief Find the scaling factor needed to achieve a specified level in dBmov.
00057     \param level The desired signal level, in dBmov.
00058     \return The scaling factor.
00059 */
00060 int dds_scaling_dbov(float level);
00061 
00062 /*! \brief Find the amplitude for a particular phase.
00063     \param phase The desired phase 32 bit phase.
00064     \return The signal amplitude.
00065 */
00066 int16_t dds_lookup(uint32_t phase);
00067 
00068 /*! \brief Find the amplitude for a particular phase offset from an accumulated phase.
00069     \param phase_acc The accumulated phase.
00070     \param phase_offset The phase offset.
00071     \return The signal amplitude.
00072 */
00073 int16_t dds_offset(uint32_t phase_acc, int32_t phase_offset);
00074 
00075 /*! \brief Advance the phase, without returning any new signal sample.
00076     \param phase_acc A pointer to a phase accumulator value.
00077     \param phase_rate The phase increment to be applied.
00078 */
00079 void dds_advance(uint32_t *phase_acc, int32_t phase_rate);
00080 
00081 /*! \brief Generate an integer tone sample.
00082     \param phase_acc A pointer to a phase accumulator value.
00083     \param phase_rate The phase increment to be applied.
00084     \return The signal amplitude, between -32767 and 32767.
00085 */
00086 int16_t dds(uint32_t *phase_acc, int32_t phase_rate);
00087 
00088 /*! \brief Lookup the integer value of a specified phase.
00089     \param phase The phase accumulator value to be looked up.
00090     \return The signal amplitude, between -32767 and 32767.
00091 */
00092 int16_t dds_lookup(uint32_t phase);
00093 
00094 /*! \brief Generate an integer tone sample, with modulation.
00095     \param phase_acc A pointer to a phase accumulator value.
00096     \param phase_rate The phase increment to be applied.
00097     \param scale The scaling factor.
00098     \param phase The phase offset.
00099     \return The signal amplitude, between -32767 and 32767.
00100 */
00101 int16_t dds_mod(uint32_t *phase_acc, int32_t phase_rate, int16_t scale, int32_t phase);
00102 
00103 /*! \brief Lookup the complex integer value of a specified phase.
00104     \param phase The phase accumulator value to be looked up.
00105     \return The complex signal amplitude, between (-32767, -32767) and (32767, 32767).
00106 */
00107 complexi_t dds_lookup_complexi(uint32_t phase);
00108 
00109 /*! \brief Generate a complex integer 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 complex signal amplitude, between (-32767, -32767) and (32767, 32767).
00113 */
00114 complexi_t dds_complexi(uint32_t *phase_acc, int32_t phase_rate);
00115 
00116 /*! \brief Generate a complex integer 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 complex signal amplitude, between (-32767, -32767) and (32767, 32767).
00122 */
00123 complexi_t dds_complexi_mod(uint32_t *phase_acc, int32_t phase_rate, int16_t scale, int32_t phase);
00124 
00125 /*! \brief Generate a complex 16 bit integer 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, -32767) and (32767, 32767).
00129 */
00130 complexi16_t dds_lookup_complexi16(uint32_t phase);
00131 
00132 /*! \brief Generate a complex 16 bit integer tone sample.
00133     \param phase_acc A pointer to a phase accumulator value.
00134     \param phase_rate The phase increment to be applied.
00135     \return The complex signal amplitude, between (-32767, -32767) and (32767, 32767).
00136 */
00137 complexi16_t dds_complexi16(uint32_t *phase_acc, int32_t phase_rate);
00138 
00139 /*! \brief Generate a complex 16bit integer tone sample, with modulation.
00140     \param phase_acc A pointer to a phase accumulator value.
00141     \param phase_rate The phase increment to be applied.
00142     \param scale The scaling factor.
00143     \param phase The phase offset.
00144     \return The complex signal amplitude, between (-32767, -32767) and (32767, 32767).
00145 */
00146 complexi16_t dds_complexi16_mod(uint32_t *phase_acc, int32_t phase_rate, int16_t scale, int32_t phase);
00147 
00148 /*! \brief Generate a complex 32 bit integer tone sample, with modulation.
00149     \param phase_acc A pointer to a phase accumulator value.
00150     \param phase_rate The phase increment to be applied.
00151     \param scale The scaling factor.
00152     \param phase The phase offset.
00153     \return The complex signal amplitude, between (-32767, -32767) and (32767, 32767).
00154 */
00155 complexi32_t dds_complexi32_mod(uint32_t *phase_acc, int32_t phase_rate, int16_t scale, int32_t phase);
00156 
00157 /*! \brief Generate a complex 32 bit integer tone sample.
00158     \param phase_acc A pointer to a phase accumulator value.
00159     \param phase_rate The phase increment to be applied.
00160     \return The complex signal amplitude, between (-32767, -32767) and (32767, 32767).
00161 */
00162 complexi32_t dds_lookup_complexi32(uint32_t phase);
00163 
00164 /*! \brief Generate a complex 32 bit integer tone sample.
00165     \param phase_acc A pointer to a phase accumulator value.
00166     \param phase_rate The phase increment to be applied.
00167     \return The complex signal amplitude, between (-32767, -32767) and (32767, 32767).
00168 */
00169 complexi32_t dds_complexi32(uint32_t *phase_acc, int32_t phase_rate);
00170 
00171 /*! \brief Generate a complex 32 bit integer tone sample, with modulation.
00172     \param phase_acc A pointer to a phase accumulator value.
00173     \param phase_rate The phase increment to be applied.
00174     \param scale The scaling factor.
00175     \param phase The phase offset.
00176     \return The complex signal amplitude, between (-32767, -32767) and (32767, 32767).
00177 */
00178 complexi32_t dds_complexi32_mod(uint32_t *phase_acc, int32_t phase_rate, int16_t scale, int32_t phase);
00179 
00180 /*! \brief Find the phase rate equivalent to a frequency, in Hz.
00181     \param frequency The frequency, in Hz.
00182     \return The equivalent phase rate.
00183 */
00184 int32_t dds_phase_ratef(float frequency);
00185 
00186 /*! \brief Find the frequency, in Hz, equivalent to a phase rate.
00187     \param phase_rate The phase rate.
00188     \return The equivalent frequency, in Hz.
00189 */
00190 float dds_frequencyf(int32_t phase_rate);
00191 
00192 /*! \brief Find the scaling factor equivalent to a dBm0 value.
00193     \param level The signal level in dBm0.
00194     \return The equivalent scaling factor.
00195 */
00196 float dds_scaling_dbm0f(float level);
00197 
00198 /*! \brief Find the scaling factor equivalent to a dBmov value.
00199     \param level The signal level in dBmov.
00200     \return The equivalent scaling factor.
00201 */
00202 float dds_scaling_dbovf(float level);
00203 
00204 /*! \brief Advance the phase, without returning any new signal sample.
00205     \param phase_acc A pointer to a phase accumulator value.
00206     \param phase_rate The phase increment to be applied.
00207 */
00208 void dds_advancef(uint32_t *phase_acc, int32_t phase_rate);
00209 
00210 /*! \brief Generate a floating point tone sample.
00211     \param phase_acc A pointer to a phase accumulator value.
00212     \param phase_rate The phase increment to be applied.
00213     \return The signal amplitude, between -1.0 and 1.0.
00214 */
00215 float ddsf(uint32_t *phase_acc, int32_t phase_rate);
00216 
00217 /*! \brief Lookup the floating point value of a specified phase.
00218     \param phase The phase accumulator value to be looked up.
00219     \return The signal amplitude, between -1.0 and 1.0.
00220 */
00221 float dds_lookupf(uint32_t phase);
00222 
00223 /*! \brief Generate a floating point tone sample, with modulation.
00224     \param phase_acc A pointer to a phase accumulator value.
00225     \param phase_rate The phase increment to be applied.
00226     \param scale The scaling factor.
00227     \param phase The phase offset.
00228     \return The signal amplitude, between -1.0 and 1.0.
00229 */
00230 float dds_modf(uint32_t *phase_acc, int32_t phase_rate, float scale, int32_t phase);
00231 
00232 /*! \brief Generate a complex floating point tone sample.
00233     \param phase_acc A pointer to a phase accumulator value.
00234     \param phase_rate The phase increment to be applied.
00235     \return The complex signal amplitude, between (-1.0, -1.0) and (1.0, 1.0).
00236 */
00237 complexf_t dds_complexf(uint32_t *phase_acc, int32_t phase_rate);
00238 
00239 /*! \brief Lookup the complex value of a specified phase.
00240     \param phase The phase accumulator value to be looked up.
00241     \return The complex signal amplitude, between (-1.0, -1.0) and (1.0, 1.0).
00242 */
00243 complexf_t dds_lookup_complexf(uint32_t phase_acc);
00244 
00245 /*! \brief Generate a complex floating point tone sample, with modulation.
00246     \param phase_acc A pointer to a phase accumulator value.
00247     \param phase_rate The phase increment to be applied.
00248     \param scale The scaling factor.
00249     \param phase The phase offset.
00250     \return The complex signal amplitude, between (-1.0, -1.0) and (1.0, 1.0).
00251 */
00252 complexf_t dds_complex_modf(uint32_t *phase_acc, int32_t phase_rate, float scale, int32_t phase);
00253 
00254 #if defined(__cplusplus)
00255 }
00256 #endif
00257 
00258 #endif
00259 /*- End of file ------------------------------------------------------------*/

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