summaryrefslogtreecommitdiff
path: root/zaptel.h
diff options
context:
space:
mode:
authorjim <jim@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2004-02-15 02:23:25 +0000
committerjim <jim@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2004-02-15 02:23:25 +0000
commitf928dbbced084622838fa6c8772833a96c66d960 (patch)
tree60f8453b95e38a5906b40f4bee6f648b7c9d02b1 /zaptel.h
parent7e8d60dcbeef0bbdb1860c4f5bb169c91d34e994 (diff)
Added support for modulation (not just two tone addition) in tonezones
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@313 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'zaptel.h')
-rwxr-xr-xzaptel.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/zaptel.h b/zaptel.h
index a45b561..aa42374 100755
--- a/zaptel.h
+++ b/zaptel.h
@@ -641,7 +641,7 @@ struct zt_tone_def { /* Structure for zone programming */
int fac2;
int init_v2_2;
int init_v3_2;
-
+ int modulate;
};
@@ -842,6 +842,7 @@ struct zt_tone_state {
int v1_2;
int v2_2;
int v3_2;
+ int modulate;
};
#ifdef CONFIG_ZAPATA_NET
@@ -1322,12 +1323,16 @@ struct zt_tone {
int tonesamples; /* How long to play this tone before
going to the next (in samples) */
struct zt_tone *next; /* Next tone in this sequence */
+
+ int modulate;
};
static inline short zt_tone_nextsample(struct zt_tone_state *ts, struct zt_tone *zt)
{
/* follow the curves, return the sum */
+ int p;
+
ts->v1_1 = ts->v2_1;
ts->v2_1 = ts->v3_1;
ts->v3_1 = (zt->fac1 * ts->v2_1 >> 15) - ts->v1_1;
@@ -1337,7 +1342,13 @@ static inline short zt_tone_nextsample(struct zt_tone_state *ts, struct zt_tone
ts->v3_2 = (zt->fac2 * ts->v2_2 >> 15) - ts->v1_2;
/* Return top 16 bits */
- return ts->v3_1 + ts->v3_2;
+ if (!ts->modulate) return ts->v3_1 + ts->v3_2;
+ /* we are modulating */
+ p = ts->v3_2 - 32768;
+ if (p < 0) p = -p;
+ p = ((p * 9) / 10) + 1;
+ return (ts->v3_1 * p) >> 15;
+
}
static inline short zt_txtone_nextsample(struct zt_chan *ss)