git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4716 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2007-03-21 18:50:51 +00:00
parent 2da36dea17
commit 573058c6d3
3 changed files with 30 additions and 1 deletions

View File

@ -154,6 +154,14 @@ SWITCH_DECLARE(int) switch_short_to_float(short *s, float *f, int len);
*/
SWITCH_DECLARE(void) switch_swap_linear(int16_t *buf, int len);
/*!
\brief Generate static noise
\param data the audio data buffer
\param samples the number of 2 byte samples
\param divisor the volume factor
*/
SWITCH_DECLARE(void) switch_generate_sln_silence(int16_t *data, uint32_t samples, uint32_t divisor);
/*!
\brief Change the volume of a signed linear audio frame
\param data the audio data

View File

@ -1696,7 +1696,7 @@ static void conference_loop_output(conference_member_t *member)
} else {
if (switch_test_flag(member, MFLAG_WASTE_BANDWIDTH)) {
memset(write_frame.data, 255, bytes);
switch_generate_sln_silence(write_frame.data, samples, 1400);
write_frame.datalen = bytes;
write_frame.samples = samples;
write_frame.timestamp = timer.samplecount;

View File

@ -183,6 +183,27 @@ SWITCH_DECLARE(void) switch_swap_linear(int16_t *buf, int len)
}
}
SWITCH_DECLARE(void) switch_generate_sln_silence(int16_t *data, uint32_t samples, uint32_t divisor)
{
int16_t rnd, x,i;
uint32_t sum_rnd = 0;
assert(divisor);
for(i = 0; i < samples; i++, sum_rnd = 0) {
for(x = 0; x < 7; x++) {
rnd = (int16_t) (rand() * sizeof(int16_t));
sum_rnd += rnd;
}
switch_normalize_to_16bit(sum_rnd);
*data = (int16_t) sum_rnd;
*data /= (int)divisor;
data++;
}
}
SWITCH_DECLARE(void) switch_change_sln_volume(int16_t *data, uint32_t samples, int32_t vol)
{
double newrate = 0;