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 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.15 2007/08/29 12:44:36 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 Generate an integer tone sample, with modulation.
00089     \param phase_acc A pointer to a phase accumulator value.
00090     \param phase_rate The phase increment to be applied.
00091     \param scale The scaling factor.
00092     \param phase The phase offset.
00093     \return The signal amplitude.
00094 */
00095 int16_t dds_mod(uint32_t *phase_acc, int32_t phase_rate, int scale, int32_t phase);
00096 
00097 /*! \brief Generate a complex integer tone sample.
00098     \param phase_acc A pointer to a phase accumulator value.
00099     \param phase_rate The phase increment to be applied.
00100     \return The complex signal amplitude, between -32767 and 32767.
00101 */
00102 complexi_t dds_complexi(uint32_t *phase_acc, int32_t phase_rate);
00103 
00104 /*! \brief Generate a complex integer tone sample, with modulation.
00105     \param phase_acc A pointer to a phase accumulator value.
00106     \param phase_rate The phase increment to be applied.
00107     \param scale The scaling factor.
00108     \param phase The phase offset.
00109     \return The complex signal amplitude.
00110 */
00111 complexi_t dds_complexi_mod(uint32_t *phase_acc, int32_t phase_rate, int scale, int32_t phase);
00112 
00113 /*! \brief Find the phase rate equivalent to a frequency, in Hz.
00114     \param frequency The frequency, in Hz.
00115     \return The equivalent phase rate.
00116 */
00117 int32_t dds_phase_ratef(float frequency);
00118 
00119 /*! \brief Find the frequency, in Hz, equivalent to a phase rate.
00120     \param phase_rate The phase rate.
00121     \return The equivalent frequency, in Hz.
00122 */
00123 float dds_frequencyf(int32_t phase_rate);
00124 
00125 /*! \brief Find the scaling factor equivalent to a dBm0 value.
00126     \param level The signal level in dBm0.
00127     \return The equivalent scaling factor.
00128 */
00129 float dds_scaling_dbm0f(float level);
00130 
00131 /*! \brief Find the scaling factor equivalent to a dBmov value.
00132     \param level The signal level in dBmov.
00133     \return The equivalent scaling factor.
00134 */
00135 float dds_scaling_dbovf(float level);
00136 
00137 /*! \brief Advance the phase, without returning any new signal sample.
00138     \param phase_acc A pointer to a phase accumulator value.
00139     \param phase_rate The phase increment to be applied.
00140 */
00141 void dds_advancef(uint32_t *phase_acc, int32_t phase_rate);
00142 
00143 /*! \brief Generate a floating point tone sample.
00144     \param phase_acc A pointer to a phase accumulator value.
00145     \param phase_rate The phase increment to be applied.
00146     \return The signal amplitude, between -32767 and 32767.
00147 */
00148 float ddsf(uint32_t *phase_acc, int32_t phase_rate);
00149 
00150 /*! \brief Generate a floating point tone sample, with modulation.
00151     \param phase_acc A pointer to a phase accumulator value.
00152     \param phase_rate The phase increment to be applied.
00153     \param scale The scaling factor.
00154     \param phase The phase offset.
00155     \return The signal amplitude.
00156 */
00157 float dds_modf(uint32_t *phase_acc, int32_t phase_rate, float scale, int32_t phase);
00158 
00159 /*! \brief Generate a complex floating point tone sample.
00160     \param phase_acc A pointer to a phase accumulator value.
00161     \param phase_rate The phase increment to be applied.
00162     \return The complex signal amplitude, between -32767 and 32767.
00163 */
00164 complexf_t dds_complexf(uint32_t *phase_acc, int32_t phase_rate);
00165 
00166 /*! \brief Generate a complex floating point tone sample, with modulation.
00167     \param phase_acc A pointer to a phase accumulator value.
00168     \param phase_rate The phase increment to be applied.
00169     \param scale The scaling factor.
00170     \param phase The phase offset.
00171     \return The complex signal amplitude.
00172 */
00173 complexf_t dds_complex_modf(uint32_t *phase_acc, int32_t phase_rate, float scale, int32_t phase);
00174 
00175 #if defined(__cplusplus)
00176 }
00177 #endif
00178 
00179 #endif
00180 /*- End of file ------------------------------------------------------------*/

Generated on Fri Sep 7 23:31:47 2007 for libspandsp by  doxygen 1.5.2