play files saying vol level in conf in lieu of making a function of say modules to return file_string urls (we need that)

This commit is contained in:
Anthony Minessale 2011-02-25 18:09:58 -06:00
parent cf827e8f22
commit 94b680fb45
2 changed files with 116 additions and 39 deletions

View File

@ -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) 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; switch_event_t *event;
char *p;
if (member == NULL) if (member == NULL)
return; return;
lock_member(member); lock_member(member);
member->energy_level += 200; member->energy_level += 200;
if (member->energy_level > 3000) { if (member->energy_level > 1800) {
member->energy_level = 3000; member->energy_level = 1800;
} }
if (test_eflag(member->conference, EFLAG_ENERGY_LEVEL) && 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); unlock_member(member);
switch_snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level); //switch_snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level);
conference_member_say(member, msg, 0); //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) 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; switch_event_t *event;
if (member == NULL) if (member == NULL)
@ -1643,13 +1654,20 @@ static void conference_loop_fn_energy_equ_conf(conference_member_t *member, call
} }
unlock_member(member); unlock_member(member);
switch_snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level); //switch_snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level);
conference_member_say(member, msg, 0); //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) 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; switch_event_t *event;
if (member == NULL) if (member == NULL)
@ -1670,8 +1688,15 @@ static void conference_loop_fn_energy_dn(conference_member_t *member, caller_con
} }
unlock_member(member); unlock_member(member);
switch_snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level); //switch_snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level);
conference_member_say(member, msg, 0); //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) 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); unlock_member(member);
switch_snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level); //switch_snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level);
conference_member_say(member, msg, 0); //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) 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); unlock_member(member);
switch_snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level); //switch_snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level);
conference_member_say(member, msg, 0); //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) 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); unlock_member(member);
switch_snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level); //switch_snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level);
conference_member_say(member, msg, 0); //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) 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); unlock_member(member);
switch_snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level); //switch_snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level);
conference_member_say(member, msg, 0); //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) 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); unlock_member(member);
switch_snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level); //switch_snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level);
conference_member_say(member, msg, 0); //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) 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); unlock_member(member);
switch_snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level); //switch_snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level);
conference_member_say(member, msg, 0); //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) 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++; count++;
} }
stream->write_function(stream, "%s%d%s%d%s%d\n", delim, member->agc_volume_in_level ? stream->write_function(stream, "%s%d%s%d%s%d%s%d\n", delim,
member->agc_volume_in_level : member->volume_in_level, delim, member->volume_out_level, delim, member->energy_level); 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); 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); 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++); x_tag = add_x_tag(x_member, "input-volume", tmp, toff++);
if (member->agc_volume_in_level) { switch_snprintf(tmp, sizeof(tmp), "%d", member->agc_volume_in_level);
switch_xml_set_attr_d(x_tag, "auto", "true"); x_tag = add_x_tag(x_member, "auto-adjusted-input-volume", tmp, toff++);
}
} }

View File

@ -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) SWITCH_DECLARE(void) switch_change_sln_volume(int16_t *data, uint32_t samples, int32_t vol)
{ {
double newrate = 0; 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); switch_normalize_volume(vol);
if (vol > 0) { if (vol > 0) {
vol++; chart = pos;
} else if (vol < 0) { } else {
vol--; chart = neg;
} }
i = abs(vol) - 1;
switch_assert(i < 4);
newrate = vol * 1.3; newrate = chart[i];
if (vol < 0) {
newrate *= -1;
div++;
}
if (newrate) { if (newrate) {
int32_t tmp; 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; int16_t *fp = data;
for (x = 0; x < samples; x++) { 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); switch_normalize_to_16bit(tmp);
fp[x] = (int16_t) tmp; fp[x] = (int16_t) tmp;
} }