From 94b680fb45b3fda90bc6652e3f588539fa783192 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 25 Feb 2011 18:09:58 -0600 Subject: [PATCH] play files saying vol level in conf in lieu of making a function of say modules to return file_string urls (we need that) --- .../mod_conference/mod_conference.c | 129 ++++++++++++++---- src/switch_resample.c | 26 ++-- 2 files changed, 116 insertions(+), 39 deletions(-) diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 35412afb17..548d8fc889 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -1598,16 +1598,17 @@ static void conference_loop_fn_deafmute_toggle(conference_member_t *member, call static void conference_loop_fn_energy_up(conference_member_t *member, caller_control_action_t *action) { - char msg[512]; + char msg[512], str[30] = ""; switch_event_t *event; + char *p; if (member == NULL) return; lock_member(member); member->energy_level += 200; - if (member->energy_level > 3000) { - member->energy_level = 3000; + if (member->energy_level > 1800) { + member->energy_level = 1800; } if (test_eflag(member->conference, EFLAG_ENERGY_LEVEL) && @@ -1619,13 +1620,23 @@ static void conference_loop_fn_energy_up(conference_member_t *member, caller_con } unlock_member(member); - switch_snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level); - conference_member_say(member, msg, 0); + //switch_snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level); + //conference_member_say(member, msg, 0); + + switch_snprintf(str, sizeof(str), "%d", abs(member->energy_level) / 200); + for (p = str; p && *p; p++) { + switch_snprintf(msg, sizeof(msg), "digits/%c.wav", *p); + conference_member_play_file(member, msg, 0); + } + + + + } static void conference_loop_fn_energy_equ_conf(conference_member_t *member, caller_control_action_t *action) { - char msg[512]; + char msg[512], str[30] = "", *p; switch_event_t *event; if (member == NULL) @@ -1643,13 +1654,20 @@ static void conference_loop_fn_energy_equ_conf(conference_member_t *member, call } unlock_member(member); - switch_snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level); - conference_member_say(member, msg, 0); + //switch_snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level); + //conference_member_say(member, msg, 0); + + switch_snprintf(str, sizeof(str), "%d", abs(member->energy_level) / 200); + for (p = str; p && *p; p++) { + switch_snprintf(msg, sizeof(msg), "digits/%c.wav", *p); + conference_member_play_file(member, msg, 0); + } + } static void conference_loop_fn_energy_dn(conference_member_t *member, caller_control_action_t *action) { - char msg[512]; + char msg[512], str[30] = "", *p; switch_event_t *event; if (member == NULL) @@ -1670,8 +1688,15 @@ static void conference_loop_fn_energy_dn(conference_member_t *member, caller_con } unlock_member(member); - switch_snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level); - conference_member_say(member, msg, 0); + //switch_snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level); + //conference_member_say(member, msg, 0); + + switch_snprintf(str, sizeof(str), "%d", abs(member->energy_level) / 200); + for (p = str; p && *p; p++) { + switch_snprintf(msg, sizeof(msg), "digits/%c.wav", *p); + conference_member_play_file(member, msg, 0); + } + } static void conference_loop_fn_volume_talk_up(conference_member_t *member, caller_control_action_t *action) @@ -1695,8 +1720,12 @@ static void conference_loop_fn_volume_talk_up(conference_member_t *member, calle } unlock_member(member); - switch_snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level); - conference_member_say(member, msg, 0); + //switch_snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level); + //conference_member_say(member, msg, 0); + + switch_snprintf(msg, sizeof(msg), "digits/%d.wav", member->volume_out_level); + conference_member_play_file(member, msg, 0); + } static void conference_loop_fn_volume_talk_zero(conference_member_t *member, caller_control_action_t *action) @@ -1719,9 +1748,17 @@ static void conference_loop_fn_volume_talk_zero(conference_member_t *member, cal } unlock_member(member); - switch_snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level); - conference_member_say(member, msg, 0); + //switch_snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level); + //conference_member_say(member, msg, 0); + + if (member->volume_out_level < 0) { + switch_snprintf(msg, sizeof(msg), "currency/negative.wav", member->volume_out_level); + conference_member_play_file(member, msg, 0); + } + + switch_snprintf(msg, sizeof(msg), "digits/%d.wav", abs(member->volume_out_level)); + conference_member_play_file(member, msg, 0); } static void conference_loop_fn_volume_talk_dn(conference_member_t *member, caller_control_action_t *action) @@ -1745,8 +1782,16 @@ static void conference_loop_fn_volume_talk_dn(conference_member_t *member, calle } unlock_member(member); - switch_snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level); - conference_member_say(member, msg, 0); + //switch_snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level); + //conference_member_say(member, msg, 0); + + if (member->volume_out_level < 0) { + switch_snprintf(msg, sizeof(msg), "currency/negative.wav", member->volume_out_level); + conference_member_play_file(member, msg, 0); + } + + switch_snprintf(msg, sizeof(msg), "digits/%d.wav", abs(member->volume_out_level)); + conference_member_play_file(member, msg, 0); } static void conference_loop_fn_volume_listen_up(conference_member_t *member, caller_control_action_t *action) @@ -1770,8 +1815,17 @@ static void conference_loop_fn_volume_listen_up(conference_member_t *member, cal } unlock_member(member); - switch_snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level); - conference_member_say(member, msg, 0); + //switch_snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level); + //conference_member_say(member, msg, 0); + + if (member->volume_in_level < 0) { + switch_snprintf(msg, sizeof(msg), "currency/negative.wav", member->volume_in_level); + conference_member_play_file(member, msg, 0); + } + + switch_snprintf(msg, sizeof(msg), "digits/%d.wav", abs(member->volume_in_level)); + conference_member_play_file(member, msg, 0); + } static void conference_loop_fn_volume_listen_zero(conference_member_t *member, caller_control_action_t *action) @@ -1794,8 +1848,17 @@ static void conference_loop_fn_volume_listen_zero(conference_member_t *member, c } unlock_member(member); - switch_snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level); - conference_member_say(member, msg, 0); + //switch_snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level); + //conference_member_say(member, msg, 0); + + if (member->volume_in_level < 0) { + switch_snprintf(msg, sizeof(msg), "currency/negative.wav", member->volume_in_level); + conference_member_play_file(member, msg, 0); + } + + switch_snprintf(msg, sizeof(msg), "digits/%d.wav", abs(member->volume_in_level)); + conference_member_play_file(member, msg, 0); + } static void conference_loop_fn_volume_listen_dn(conference_member_t *member, caller_control_action_t *action) @@ -1819,8 +1882,16 @@ static void conference_loop_fn_volume_listen_dn(conference_member_t *member, cal } unlock_member(member); - switch_snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level); - conference_member_say(member, msg, 0); + //switch_snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level); + //conference_member_say(member, msg, 0); + + if (member->volume_in_level < 0) { + switch_snprintf(msg, sizeof(msg), "currency/negative.wav", member->volume_in_level); + conference_member_play_file(member, msg, 0); + } + + switch_snprintf(msg, sizeof(msg), "digits/%d.wav", abs(member->volume_in_level)); + conference_member_play_file(member, msg, 0); } static void conference_loop_fn_event(conference_member_t *member, caller_control_action_t *action) @@ -3441,8 +3512,11 @@ static void conference_list(conference_obj_t *conference, switch_stream_handle_t count++; } - stream->write_function(stream, "%s%d%s%d%s%d\n", delim, member->agc_volume_in_level ? - member->agc_volume_in_level : member->volume_in_level, delim, member->volume_out_level, delim, member->energy_level); + stream->write_function(stream, "%s%d%s%d%s%d%s%d\n", delim, + member->volume_in_level, + delim, + member->agc_volume_in_level, + delim, member->volume_out_level, delim, member->energy_level); } switch_mutex_unlock(conference->member_mutex); @@ -3969,9 +4043,8 @@ static void conference_xlist(conference_obj_t *conference, switch_xml_t x_confer switch_snprintf(tmp, sizeof(tmp), "%d", member->agc_volume_in_level ? member->agc_volume_in_level : member->volume_in_level); x_tag = add_x_tag(x_member, "input-volume", tmp, toff++); - if (member->agc_volume_in_level) { - switch_xml_set_attr_d(x_tag, "auto", "true"); - } + switch_snprintf(tmp, sizeof(tmp), "%d", member->agc_volume_in_level); + x_tag = add_x_tag(x_member, "auto-adjusted-input-volume", tmp, toff++); } diff --git a/src/switch_resample.c b/src/switch_resample.c index 949b351785..9c7f9b95d2 100644 --- a/src/switch_resample.c +++ b/src/switch_resample.c @@ -309,22 +309,26 @@ SWITCH_DECLARE(void) switch_change_sln_volume_granular(int16_t *data, uint32_t s SWITCH_DECLARE(void) switch_change_sln_volume(int16_t *data, uint32_t samples, int32_t vol) { double newrate = 0; - int div = 0; + double pos[4] = {1.3, 2.3, 3.3, 4.3}; + double neg[4] = {.80, .60, .40, .20}; + double *chart; + uint32_t i; + + if (vol == 0) return; switch_normalize_volume(vol); if (vol > 0) { - vol++; - } else if (vol < 0) { - vol--; + chart = pos; + } else { + chart = neg; } + + i = abs(vol) - 1; + + switch_assert(i < 4); - newrate = vol * 1.3; - - if (vol < 0) { - newrate *= -1; - div++; - } + newrate = chart[i]; if (newrate) { int32_t tmp; @@ -332,7 +336,7 @@ SWITCH_DECLARE(void) switch_change_sln_volume(int16_t *data, uint32_t samples, i int16_t *fp = data; for (x = 0; x < samples; x++) { - tmp = (int32_t) (div ? fp[x] / newrate : fp[x] * newrate); + tmp = (int32_t) (fp[x] * newrate); switch_normalize_to_16bit(tmp); fp[x] = (int16_t) tmp; }