]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
update
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 7 Jun 2007 05:13:39 +0000 (05:13 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 7 Jun 2007 05:13:39 +0000 (05:13 +0000)
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@235 a93c3328-9c30-0410-af19-c9cd2b2d52af

libs/freetdm/conf/tones.conf
libs/freetdm/general.makefile
libs/freetdm/src/include/libteletone_generate.h
libs/freetdm/src/libteletone_generate.c

index e24ccccfcd2acea19a9a17111307997ba8664aeb..d0f27acd93c20ed9d2742944d27dfa9148843690 100644 (file)
@@ -1,14 +1,14 @@
 [us]
-generate-dial => %(1000,0,350,440)
+generate-dial => v=-7;%(1000,0,350,440)
 detect-dial => 350,440
 
-generate-ring => %(2000,4000,440,480)
+generate-ring => v=-7;%(2000,4000,440,480)
 detect-ring => 440,480
 
-generate-busy => %(500,500,480,620)
+generate-busy => v=-7;%(500,500,480,620)
 detect-busy => 480,620
 
-generate-attn => %(100,100,1400,2060,2450,2600)
+generate-attn => v=0;%(100,100,1400,2060,2450,2600)
 detect-attn => 1400,2060,2450,2600
 
 detect-fail1 => 913.8
index 5b2fcb9821350800c3da69624e49d42802c93517..b6d37774367ce8cd9286580346a97121de659276 100644 (file)
@@ -1,3 +1,3 @@
 CC=gcc 
-CC_CFLAGS += -Wall -Werror -Wextra -std=c99 -pedantic -Wno-unused-parameter 
+CC_CFLAGS += -Wall -Werror -Wextra -std=c99 -pedantic -Wno-unused-parameter
 
index 5340f767ccbacda799a3629299cc5b11c162d4f8..177c893966faff456ff33cc070985ca100fbe1f2 100644 (file)
@@ -112,12 +112,12 @@ extern float powf (float, float);
 
 #define TELETONE_VOL_DB_MAX 0
 #define TELETONE_VOL_DB_MIN -63
+#define MAX_PHASE_TONES 4
 
 struct teletone_dds_state {
-       uint32_t phase_rate;
+       uint32_t phase_rate[MAX_PHASE_TONES];
        uint32_t scale_factor;
        uint32_t phase_accumulator;
-       int16_t sample;
        teletone_process_t tx_level;
 };
 typedef struct teletone_dds_state teletone_dds_state_t;
@@ -131,11 +131,20 @@ typedef struct teletone_dds_state teletone_dds_state_t;
 
 extern int16_t TELETONE_SINES[SINE_TABLE_MAX];
 
-static __inline__ int16_t teletone_dds_modulate_sample(teletone_dds_state_t *dds)
+static __inline__ int32_t teletone_dds_phase_rate(teletone_process_t tone, uint32_t rate)
+{
+       return (int32_t) ((tone * MAX_PHASE_ACCUMULATOR) / rate);
+}
+
+static __inline__ int16_t teletone_dds_state_modulate_sample(teletone_dds_state_t *dds, uint32_t pindex)
 {
     int32_t bitmask = dds->phase_accumulator, sine_index = (bitmask >>= 23) & SINE_TABLE_LEN;
        int16_t sample;
 
+       if (pindex >= MAX_PHASE_TONES)  {
+               pindex = 0;
+       }
+
     if (bitmask & SINE_TABLE_MAX) {
         sine_index = SINE_TABLE_LEN - sine_index;
        }
@@ -146,7 +155,7 @@ static __inline__ int16_t teletone_dds_modulate_sample(teletone_dds_state_t *dds
                sample *= -1;
        }
 
-       dds->phase_accumulator += dds->phase_rate;
+       dds->phase_accumulator += dds->phase_rate[pindex];
 
     return (int16_t) (sample * dds->scale_factor >> 15);
 }
@@ -154,19 +163,22 @@ static __inline__ int16_t teletone_dds_modulate_sample(teletone_dds_state_t *dds
 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));
+       dds->tx_level = tx_level;
 }
 
-static __inline__ void teletone_dds_state_set_tone(teletone_dds_state_t *dds, teletone_process_t tone, uint32_t rate, float tx_level)
+static __inline__ void teletone_dds_state_reset_accum(teletone_dds_state_t *dds)
 {
        dds->phase_accumulator = 0;
-       dds->phase_rate = (int32_t) ((tone * MAX_PHASE_ACCUMULATOR) / rate);
-       
+}
 
-       if (dds->tx_level != tx_level || !dds->scale_factor) {
-               teletone_dds_state_set_tx_level(dds, tx_level);
+static __inline__ int teletone_dds_state_set_tone(teletone_dds_state_t *dds, teletone_process_t tone, uint32_t rate, uint32_t pindex)
+{
+       if (pindex < MAX_PHASE_TONES)  {
+               dds->phase_rate[pindex] = teletone_dds_phase_rate(tone, rate);
+               return 0;
        }
        
-       dds->tx_level = tx_level;
+       return -1;
 }
 
 
index bb904b2d68571d39d79cb9ad58670d25054b3a2d..2804f0a9206785ee97dd3d422b7313d17d823a9e 100644 (file)
@@ -219,7 +219,8 @@ int teletone_mux_tones(teletone_generation_session_t *ts, teletone_tone_map_t *m
 
        if (map->freqs[0] > 0) {
                for (freqlen = 0; map->freqs[freqlen] && freqlen < TELETONE_MAX_TONES; freqlen++) {
-                       teletone_dds_state_set_tone(&tones[freqlen], map->freqs[freqlen], ts->rate, vol);
+                       teletone_dds_state_set_tone(&tones[freqlen], map->freqs[freqlen], ts->rate, 0);
+                       teletone_dds_state_set_tx_level(&tones[freqlen], vol);
                }
        
                if (ts->channels > 1) {
@@ -249,7 +250,7 @@ int teletone_mux_tones(teletone_generation_session_t *ts, teletone_tone_map_t *m
                        sample = 128;
 
                        for (i = 0; i < freqlen; i++) {
-                               int32_t s = teletone_dds_modulate_sample(&tones[i]);
+                               int32_t s = teletone_dds_state_modulate_sample(&tones[i], 0);
                                sample += s;
                        }
                        sample /= freqlen;