mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-14 01:49:05 +00:00
mux multi-channel audio files to mono to support playing stereo sound files
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11226 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
@@ -244,6 +244,27 @@ SWITCH_DECLARE(uint32_t) switch_merge_sln(int16_t *data, uint32_t samples, int16
|
||||
return x;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) switch_mux_channels(int16_t *data, uint32_t samples, uint32_t channels)
|
||||
{
|
||||
int16_t *buf;
|
||||
switch_size_t len = samples * sizeof(int16_t);
|
||||
uint32_t i = 0, j = 0, k = 0;
|
||||
|
||||
switch_zmalloc(buf, len);
|
||||
|
||||
for(i = 0; i < samples; i++) {
|
||||
for (j = 0; j < channels; j++) {
|
||||
int32_t z = buf[i] + data[k++];
|
||||
switch_normalize_to_16bit(z);
|
||||
buf[i] = (int16_t) z;
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(data, buf, len);
|
||||
free(buf);
|
||||
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) switch_change_sln_volume(int16_t *data, uint32_t samples, int32_t vol)
|
||||
{
|
||||
double newrate = 0;
|
||||
|
Reference in New Issue
Block a user