diff options
author | kpfleming <kpfleming@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2008-03-21 23:30:41 +0000 |
---|---|---|
committer | kpfleming <kpfleming@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2008-03-21 23:30:41 +0000 |
commit | 57544543646a83e92555be35b6096928d41b721e (patch) | |
tree | 9bbfb63133ea8454d6968122a860a68ca46577fd /tonezone.c | |
parent | 9b0ddb179b1216d03a2d0e7d884342fbef2246a0 (diff) |
add MF R2 tone generation, and along the way do a lot of cleanup of the tone building and playback code
git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.4@4063 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'tonezone.c')
-rw-r--r-- | tonezone.c | 92 |
1 files changed, 72 insertions, 20 deletions
@@ -234,7 +234,7 @@ struct mf_tone { float f2; /* second freq */ }; -static struct mf_tone dtmf_dial[] = { +static struct mf_tone dtmf_tones[] = { { ZT_TONE_DTMF_0, 941.0, 1336.0 }, { ZT_TONE_DTMF_1, 697.0, 1209.0 }, { ZT_TONE_DTMF_2, 697.0, 1336.0 }, @@ -254,22 +254,60 @@ static struct mf_tone dtmf_dial[] = { { 0, 0, 0 } }; -static struct mf_tone mf_dial[] = { - { ZT_TONE_MF_0, 1300.0, 1500.0 }, - { ZT_TONE_MF_1, 700.0, 900.0 }, - { ZT_TONE_MF_2, 700.0, 1100.0 }, - { ZT_TONE_MF_3, 900.0, 1100.0 }, - { ZT_TONE_MF_4, 700.0, 1300.0 }, - { ZT_TONE_MF_5, 900.0, 1300.0 }, - { ZT_TONE_MF_6, 1100.0, 1300.0 }, - { ZT_TONE_MF_7, 700.0, 1500.0 }, - { ZT_TONE_MF_8, 900.0, 1500.0 }, - { ZT_TONE_MF_9, 1100.0, 1500.0 }, - { ZT_TONE_MF_s, 1100.0, 1700.0 }, /* KP */ - { ZT_TONE_MF_p, 1500.0, 1700.0 }, /* ST */ - { ZT_TONE_MF_A, 900.0, 1700.0 }, /* ST' */ - { ZT_TONE_MF_B, 1300.0, 1700.0 }, /* ST'' */ - { ZT_TONE_MF_C, 700.0, 1700.0 }, /* ST''' */ +static struct mf_tone mfr1_tones[] = { + { ZT_TONE_MFR1_0, 1300.0, 1500.0 }, + { ZT_TONE_MFR1_1, 700.0, 900.0 }, + { ZT_TONE_MFR1_2, 700.0, 1100.0 }, + { ZT_TONE_MFR1_3, 900.0, 1100.0 }, + { ZT_TONE_MFR1_4, 700.0, 1300.0 }, + { ZT_TONE_MFR1_5, 900.0, 1300.0 }, + { ZT_TONE_MFR1_6, 1100.0, 1300.0 }, + { ZT_TONE_MFR1_7, 700.0, 1500.0 }, + { ZT_TONE_MFR1_8, 900.0, 1500.0 }, + { ZT_TONE_MFR1_9, 1100.0, 1500.0 }, + { ZT_TONE_MFR1_KP, 1100.0, 1700.0 }, /* KP */ + { ZT_TONE_MFR1_ST, 1500.0, 1700.0 }, /* ST */ + { ZT_TONE_MFR1_STP, 900.0, 1700.0 }, /* KP' or ST' */ + { ZT_TONE_MFR1_ST2P, 1300.0, 1700.0 }, /* KP'' or ST'' */ + { ZT_TONE_MFR1_ST3P, 700.0, 1700.0 }, /* KP''' or ST''' */ + { 0, 0, 0 } +}; + +static struct mf_tone mfr2_fwd_tones[] = { + { ZT_TONE_MFR2_FWD_1, 1380.0, 1500.0 }, + { ZT_TONE_MFR2_FWD_2, 1380.0, 1620.0 }, + { ZT_TONE_MFR2_FWD_3, 1500.0, 1620.0 }, + { ZT_TONE_MFR2_FWD_4, 1380.0, 1740.0 }, + { ZT_TONE_MFR2_FWD_5, 1500.0, 1740.0 }, + { ZT_TONE_MFR2_FWD_6, 1620.0, 1740.0 }, + { ZT_TONE_MFR2_FWD_7, 1380.0, 1860.0 }, + { ZT_TONE_MFR2_FWD_8, 1500.0, 1860.0 }, + { ZT_TONE_MFR2_FWD_9, 1620.0, 1860.0 }, + { ZT_TONE_MFR2_FWD_10, 1740.0, 1860.0 }, + { ZT_TONE_MFR2_FWD_11, 1380.0, 1980.0 }, + { ZT_TONE_MFR2_FWD_12, 1500.0, 1980.0 }, + { ZT_TONE_MFR2_FWD_13, 1620.0, 1980.0 }, + { ZT_TONE_MFR2_FWD_14, 1740.0, 1980.0 }, + { ZT_TONE_MFR2_FWD_15, 1860.0, 1980.0 }, + { 0, 0, 0 } +}; + +static struct mf_tone mfr2_rev_tones[] = { + { ZT_TONE_MFR2_REV_1, 1020.0, 1140.0 }, + { ZT_TONE_MFR2_REV_2, 900.0, 1140.0 }, + { ZT_TONE_MFR2_REV_3, 900.0, 1020.0 }, + { ZT_TONE_MFR2_REV_4, 780.0, 1140.0 }, + { ZT_TONE_MFR2_REV_5, 780.0, 1020.0 }, + { ZT_TONE_MFR2_REV_6, 780.0, 900.0 }, + { ZT_TONE_MFR2_REV_7, 660.0, 1140.0 }, + { ZT_TONE_MFR2_REV_8, 660.0, 1020.0 }, + { ZT_TONE_MFR2_REV_9, 660.0, 900.0 }, + { ZT_TONE_MFR2_REV_10, 660.0, 780.0 }, + { ZT_TONE_MFR2_REV_11, 540.0, 1140.0 }, + { ZT_TONE_MFR2_REV_12, 540.0, 1020.0 }, + { ZT_TONE_MFR2_REV_13, 540.0, 900.0 }, + { ZT_TONE_MFR2_REV_14, 540.0, 780.0 }, + { ZT_TONE_MFR2_REV_15, 540.0, 660.0 }, { 0, 0, 0 } }; @@ -346,15 +384,29 @@ int tone_zone_register_zone(int fd, struct tone_zone *z) space -= res; } - if ((res = build_mf_tones(ptr, space, &count, dtmf_dial, z->dtmf_low_level, z->dtmf_high_level)) < 0) { + if ((res = build_mf_tones(ptr, space, &count, dtmf_tones, z->dtmf_low_level, z->dtmf_high_level)) < 0) { fprintf(stderr, "Could not build DTMF tones.\n"); return -1; } ptr += res; space -= res; - if ((res = build_mf_tones(ptr, space, &count, mf_dial, z->mf_level, z->mf_level)) < 0) { - fprintf(stderr, "Could not build MF tones.\n"); + if ((res = build_mf_tones(ptr, space, &count, mfr1_tones, z->mfr1_level, z->mfr1_level)) < 0) { + fprintf(stderr, "Could not build MFR1 tones.\n"); + return -1; + } + ptr += res; + space -= res; + + if ((res = build_mf_tones(ptr, space, &count, mfr2_fwd_tones, z->mfr2_level, z->mfr2_level)) < 0) { + fprintf(stderr, "Could not build MFR2 FWD tones.\n"); + return -1; + } + ptr += res; + space -= res; + + if ((res = build_mf_tones(ptr, space, &count, mfr2_rev_tones, z->mfr2_level, z->mfr2_level)) < 0) { + fprintf(stderr, "Could not build MFR2 REV tones.\n"); return -1; } ptr += res; |