Mercurial > hg > audiostuff
comparison spandsp-0.0.6pre17/src/spandsp/dds.h @ 4:26cd8f1ef0b1
import spandsp-0.0.6pre17
| author | Peter Meerwald <pmeerw@cosy.sbg.ac.at> |
|---|---|
| date | Fri, 25 Jun 2010 15:50:58 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 3:c6c5a16ce2f2 | 4:26cd8f1ef0b1 |
|---|---|
| 1 /* | |
| 2 * SpanDSP - a series of DSP components for telephony | |
| 3 * | |
| 4 * dds.h | |
| 5 * | |
| 6 * Written by Steve Underwood <steveu@coppice.org> | |
| 7 * | |
| 8 * Copyright (C) 2003 Steve Underwood | |
| 9 * | |
| 10 * All rights reserved. | |
| 11 * | |
| 12 * This program is free software; you can redistribute it and/or modify | |
| 13 * it under the terms of the GNU Lesser General Public License version 2.1, | |
| 14 * as published by the Free Software Foundation. | |
| 15 * | |
| 16 * This program is distributed in the hope that it will be useful, | |
| 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 19 * GNU Lesser General Public License for more details. | |
| 20 * | |
| 21 * You should have received a copy of the GNU Lesser General Public | |
| 22 * License along with this program; if not, write to the Free Software | |
| 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
| 24 * | |
| 25 * $Id: dds.h,v 1.23 2009/01/31 08:48:11 steveu Exp $ | |
| 26 */ | |
| 27 | |
| 28 /*! \file */ | |
| 29 | |
| 30 #if !defined(_SPANDSP_DDS_H_) | |
| 31 #define _SPANDSP_DDS_H_ | |
| 32 | |
| 33 #if defined(__cplusplus) | |
| 34 extern "C" | |
| 35 { | |
| 36 #endif | |
| 37 | |
| 38 /*! \brief Find the phase rate value to achieve a particular frequency. | |
| 39 \param frequency The desired frequency, in Hz. | |
| 40 \return The phase rate which while achieve the desired frequency. | |
| 41 */ | |
| 42 SPAN_DECLARE(int32_t) dds_phase_rate(float frequency); | |
| 43 | |
| 44 /*! \brief Find the frequency, in Hz, equivalent to a phase rate. | |
| 45 \param phase_rate The phase rate. | |
| 46 \return The equivalent frequency, in Hz. | |
| 47 */ | |
| 48 SPAN_DECLARE(float) dds_frequency(int32_t phase_rate); | |
| 49 | |
| 50 /*! \brief Find the scaling factor needed to achieve a specified level in dBm0. | |
| 51 \param level The desired signal level, in dBm0. | |
| 52 \return The scaling factor. | |
| 53 */ | |
| 54 SPAN_DECLARE(int16_t) dds_scaling_dbm0(float level); | |
| 55 | |
| 56 /*! \brief Find the scaling factor needed to achieve a specified level in dBmov. | |
| 57 \param level The desired signal level, in dBmov. | |
| 58 \return The scaling factor. | |
| 59 */ | |
| 60 SPAN_DECLARE(int16_t) dds_scaling_dbov(float level); | |
| 61 | |
| 62 /*! \brief Find the amplitude for a particular phase. | |
| 63 \param phase The desired phase 32 bit phase. | |
| 64 \return The signal amplitude. | |
| 65 */ | |
| 66 SPAN_DECLARE(int16_t) dds_lookup(uint32_t phase); | |
| 67 | |
| 68 /*! \brief Find the amplitude for a particular phase offset from an accumulated phase. | |
| 69 \param phase_acc The accumulated phase. | |
| 70 \param phase_offset The phase offset. | |
| 71 \return The signal amplitude. | |
| 72 */ | |
| 73 SPAN_DECLARE(int16_t) dds_offset(uint32_t phase_acc, int32_t phase_offset); | |
| 74 | |
| 75 /*! \brief Advance the phase, without returning any new signal sample. | |
| 76 \param phase_acc A pointer to a phase accumulator value. | |
| 77 \param phase_rate The phase increment to be applied. | |
| 78 */ | |
| 79 SPAN_DECLARE(void) dds_advance(uint32_t *phase_acc, int32_t phase_rate); | |
| 80 | |
| 81 /*! \brief Generate an integer tone sample. | |
| 82 \param phase_acc A pointer to a phase accumulator value. | |
| 83 \param phase_rate The phase increment to be applied. | |
| 84 \return The signal amplitude, between -32767 and 32767. | |
| 85 */ | |
| 86 SPAN_DECLARE(int16_t) dds(uint32_t *phase_acc, int32_t phase_rate); | |
| 87 | |
| 88 /*! \brief Lookup the integer value of a specified phase. | |
| 89 \param phase The phase accumulator value to be looked up. | |
| 90 \return The signal amplitude, between -32767 and 32767. | |
| 91 */ | |
| 92 SPAN_DECLARE(int16_t) dds_lookup(uint32_t phase); | |
| 93 | |
| 94 /*! \brief Generate an integer tone sample, with modulation. | |
| 95 \param phase_acc A pointer to a phase accumulator value. | |
| 96 \param phase_rate The phase increment to be applied. | |
| 97 \param scale The scaling factor. | |
| 98 \param phase The phase offset. | |
| 99 \return The signal amplitude, between -32767 and 32767. | |
| 100 */ | |
| 101 SPAN_DECLARE(int16_t) dds_mod(uint32_t *phase_acc, int32_t phase_rate, int16_t scale, int32_t phase); | |
| 102 | |
| 103 /*! \brief Lookup the complex integer value of a specified phase. | |
| 104 \param phase The phase accumulator value to be looked up. | |
| 105 \return The complex signal amplitude, between (-32767, -32767) and (32767, 32767). | |
| 106 */ | |
| 107 SPAN_DECLARE(complexi_t) dds_lookup_complexi(uint32_t phase); | |
| 108 | |
| 109 /*! \brief Generate a complex integer tone sample. | |
| 110 \param phase_acc A pointer to a phase accumulator value. | |
| 111 \param phase_rate The phase increment to be applied. | |
| 112 \return The complex signal amplitude, between (-32767, -32767) and (32767, 32767). | |
| 113 */ | |
| 114 SPAN_DECLARE(complexi_t) dds_complexi(uint32_t *phase_acc, int32_t phase_rate); | |
| 115 | |
| 116 /*! \brief Generate a complex integer tone sample, with modulation. | |
| 117 \param phase_acc A pointer to a phase accumulator value. | |
| 118 \param phase_rate The phase increment to be applied. | |
| 119 \param scale The scaling factor. | |
| 120 \param phase The phase offset. | |
| 121 \return The complex signal amplitude, between (-32767, -32767) and (32767, 32767). | |
| 122 */ | |
| 123 SPAN_DECLARE(complexi_t) dds_complexi_mod(uint32_t *phase_acc, int32_t phase_rate, int16_t scale, int32_t phase); | |
| 124 | |
| 125 /*! \brief Generate a complex 16 bit integer tone sample. | |
| 126 \param phase_acc A pointer to a phase accumulator value. | |
| 127 \param phase_rate The phase increment to be applied. | |
| 128 \return The complex signal amplitude, between (-32767, -32767) and (32767, 32767). | |
| 129 */ | |
| 130 SPAN_DECLARE(complexi16_t) dds_lookup_complexi16(uint32_t phase); | |
| 131 | |
| 132 /*! \brief Generate a complex 16 bit integer tone sample. | |
| 133 \param phase_acc A pointer to a phase accumulator value. | |
| 134 \param phase_rate The phase increment to be applied. | |
| 135 \return The complex signal amplitude, between (-32767, -32767) and (32767, 32767). | |
| 136 */ | |
| 137 SPAN_DECLARE(complexi16_t) dds_complexi16(uint32_t *phase_acc, int32_t phase_rate); | |
| 138 | |
| 139 /*! \brief Generate a complex 16bit integer tone sample, with modulation. | |
| 140 \param phase_acc A pointer to a phase accumulator value. | |
| 141 \param phase_rate The phase increment to be applied. | |
| 142 \param scale The scaling factor. | |
| 143 \param phase The phase offset. | |
| 144 \return The complex signal amplitude, between (-32767, -32767) and (32767, 32767). | |
| 145 */ | |
| 146 SPAN_DECLARE(complexi16_t) dds_complexi16_mod(uint32_t *phase_acc, int32_t phase_rate, int16_t scale, int32_t phase); | |
| 147 | |
| 148 /*! \brief Generate a complex 32 bit integer tone sample, with modulation. | |
| 149 \param phase_acc A pointer to a phase accumulator value. | |
| 150 \param phase_rate The phase increment to be applied. | |
| 151 \param scale The scaling factor. | |
| 152 \param phase The phase offset. | |
| 153 \return The complex signal amplitude, between (-32767, -32767) and (32767, 32767). | |
| 154 */ | |
| 155 SPAN_DECLARE(complexi32_t) dds_complexi32_mod(uint32_t *phase_acc, int32_t phase_rate, int16_t scale, int32_t phase); | |
| 156 | |
| 157 /*! \brief Generate a complex 32 bit integer tone sample. | |
| 158 \param phase_acc A pointer to a phase accumulator value. | |
| 159 \param phase_rate The phase increment to be applied. | |
| 160 \return The complex signal amplitude, between (-32767, -32767) and (32767, 32767). | |
| 161 */ | |
| 162 SPAN_DECLARE(complexi32_t) dds_lookup_complexi32(uint32_t phase); | |
| 163 | |
| 164 /*! \brief Generate a complex 32 bit integer tone sample. | |
| 165 \param phase_acc A pointer to a phase accumulator value. | |
| 166 \param phase_rate The phase increment to be applied. | |
| 167 \return The complex signal amplitude, between (-32767, -32767) and (32767, 32767). | |
| 168 */ | |
| 169 SPAN_DECLARE(complexi32_t) dds_complexi32(uint32_t *phase_acc, int32_t phase_rate); | |
| 170 | |
| 171 /*! \brief Generate a complex 32 bit integer tone sample, with modulation. | |
| 172 \param phase_acc A pointer to a phase accumulator value. | |
| 173 \param phase_rate The phase increment to be applied. | |
| 174 \param scale The scaling factor. | |
| 175 \param phase The phase offset. | |
| 176 \return The complex signal amplitude, between (-32767, -32767) and (32767, 32767). | |
| 177 */ | |
| 178 SPAN_DECLARE(complexi32_t) dds_complexi32_mod(uint32_t *phase_acc, int32_t phase_rate, int16_t scale, int32_t phase); | |
| 179 | |
| 180 /*! \brief Find the phase rate equivalent to a frequency, in Hz. | |
| 181 \param frequency The frequency, in Hz. | |
| 182 \return The equivalent phase rate. | |
| 183 */ | |
| 184 SPAN_DECLARE(int32_t) dds_phase_ratef(float frequency); | |
| 185 | |
| 186 /*! \brief Find the frequency, in Hz, equivalent to a phase rate. | |
| 187 \param phase_rate The phase rate. | |
| 188 \return The equivalent frequency, in Hz. | |
| 189 */ | |
| 190 SPAN_DECLARE(float) dds_frequencyf(int32_t phase_rate); | |
| 191 | |
| 192 /*! \brief Find the scaling factor equivalent to a dBm0 value. | |
| 193 \param level The signal level in dBm0. | |
| 194 \return The equivalent scaling factor. | |
| 195 */ | |
| 196 SPAN_DECLARE(float) dds_scaling_dbm0f(float level); | |
| 197 | |
| 198 /*! \brief Find the scaling factor equivalent to a dBmov value. | |
| 199 \param level The signal level in dBmov. | |
| 200 \return The equivalent scaling factor. | |
| 201 */ | |
| 202 SPAN_DECLARE(float) dds_scaling_dbovf(float level); | |
| 203 | |
| 204 /*! \brief Advance the phase, without returning any new signal sample. | |
| 205 \param phase_acc A pointer to a phase accumulator value. | |
| 206 \param phase_rate The phase increment to be applied. | |
| 207 */ | |
| 208 SPAN_DECLARE(void) dds_advancef(uint32_t *phase_acc, int32_t phase_rate); | |
| 209 | |
| 210 /*! \brief Generate a floating point tone sample. | |
| 211 \param phase_acc A pointer to a phase accumulator value. | |
| 212 \param phase_rate The phase increment to be applied. | |
| 213 \return The signal amplitude, between -1.0 and 1.0. | |
| 214 */ | |
| 215 SPAN_DECLARE(float) ddsf(uint32_t *phase_acc, int32_t phase_rate); | |
| 216 | |
| 217 /*! \brief Lookup the floating point value of a specified phase. | |
| 218 \param phase The phase accumulator value to be looked up. | |
| 219 \return The signal amplitude, between -1.0 and 1.0. | |
| 220 */ | |
| 221 SPAN_DECLARE(float) dds_lookupf(uint32_t phase); | |
| 222 | |
| 223 /*! \brief Generate a floating point tone sample, with modulation. | |
| 224 \param phase_acc A pointer to a phase accumulator value. | |
| 225 \param phase_rate The phase increment to be applied. | |
| 226 \param scale The scaling factor. | |
| 227 \param phase The phase offset. | |
| 228 \return The signal amplitude, between -1.0 and 1.0. | |
| 229 */ | |
| 230 SPAN_DECLARE(float) dds_modf(uint32_t *phase_acc, int32_t phase_rate, float scale, int32_t phase); | |
| 231 | |
| 232 /*! \brief Generate a complex floating point tone sample. | |
| 233 \param phase_acc A pointer to a phase accumulator value. | |
| 234 \param phase_rate The phase increment to be applied. | |
| 235 \return The complex signal amplitude, between (-1.0, -1.0) and (1.0, 1.0). | |
| 236 */ | |
| 237 SPAN_DECLARE(complexf_t) dds_complexf(uint32_t *phase_acc, int32_t phase_rate); | |
| 238 | |
| 239 /*! \brief Lookup the complex value of a specified phase. | |
| 240 \param phase The phase accumulator value to be looked up. | |
| 241 \return The complex signal amplitude, between (-1.0, -1.0) and (1.0, 1.0). | |
| 242 */ | |
| 243 SPAN_DECLARE(complexf_t) dds_lookup_complexf(uint32_t phase_acc); | |
| 244 | |
| 245 /*! \brief Generate a complex floating point tone sample, with modulation. | |
| 246 \param phase_acc A pointer to a phase accumulator value. | |
| 247 \param phase_rate The phase increment to be applied. | |
| 248 \param scale The scaling factor. | |
| 249 \param phase The phase offset. | |
| 250 \return The complex signal amplitude, between (-1.0, -1.0) and (1.0, 1.0). | |
| 251 */ | |
| 252 SPAN_DECLARE(complexf_t) dds_complex_modf(uint32_t *phase_acc, int32_t phase_rate, float scale, int32_t phase); | |
| 253 | |
| 254 #if defined(__cplusplus) | |
| 255 } | |
| 256 #endif | |
| 257 | |
| 258 #endif | |
| 259 /*- End of file ------------------------------------------------------------*/ |
