fix build, sync with our working copy.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5279 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2007-06-07 03:50:08 +00:00
parent d90df53666
commit d46578dbcf
4 changed files with 26 additions and 28 deletions

View File

@ -78,7 +78,7 @@ extern "C" {
#define TELETONE_MAX_TONES 6 #define TELETONE_MAX_TONES 6
#define TELETONE_TONE_RANGE 127 #define TELETONE_TONE_RANGE 127
typedef float teletone_process_t; typedef double teletone_process_t;
/*! \file libteletone.h /*! \file libteletone.h
\brief Top level include file \brief Top level include file

View File

@ -144,17 +144,17 @@ void teletone_dtmf_detect_init (teletone_dtmf_detect_state_t *dtmf_detect_state,
dtmf_detect_state->hit1 = dtmf_detect_state->hit2 = 0; dtmf_detect_state->hit1 = dtmf_detect_state->hit2 = 0;
for (i = 0; i < GRID_FACTOR; i++) { for (i = 0; i < GRID_FACTOR; i++) {
theta = (teletone_process_t)(M_TWO_PI*(dtmf_row[i]/(teletone_process_t)sample_rate)); theta = M_TWO_PI*(dtmf_row[i]/(teletone_process_t)sample_rate);
dtmf_detect_row[i].fac = (teletone_process_t)(2.0*cos(theta)); dtmf_detect_row[i].fac = 2.0*cos(theta);
theta = (teletone_process_t)(M_TWO_PI*(dtmf_col[i]/(teletone_process_t)sample_rate)); theta = M_TWO_PI*(dtmf_col[i]/(teletone_process_t)sample_rate);
dtmf_detect_col[i].fac = (teletone_process_t)(2.0*cos(theta)); dtmf_detect_col[i].fac = 2.0*cos(theta);
theta = (teletone_process_t)(M_TWO_PI*(dtmf_row[i]*2.0/(teletone_process_t)sample_rate)); theta = M_TWO_PI*(dtmf_row[i]*2.0/(teletone_process_t)sample_rate);
dtmf_detect_row_2nd[i].fac = (teletone_process_t)(2.0*cos(theta)); dtmf_detect_row_2nd[i].fac = 2.0*cos(theta);
theta = (teletone_process_t)(M_TWO_PI*(dtmf_col[i]*2.0/(teletone_process_t)sample_rate)); theta = M_TWO_PI*(dtmf_col[i]*2.0/(teletone_process_t)sample_rate);
dtmf_detect_col_2nd[i].fac = (teletone_process_t)(2.0*cos(theta)); dtmf_detect_col_2nd[i].fac = 2.0*cos(theta);
goertzel_init (&dtmf_detect_state->row_out[i], &dtmf_detect_row[i]); goertzel_init (&dtmf_detect_state->row_out[i], &dtmf_detect_row[i]);
goertzel_init (&dtmf_detect_state->col_out[i], &dtmf_detect_col[i]); goertzel_init (&dtmf_detect_state->col_out[i], &dtmf_detect_col[i]);
@ -200,8 +200,8 @@ void teletone_multi_tone_init(teletone_multi_tone_t *mt, teletone_tone_map_t *ma
break; break;
} }
mt->tone_count++; mt->tone_count++;
theta = (teletone_process_t)(M_TWO_PI*(map->freqs[x]/(teletone_process_t)mt->sample_rate)); theta = M_TWO_PI*(map->freqs[x]/(teletone_process_t)mt->sample_rate);
mt->tdd[x].fac = (teletone_process_t)(2.0 * cos(theta)); mt->tdd[x].fac = 2.0 * cos(theta);
goertzel_init (&mt->gs[x], &mt->tdd[x]); goertzel_init (&mt->gs[x], &mt->tdd[x]);
goertzel_init (&mt->gs2[x], &mt->tdd[x]); goertzel_init (&mt->gs2[x], &mt->tdd[x]);
} }

View File

@ -211,7 +211,7 @@ int teletone_mux_tones(teletone_generation_session_t *ts, teletone_tone_map_t *m
int wait = 0; int wait = 0;
int32_t sample; int32_t sample;
int32_t dc = 0; int32_t dc = 0;
teletone_process_t vol = ts->volume; float vol = ts->volume;
ts->samples = 0; ts->samples = 0;
memset(tones, 0, sizeof(tones[0]) * TELETONE_MAX_TONES); memset(tones, 0, sizeof(tones[0]) * TELETONE_MAX_TONES);
duration = (ts->tmp_duration > -1) ? ts->tmp_duration : ts->duration; duration = (ts->tmp_duration > -1) ? ts->tmp_duration : ts->duration;
@ -234,7 +234,7 @@ int teletone_mux_tones(teletone_generation_session_t *ts, teletone_tone_map_t *m
for (ts->samples = 0; ts->samples < ts->datalen && ts->samples < duration; ts->samples++) { for (ts->samples = 0; ts->samples < ts->datalen && ts->samples < duration; ts->samples++) {
if (ts->decay_direction && ++dc >= ts->decay_step) { if (ts->decay_direction && ++dc >= ts->decay_step) {
teletone_process_t nvol = vol + ts->decay_direction * ts->decay_factor; float nvol = vol + ts->decay_direction * ts->decay_factor;
int j; int j;
if (nvol <= TELETONE_VOL_DB_MAX && nvol >= TELETONE_VOL_DB_MIN) { if (nvol <= TELETONE_VOL_DB_MAX && nvol >= TELETONE_VOL_DB_MIN) {
@ -355,7 +355,7 @@ int teletone_run(teletone_generation_session_t *ts, char *cmd)
break; break;
case 'v': case 'v':
{ {
teletone_process_t vol = (teletone_process_t)atof(cur + 2); float vol = (float)atof(cur + 2);
if (vol <= TELETONE_VOL_DB_MAX && vol >= TELETONE_VOL_DB_MIN) { if (vol <= TELETONE_VOL_DB_MAX && vol >= TELETONE_VOL_DB_MIN) {
ts->volume = vol; ts->volume = vol;
} }
@ -370,7 +370,7 @@ int teletone_run(teletone_generation_session_t *ts, char *cmd)
ts->decay_direction = 1; ts->decay_direction = 1;
break; break;
case '+': case '+':
ts->decay_factor = (teletone_process_t)atof(cur + 2); ts->decay_factor = (float)atof(cur + 2);
break; break;
case 'w': case 'w':
ts->wait = atoi(cur + 2) * (ts->rate / 1000); ts->wait = atoi(cur + 2) * (ts->rate / 1000);
@ -419,7 +419,7 @@ int teletone_run(teletone_generation_session_t *ts, char *cmd)
ts->tmp_wait = atoi(p) * (ts->rate / 1000); ts->tmp_wait = atoi(p) * (ts->rate / 1000);
i++; i++;
} else { } else {
mymap.freqs[i++ - 2] = (teletone_process_t)atof(p); mymap.freqs[i++ - 2] = atof(p);
} }
p = next; p = next;

View File

@ -79,12 +79,10 @@ extern "C" {
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#ifdef WIN32
#ifdef _MSC_VER #ifdef _MSC_VER
#ifndef __inline__ #ifndef __inline__
#define __inline__ __inline #define __inline__ __inline
#endif #endif
#endif
typedef unsigned __int64 uint64_t; typedef unsigned __int64 uint64_t;
typedef unsigned __int32 uint32_t; typedef unsigned __int32 uint32_t;
typedef unsigned __int16 uint16_t; typedef unsigned __int16 uint16_t;
@ -153,24 +151,24 @@ static __inline__ int16_t teletone_dds_modulate_sample(teletone_dds_state_t *dds
return (int16_t) (sample * dds->scale_factor >> 15); return (int16_t) (sample * dds->scale_factor >> 15);
} }
static __inline__ void teletone_dds_state_set_tone(teletone_dds_state_t *dds, teletone_process_t tone, uint32_t rate, teletone_process_t tx_level) static __inline__ void teletone_dds_state_set_tx_level(teletone_dds_state_t *dds, float tx_level)
{
dds->scale_factor = (int) (powf(10.0f, (tx_level - DBM0_MAX_POWER) / 20.0f) * (32767.0f * 1.414214f));
}
static __inline__ void teletone_dds_state_set_tone(teletone_dds_state_t *dds, teletone_process_t tone, uint32_t rate, float tx_level)
{ {
dds->phase_accumulator = 0; dds->phase_accumulator = 0;
dds->phase_rate = (int32_t) ((tone * MAX_PHASE_ACCUMULATOR) / rate); dds->phase_rate = (int32_t) ((tone * MAX_PHASE_ACCUMULATOR) / rate);
if (dds->tx_level != tx_level || !dds->scale_factor) { if (dds->tx_level != tx_level || !dds->scale_factor) {
dds->scale_factor = (int) (powf(10.0f, (tx_level - DBM0_MAX_POWER) / 20.0f) * (32767.0f * 1.414214f)); teletone_dds_state_set_tx_level(dds, tx_level);
} }
dds->tx_level = tx_level; dds->tx_level = tx_level;
} }
static __inline__ void teletone_dds_state_set_tx_level(teletone_dds_state_t *dds, teletone_process_t tx_level)
{
dds->scale_factor = (int) (powf(10.0f, (tx_level - DBM0_MAX_POWER) / 20.0f) * (32767.0f * 1.414214f));
}
/*! \file libteletone_generate.h /*! \file libteletone_generate.h
@ -204,13 +202,13 @@ struct teletone_generation_session {
/*! Number of loops to repeat the entire set of instructions*/ /*! Number of loops to repeat the entire set of instructions*/
int LOOPS; int LOOPS;
/*! Number to mutiply total samples by to determine when to begin ascent or decent e.g. 0=beginning 4=(last 25%) */ /*! Number to mutiply total samples by to determine when to begin ascent or decent e.g. 0=beginning 4=(last 25%) */
teletone_process_t decay_factor; float decay_factor;
/*! Direction to perform volume increase/decrease 1/-1*/ /*! Direction to perform volume increase/decrease 1/-1*/
int decay_direction; int decay_direction;
/*! Number of samples between increase/decrease of volume */ /*! Number of samples between increase/decrease of volume */
int decay_step; int decay_step;
/*! Volume factor of the tone */ /*! Volume factor of the tone */
teletone_process_t volume; float volume;
/*! Debug on/off */ /*! Debug on/off */
int debug; int debug;
/*! FILE stream to write debug data to */ /*! FILE stream to write debug data to */