1) no the += or = makes no difference to me. 2) the macro is designed to fight clipping: When a sample exceeds the max size of the datatype we set it to the max value then cut the volume in half of that sample so it does not make too much noise. if we divide everything by 2 then all the volume would be reduced even on samples that fell inside the proper range. 3) rlen and wlen are often both > 0. the point is we only manupulate the data that is real rlen is how many bytes on the read channel and wlen the write, we normalize it so if one of the other is a difference size we only change samples that are in the range where actual audio occured. On Mon, Apr 6, 2009 at 10:44 AM, seven du <seven@idapted.com> wrote:
Well, Thank you Anthony. 3 questions In summary,
1) in
if (x < rlen) { z += (int32_t) *(fp + x);
Any difference if change the "+=" to "=" since z is 0? It just confused me.
2) If n1 = 32768, n2 = 32766, after use MACRO switch_normalize_to_16bit(n1) switch_normalize_to_16bit(n2)
the result will be: n1 = 32767/2 = 16383 n2 = 32766
is that the expected result?
3) Is there any chance rlen and wlen both > 0?
On Apr 6, 2009, at 11:16 PM, Anthony Minessale wrote:
what ?
I don't know what your question is.
On Mon, Apr 6, 2009 at 9:35 AM, seven du <seven@idapted.com> wrote:
Hi, can someone explain this to me?
In switch_core_media_bug.c, around line 173:
for (x = 0; x < blen; x++) { int32_t z = 0;
if (x < rlen) { z += (int32_t) *(fp + x); //what's difference here with z = (int32_t) *(fp + x) ?
} if (x < wlen) { z += (int32_t) *(dp + x); } switch_normalize_to_16bit(z); *(fp + x) = (int16_t) z / 2; }
And for switch_normalize_to_16bit, according to switch_utils.h,
#define SWITCH_SMAX 32767 #define SWITCH_SMIN -32768 #define switch_normalize_to_16bit(n) if (n > SWITCH_SMAX) n = SWITCH_SMAX / 2; else if (n < SWITCH_SMIN) n = SWITCH_SMIN / 2;
Then switch_normalize_to_16bit( 32768 ), z = 32767/2, and (int16_t) z / 2 = 32767/4 switch_normalize_to_16bit( 32766) , z = 32766, and (int16_t) z / 2 = 32766/2
Does that make sense? I guess it should be like this:
#define switch_normalize_to_16bit(n) if (n > SWITCH_SMAX) n = SWITCH_SMAX / 2; else if (n < SWITCH_SMIN) n = SWITCH_SMIN / 2; else n = n / 2;
switch_normalize_to_16bit(z); *(fp + x) = (int16_t) z;
Thank you.
_______________________________________________ Freeswitch-dev mailing list Freeswitch-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
-- Anthony Minessale II
FreeSWITCH http://www.freeswitch.org/ ClueCon http://www.cluecon.com/
AIM: anthm MSN:anthony_minessale@hotmail.com <MSN%3Aanthony_minessale@hotmail.com> GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com<PAYPAL%3Aanthony.minessale@gmail.com> IRC: irc.freenode.net #freeswitch
FreeSWITCH Developer Conference sip:888@conference.freeswitch.org <sip%3A888@conference.freeswitch.org> iax:guest@conference.freeswitch.org/888 googletalk:conf+888@conference.freeswitch.org<googletalk%3Aconf%2B888@conference.freeswitch.org> pstn:213-799-1400 _______________________________________________ Freeswitch-dev mailing list Freeswitch-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
_______________________________________________ Freeswitch-dev mailing list Freeswitch-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
-- Anthony Minessale II FreeSWITCH http://www.freeswitch.org/ ClueCon http://www.cluecon.com/ AIM: anthm MSN:anthony_minessale@hotmail.com <MSN%3Aanthony_minessale@hotmail.com> GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com<PAYPAL%3Aanthony.minessale@gmail.com> IRC: irc.freenode.net #freeswitch FreeSWITCH Developer Conference sip:888@conference.freeswitch.org <sip%3A888@conference.freeswitch.org> iax:guest@conference.freeswitch.org/888 googletalk:conf+888@conference.freeswitch.org<googletalk%3Aconf%2B888@conference.freeswitch.org> pstn:213-799-1400