Subject: Re: dynamic range and sample bit depth From: Eric Thompson <et_27@xxxxxxxx> Date: Fri, 5 Dec 2014 20:16:29 +0000 List-Archive:<http://lists.mcgill.ca/scripts/wa.exe?LIST=AUDITORY>------=_Part_5732262_1585285128.1417810589455 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I can add some insight into the problem with audible signals from Matlab wh= en the signals should not be audible. I discovered this as well, through so= me admittedly sloppy coding on my part. I even went through the exercise of= reporting a bug to the Mathworks, and after a lot of back and forth, and a= lot of testing, we determined that it was a "feature" not a "bug" in Matla= b. What I discovered was that very low level signals (i.e.=C2=A0levels << -= 100 dB FS) were still audible to my ears using HD280pro headphones=C2=A0whe= n played with audioplayer at 16 bit depth, as Dan described, but the same s= ignals were not audible when played with wavplay (always 16-bit) or with au= dioplayer at 24-bit. I finally figured out after looking at the signals out= put from the sound card=C2=A0on an oscilloscope that audioplayer uses mid-r= iser quantization and wavplay uses mid-tread quantization (see http://en.wi= kipedia.org/wiki/Quantization_(signal_processing)#Mid-riser_and_mid-tread_u= niform_quantizers). This means that any signal that oscillates between very= small positive and negative values will get rounded up by audioplayer to o= scillate between the quantization levels around 0, whereas wavplay will out= put 0. Dithering should help avoid this problem, albeit by adding an audibl= e noise floor (at least audible with audioplayer). Also, Dan's solution of = using 24-bit output also will work around this feature because the acoustic= /electric noise floor=C2=A0should be=C2=A0high enough with any system=C2=A0= to mask this small signal, as several others have already pointed out. -Eri= c On Friday, December 5, 2014 12:13 AM, Dan Goodman <d.goodman@xxxxxxxx= AC.UK> wrote: =20 Thanks to everyone who replied on and off list to my questions! So, several people seemed to agree that using dither is essential. What=20 worries me about this is that if you do your sound presentations using=20 Matlab on synthetic signals (generated using Matlab code rather than=20 recorded), as far as I can tell it won't do this dithering, and so the=20 dynamic range will be much worse than people might be expecting. I=20 actually first came across this problem when helping to debug someone's=20 threshold finding code that was failing for people with very good=20 hearing. It turned out that this was because tones presented at low=20 levels (substantially less than 0 dB SPL) were still audible. The reason=20 in this case is that they were using 16 bit audio and switching to 24=20 bit solved the problem. (I guess Matlab was rounding up when converting=20 from floats to integers, so no matter how low the level of the signal=20 you were still getting some 1s in there and not just 0s.) However, my=20 worry is that if your reference level was set higher than this (because=20 you were testing normal and hearing impaired people with the same=20 equipment) then even 24 bit might not be enough (without dithering). --------snip--------- Dan ------=_Part_5732262_1585285128.1417810589455 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <html><body><div style=3D"color:#000; background-color:#fff; font-family:He= lveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;fo= nt-size:13px"><div id=3D"yui_3_16_0_1_1417808388798_21901" dir=3D"ltr"><spa= n id=3D"yui_3_16_0_1_1417808388798_21900">I can add some insight into the p= roblem with audible signals from Matlab when the signals should not be audi= ble. I discovered this as well, through some admittedly sloppy coding on my= part. I even went through the exercise of reporting a bug to the Mathworks= , and after a lot of back and forth, and a lot of testing, we determined th= at it was a "feature" not a "bug" in Matlab. What I discovered was that ver= y low level signals (i.e. levels << -100 dB FS) were still audib= le to my ears using HD280pro headphones when played with audioplayer a= t 16 bit depth, as Dan described, but the same signals were not audible whe= n played with wavplay (always 16-bit) or with audioplayer at 24-bit. I fina= lly figured out after looking at the signals output from the sound card&nbs= p;on an oscilloscope that audioplayer uses mid-riser quantization and wavpl= ay uses mid-tread quantization (see <a id=3D"yui_3_16_0_1_1417808388798_315= 30" href=3D"http://en.wikipedia.org/wiki/Quantization_(signal_processing)#M= id-riser_and_mid-tread_uniform_quantizers">http://en.wikipedia.org/wiki/Qua= ntization_(signal_processing)#Mid-riser_and_mid-tread_uniform_quantizers</a= >). This means that any signal that oscillates between very small positive = and negative values will get rounded up by audioplayer to oscillate between= the quantization levels around 0, whereas wavplay will output 0. Dithering= should help avoid this problem, albeit by adding an audible noise floor (a= t least audible with audioplayer). Also, Dan's solution of using 24-bit out= put also will work around this feature because the acoustic/electric noise = floor should be high enough with any system to mask this sma= ll signal, as several others have already pointed out.</span></div> <div cl= ass=3D"qtdSeparateBR" id=3D"yui_3_16_0_1_1417808388798_38875" dir=3D"ltr">-= Eric<br><br></div><div class=3D"yahoo_quoted" id=3D"yui_3_16_0_1_1417808388= 798_38869" style=3D"display: block;"> <div id=3D"yui_3_16_0_1_1417808388798= _38868" style=3D"font-family: HelveticaNeue, Helvetica Neue, Helvetica, Ari= al, Lucida Grande, sans-serif; font-size: 13px;"> <div id=3D"yui_3_16_0_1_1= 417808388798_38867" style=3D"font-family: HelveticaNeue, Helvetica Neue, He= lvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div id=3D"yu= i_3_16_0_1_1417808388798_38874" dir=3D"ltr"> <font id=3D"yui_3_16_0_1_14178= 08388798_38873" face=3D"Arial" size=3D"2"> On Friday, December 5, 2014 12:1= 3 AM, Dan Goodman <d.goodman@xxxxxxxx> wrote:<br> </font> </div= > <br><br> <div class=3D"y_msg_container" id=3D"yui_3_16_0_1_1417808388798= _38872">Thanks to everyone who replied on and off list to my questions!<br>= <br>So, several people seemed to agree that using dither is essential. What= <br>worries me about this is that if you do your sound presentations using= <br>Matlab on synthetic signals (generated using Matlab code rather than <= br>recorded), as far as I can tell it won't do this dithering, and so the <= br>dynamic range will be much worse than people might be expecting. I <br>a= ctually first came across this problem when helping to debug someone's <br>= threshold finding code that was failing for people with very good <br>heari= ng. It turned out that this was because tones presented at low <br>levels (= substantially less than 0 dB SPL) were still audible. The reason <br>in thi= s case is that they were using 16 bit audio and switching to 24 <br>bit sol= ved the problem. (I guess Matlab was rounding up when converting <br>from f= loats to integers, so no matter how low the level of the signal <br>you wer= e still getting some 1s in there and not just 0s.) However, my <br>worry is= that if your reference level was set higher than this (because <br>you wer= e testing normal and hearing impaired people with the same <br>equipment) t= hen even 24 bit might not be enough (without dithering).<br><br>--------sni= p---------</div><div class=3D"y_msg_container" id=3D"yui_3_16_0_1_141780838= 8798_47103"><br>Dan<br><br><br></div> </div> </div> </div> </div></body><= /html> ------=_Part_5732262_1585285128.1417810589455--