Index: indications.c =================================================================== RCS file: /usr/cvsroot/asterisk/indications.c,v retrieving revision 1.5 diff -u -r1.5 indications.c --- indications.c 13 Aug 2003 15:25:16 -0000 1.5 +++ indications.c 5 Jan 2004 13:06:36 -0000 @@ -14,6 +14,8 @@ * Each element has two frequencies, which are mixed together and a * duration. For silence both frequencies can be set to 0. * The playtones can be given as a comma seperated string. + * + * Mixing can be by summing, or modulation (multiplication) */ #include @@ -31,6 +33,7 @@ int freq1; int freq2; int duration; + int modulate; }; struct playtones_def { @@ -103,7 +106,15 @@ pi = &ps->items[ps->npos]; for (x=0;xdata[x] = ps->vol * ( + if (pi->modulate) + /* Modulate 1st tone with 2nd, to 90% modulation depth */ + ps->data[x] = ps->vol * 2 * ( + sin((pi->freq1 * 2.0 * M_PI / 8000.0) * (ps->pos + x)) * + (0.9 * fabs(sin((pi->freq2 * 2.0 * M_PI / 8000.0) * (ps->pos + x))) + 0.1) + ); + else + /* Add 2 tones together */ + ps->data[x] = ps->vol * ( sin((pi->freq1 * 2.0 * M_PI / 8000.0) * (ps->pos + x)) + sin((pi->freq2 * 2.0 * M_PI / 8000.0) * (ps->pos + x)) ); @@ -157,7 +168,7 @@ separator = ","; s = strsep(&stringp,separator); while(s && *s) { - int freq1, freq2, time; + int freq1, freq2, time, modulate=0; if (s[0]=='!') s++; @@ -168,6 +179,13 @@ } else if (sscanf(s, "%d+%d", &freq1, &freq2) == 2) { /* f1+f2 format */ time = 0; + } else if (sscanf(s, "%d*%d/%d", &freq1, &freq2, &time) == 3) { + /* f1*f2/time format */ + modulate = 1; + } else if (sscanf(s, "%d*%d", &freq1, &freq2) == 2) { + /* f1*f2 format */ + time = 0; + modulate = 1; } else if (sscanf(s, "%d/%d", &freq1, &time) == 2) { /* f1/time format */ freq2 = 0; @@ -186,6 +204,7 @@ d.items[d.nitems].freq1 = freq1; d.items[d.nitems].freq2 = freq2; d.items[d.nitems].duration = time; + d.items[d.nitems].modulate = modulate; d.nitems++; s = strsep(&stringp,separator);