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.18 2008/04/17 14:27:00 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, int scale, int32_t phase);
00102 
00103 /*! \brief Generate a complex integer tone sample.
00104     \param phase_acc A pointer to a phase accumulator value.
00105     \param phase_rate The phase increment to be applied.
00106     \return The complex signal amplitude, between (-32767, -32767) and (32767, 32767).
00107 */
00108 complexi_t dds_complexi(uint32_t *phase_acc, int32_t phase_rate);
00109 
00110 /*! \brief Lookup the complex integer value of a specified phase.
00111     \param phase The phase accumulator value to be looked up.
00112     \return The complex signal amplitude, between (-32767, -32767) and (32767, 32767).
00113 */
00114 complexi_t dds_lookup_complexi(uint32_t phase);
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, int scale, int32_t phase);
00124 
00125 /*! \brief Find the phase rate equivalent to a frequency, in Hz.
00126     \param frequency The frequency, in Hz.
00127     \return The equivalent phase rate.
00128 */
00129 int32_t dds_phase_ratef(float frequency);
00130 
00131 /*! \brief Find the frequency, in Hz, equivalent to a phase rate.
00132     \param phase_rate The phase rate.
00133     \return The equivalent frequency, in Hz.
00134 */
00135 float dds_frequencyf(int32_t phase_rate);
00136 
00137 /*! \brief Find the scaling factor equivalent to a dBm0 value.
00138     \param level The signal level in dBm0.
00139     \return The equivalent scaling factor.
00140 */
00141 float dds_scaling_dbm0f(float level);
00142 
00143 /*! \brief Find the scaling factor equivalent to a dBmov value.
00144     \param level The signal level in dBmov.
00145     \return The equivalent scaling factor.
00146 */
00147 float dds_scaling_dbovf(float level);
00148 
00149 /*! \brief Advance the phase, without returning any new signal sample.
00150     \param phase_acc A pointer to a phase accumulator value.
00151     \param phase_rate The phase increment to be applied.
00152 */
00153 void dds_advancef(uint32_t *phase_acc, int32_t phase_rate);
00154 
00155 /*! \brief Generate a floating point tone sample.
00156     \param phase_acc A pointer to a phase accumulator value.
00157     \param phase_rate The phase increment to be applied.
00158     \return The signal amplitude, between -1.0 and 1.0.
00159 */
00160 float ddsf(uint32_t *phase_acc, int32_t phase_rate);
00161 
00162 /*! \brief Lookup the floating point value of a specified phase.
00163     \param phase The phase accumulator value to be looked up.
00164     \return The signal amplitude, between -1.0 and 1.0.
00165 */
00166 float dds_lookupf(uint32_t phase);
00167 
00168 /*! \brief Generate a floating point tone sample, with modulation.
00169     \param phase_acc A pointer to a phase accumulator value.
00170     \param phase_rate The phase increment to be applied.
00171     \param scale The scaling factor.
00172     \param phase The phase offset.
00173     \return The signal amplitude, between -1.0 and 1.0.
00174 */
00175 float dds_modf(uint32_t *phase_acc, int32_t phase_rate, float scale, int32_t phase);
00176 
00177 /*! \brief Generate a complex floating point tone sample.
00178     \param phase_acc A pointer to a phase accumulator value.
00179     \param phase_rate The phase increment to be applied.
00180     \return The complex signal amplitude, between (-1.0, -1.0) and (1.0, 1.0).
00181 */
00182 complexf_t dds_complexf(uint32_t *phase_acc, int32_t phase_rate);
00183 
00184 /*! \brief Lookup the complex value of a specified phase.
00185     \param phase The phase accumulator value to be looked up.
00186     \return The complex signal amplitude, between (-1.0, -1.0) and (1.0, 1.0).
00187 */
00188 complexf_t dds_lookup_complexf(uint32_t phase_acc);
00189 
00190 /*! \brief Generate a complex floating point tone sample, with modulation.
00191     \param phase_acc A pointer to a phase accumulator value.
00192     \param phase_rate The phase increment to be applied.
00193     \param scale The scaling factor.
00194     \param phase The phase offset.
00195     \return The complex signal amplitude, between (-1.0, -1.0) and (1.0, 1.0).
00196 */
00197 complexf_t dds_complex_modf(uint32_t *phase_acc, int32_t phase_rate, float scale, int32_t phase);
00198 
00199 #if defined(__cplusplus)
00200 }
00201 #endif
00202 
00203 #endif
00204 /*- End of file ------------------------------------------------------------*/

Generated on Thu Feb 26 01:19:43 2009 for libspandsp by  doxygen 1.5.8