mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-14 01:49:05 +00:00
add some sanity code to originate and conference
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3189 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
@@ -182,3 +182,37 @@ SWITCH_DECLARE(void) switch_swap_linear(int16_t *buf, int len)
|
||||
buf[i] = ((buf[i] >> 8) & 0x00ff) | ((buf[i] << 8) & 0xff00);
|
||||
}
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) switch_change_sln_volume(int16_t *data, uint32_t samples, int32_t vol)
|
||||
{
|
||||
double newrate = 0;
|
||||
int div = 0;
|
||||
|
||||
switch_normalize_volume(vol);
|
||||
|
||||
if (vol > 0) {
|
||||
vol++;
|
||||
} else if (vol < 0) {
|
||||
vol--;
|
||||
}
|
||||
|
||||
newrate = vol * 1.3;
|
||||
|
||||
if (vol < 0) {
|
||||
newrate *= -1;
|
||||
div++;
|
||||
}
|
||||
|
||||
if (newrate) {
|
||||
int32_t tmp;
|
||||
int x;
|
||||
int16_t *fp = data;
|
||||
|
||||
for (x = 0; x < samples; x++) {
|
||||
tmp = (double) div ? fp[x] / newrate : fp[x] * newrate;
|
||||
switch_normalize_to_16bit(tmp);
|
||||
fp[x] = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user