tag:blogger.com,1999:blog-7844549485270153160.post5878021044635524805..comments2024-02-14T00:37:51.623-08:00Comments on My Blog: Converting audio samplesAlexander E. Patrakovhttp://www.blogger.com/profile/15370096336423115833noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-7844549485270153160.post-72595125988349002422015-10-04T07:48:32.489-07:002015-10-04T07:48:32.489-07:00Niels, it would be nice if you also mention any so...Niels, it would be nice if you also mention any software that implements this (entirely valid) possibility.Alexander E. Patrakovhttps://www.blogger.com/profile/15370096336423115833noreply@blogger.comtag:blogger.com,1999:blog-7844549485270153160.post-78464633068993752972015-10-04T02:40:09.828-07:002015-10-04T02:40:09.828-07:00There's also a fourth possibility that can los...There's also a fourth possibility that can losslessly represent all 16 bit values without requiring 2 different scale factors:<br /><br />When converting int16 samples to float, you first add 0.5 and then divide by 32767.5. When converting float to int16, you multiply by 32767.5, then subtract 0.5 and at the end round fairly to integer (or skip the subtraction and floor the value instead).<br /><br />That means 32767 converts to 1.0 (and vice versa) and -32768 converts to -1.0. The only downside is that neutral amplitude is not exactly representable this way on the integer side (lying exactly in between -1 and 0 in that case), but it's still damn close and should pose a problem in practice.Anonymoushttps://www.blogger.com/profile/16937888958433187446noreply@blogger.com