<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Thank you for the quick and detailed explain, It had confused me for a while. :)<div><br></div><div> <div><div><html>On Apr 7, 2009, at 12:21 AM, Anthony Minessale wrote:</html><br class="Apple-interchange-newline"><blockquote type="cite">1) no the += or = makes no difference to me.<br><br>2) the macro is designed to fight clipping:<br> 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.<br> <br>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.<br> <br><br><br><br><div class="gmail_quote">On Mon, Apr 6, 2009 at 10:44 AM, seven du <span dir="ltr"><<a href="mailto:seven@idapted.com">seven@idapted.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> <div style=""><div>Well, Thank you Anthony. 3 questions In summary,</div><div><br></div><div>1) in </div><div class="im"><div><blockquote type="cite"> if (x < rlen) {<br> z += (int32_t) *(fp + x);</blockquote> <br></div></div><div>Any difference if change the "+=" to "=" since z is 0? It just confused me.</div><div><br></div><div>2) If n1 = 32768, n2 = 32766, after use MACRO </div><div>switch_normalize_to_16bit(n1)</div> <div>switch_normalize_to_16bit(n2)</div><div><br></div><div>the result will be:</div><div>n1 = 32767/2 = 16383</div><div>n2 = 32766</div><div><br></div><div>is that the expected result? </div><div><div><br></div><div>3) Is there any chance rlen and wlen both > 0?</div> <div><div></div><div class="h5"><div><br><div><div><div>On Apr 6, 2009, at 11:16 PM, Anthony Minessale wrote:<br><blockquote type="cite">what ?<br><br>I don't know what your question is.</blockquote><blockquote type="cite"> <br><br><div class="gmail_quote">On Mon, Apr 6, 2009 at 9:35 AM, seven du <span dir="ltr"><<a href="mailto:seven@idapted.com" target="_blank">seven@idapted.com</a>></span> wrote:<br> <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> Hi, can someone explain this to me?<br> <br> In switch_core_media_bug.c, around line 173:<br> <br> <br> <br> for (x = 0; x < blen; x++) {<br> int32_t z = 0;<br> <br> if (x < rlen) {<br> z += (int32_t) *(fp + x); //what's difference here with z =<br> (int32_t) *(fp + x) ?</blockquote></div></blockquote><blockquote type="cite"><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> <br> }<br> if (x < wlen) {<br> z += (int32_t) *(dp + x);<br> }<br> switch_normalize_to_16bit(z);<br> *(fp + x) = (int16_t) z / 2;<br> }<br> <br> And for switch_normalize_to_16bit, according to switch_utils.h,<br> <br> #define SWITCH_SMAX 32767<br> #define SWITCH_SMIN -32768<br> #define switch_normalize_to_16bit(n) if (n > SWITCH_SMAX) n =<br> SWITCH_SMAX / 2; else if (n < SWITCH_SMIN) n = SWITCH_SMIN / 2;<br> <br> Then<br> switch_normalize_to_16bit( 32768 ), z = 32767/2, and (int16_t) z / 2 =<br> 32767/4<br> switch_normalize_to_16bit( 32766) , z = 32766, and (int16_t) z / 2 =<br> 32766/2<br> <br> Does that make sense? I guess it should be like this:<br> <br> #define switch_normalize_to_16bit(n) if (n > SWITCH_SMAX) n =<br> SWITCH_SMAX / 2; else if (n < SWITCH_SMIN) n = SWITCH_SMIN / 2; else n<br> = n / 2;<br> <br> switch_normalize_to_16bit(z);<br> *(fp + x) = (int16_t) z;<br> <br> <br> Thank you.<br> <br> _______________________________________________<br> Freeswitch-dev mailing list<br> <a href="mailto:Freeswitch-dev@lists.freeswitch.org" target="_blank">Freeswitch-dev@lists.freeswitch.org</a><br> <a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev</a><br> UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-dev" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-dev</a><br> <a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br> </blockquote></div><br><br clear="all"><br>-- <br>Anthony Minessale II<br><br>FreeSWITCH <a href="http://www.freeswitch.org/" target="_blank">http://www.freeswitch.org/</a><br>ClueCon <a href="http://www.cluecon.com/" target="_blank">http://www.cluecon.com/</a><br> <br>AIM: anthm<br><a href="mailto:MSN%3Aanthony_minessale@hotmail.com" target="_blank">MSN:anthony_minessale@hotmail.com</a><br>GTALK/JABBER/<a href="mailto:PAYPAL%3Aanthony.minessale@gmail.com" target="_blank">PAYPAL:anthony.minessale@gmail.com</a><br> IRC: <a href="http://irc.freenode.net" target="_blank">irc.freenode.net</a> #freeswitch<br><br>FreeSWITCH Developer Conference<br><a href="mailto:sip%3A888@conference.freeswitch.org" target="_blank">sip:888@conference.freeswitch.org</a><br> <a href="http://iax:guest@conference.freeswitch.org/888" target="_blank">iax:guest@conference.freeswitch.org/888</a><br> <a href="mailto:googletalk%3Aconf%2B888@conference.freeswitch.org" target="_blank">googletalk:conf+888@conference.freeswitch.org</a><br> pstn:213-799-1400<br> _______________________________________________<br>Freeswitch-dev mailing list<br><a href="mailto:Freeswitch-dev@lists.freeswitch.org" target="_blank">Freeswitch-dev@lists.freeswitch.org</a><br><a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev</a><br> UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-dev" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-dev</a><br><a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br> </blockquote></div><br></div></div></div></div></div></div></div><br>_______________________________________________<br> Freeswitch-dev mailing list<br> <a href="mailto:Freeswitch-dev@lists.freeswitch.org">Freeswitch-dev@lists.freeswitch.org</a><br> <a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev</a><br> UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-dev" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-dev</a><br> <a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br> <br></blockquote></div><br><br clear="all"><br>-- <br>Anthony Minessale II<br><br>FreeSWITCH <a href="http://www.freeswitch.org/">http://www.freeswitch.org/</a><br>ClueCon <a href="http://www.cluecon.com/">http://www.cluecon.com/</a><br> <br>AIM: anthm<br><a href="mailto:MSN%3Aanthony_minessale@hotmail.com">MSN:anthony_minessale@hotmail.com</a><br>GTALK/JABBER/<a href="mailto:PAYPAL%3Aanthony.minessale@gmail.com">PAYPAL:anthony.minessale@gmail.com</a><br> IRC: <a href="http://irc.freenode.net">irc.freenode.net</a> #freeswitch<br><br>FreeSWITCH Developer Conference<br><a href="mailto:sip%3A888@conference.freeswitch.org">sip:888@conference.freeswitch.org</a><br><a href="http://iax:guest@conference.freeswitch.org/888">iax:guest@conference.freeswitch.org/888</a><br> <a href="mailto:googletalk%3Aconf%2B888@conference.freeswitch.org">googletalk:conf+888@conference.freeswitch.org</a><br>pstn:213-799-1400<br> _______________________________________________<br>Freeswitch-dev mailing list<br><a href="mailto:Freeswitch-dev@lists.freeswitch.org">Freeswitch-dev@lists.freeswitch.org</a><br>http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev<br>UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev<br>http://www.freeswitch.org<br></blockquote></div><br></div></div></body></html>