Re: Audio Glitch in Matlab ("Jelfs, Sam" )


Subject: Re: Audio Glitch in Matlab
From:    "Jelfs, Sam"  <sam.jelfs@xxxxxxxx>
Date:    Mon, 17 Oct 2011 17:52:09 +0200
List-Archive:<http://lists.mcgill.ca/scripts/wa.exe?LIST=AUDITORY>

--_000_E4FB19A270B2AE4E99E35D8BF51CEA3FC8FD0DCEFCNLCLUEXM03con_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable It is also possible to use PortAudio / pa_wavplay to make use of the ASIO4A= LL drivers with existing non-asio hardware. http://www.portaudio.com/ http://www.mathworks.com/matlabcentral/fileexchange/4017 http://www.asio4all.com/ Sam Jelfs From: AUDITORY - Research in Auditory Perception [mailto:AUDITORY@xxxxxxxx= ILL.CA] On Behalf Of Brian FG Katz Sent: Monday 17 October 2011 16:36 To: AUDITORY@xxxxxxxx Subject: Re: [AUDITORY] Audio Glitch in Matlab This bug is quite present in Windows. The solution is to not use the defaul= t system driver, but an ASIO supported soundcard. This is also recommended = for any sync play/rec situations, as the default Windows driver does not as= sure good or repeatable synchronization. -Brian FG Katz -- Brian FG Katz, Ph.D Audio & Acoustique LIMSI-CNRS BP 133 F91403 Orsay France tel. (+33) 01 69 85 81 55 fax. (+33) 01.69.85.80.88 e-mail Brian.Katz@xxxxxxxx<mailto:Brian.Katz@xxxxxxxx> <mailto:Brian.Katz@xxxxxxxx= imsi.fr> web_theme: http://www.limsi.fr/Scientifique/aa/thmsonesp/ web_group: http://www.limsi.fr/Scientifique/aa/ De : AUDITORY - Research in Auditory Perception [mailto:AUDITORY@xxxxxxxx= LL.CA] De la part de Patrick Zurek Envoy=E9 : lundi 17 octobre 2011 09:57 =C0 : AUDITORY@xxxxxxxx Objet : [AUDITORY] Audio Glitch in Matlab I'm writing to notify list readers of a problem playing audio using Matlab. The problem is that brief signals are truncated, and it happens using any o= f the common commands for playing audio (wavplay, sound, and the play metho= d of the audioplayer object). I can't specify the exact conditions under which the truncation occurs. How= ever, with a sample rate of 44.1 kHz, signals shorter than about 500 msec a= re truncated. I haven't looked much at other sample rates. A simple work-around for the problem is to pad the end of the signal with a= sufficient number of zeros that truncation occurs during the zero segment.= I've found that at least 2000 zeros need to be added to assure no truncati= on of a 10-msec signal (with a sample rate of 44.1kHz). I've brought this problem to the attention of The Mathworks. They confirmed= the problem, which they attribute to a bug in their driver. The Mathworks also informed me that the problem has been solved in their la= test release (R2011b) for playing using audioplayer, but not necessarily fo= r the other audio commands. I've confirmed this in very limited tests. The following is a piece of code that you can use to observe the truncation= . It creates a 100-msec, 1-kHz sine wave, applies a hanning window, and the= n plays it first with zero-padding and then without. You should be able to = hear the click at the end of the second tone, which is not present on the f= irst. If not, you can see it on an oscilloscope. %%%%%%%%%%%%%%%%%%%% fs =3D 44100; f =3D 1000; T =3D 0.1; nPad =3D 2000; nS =3D round(fs*T); y =3D sin(2.*pi*f/fs*(1:nS)'); w =3D .5*(1 - cos(2*pi*(1:nS)'/(nS+1))); y =3D w.*y; yPad =3D [y; zeros(nPad,1)]; wavplay(yPad, fs, 'sync') pause(0.5) wavplay(y, fs, 'sync') %%%%%%%%%%%%%%%%%%%%% -- Patrick M. Zurek President Sensimetrics Corporation 14 Summer St. Suite 403 Malden, MA 02148 Tel: 781-399-0858 x237 Fax: 781-399-0853 email: pat@xxxxxxxx<mailto:pat@xxxxxxxx> web: www.sens.com<http://www.sens.com> ________________________________ The information contained in this message may be confidential and legally p= rotected under applicable law. The message is intended solely for the addre= ssee(s). If you are not the intended recipient, you are hereby notified tha= t any use, forwarding, dissemination, or reproduction of this message is st= rictly prohibited and may be unlawful. If you are not the intended recipien= t, please contact the sender by return e-mail and destroy all copies of the= original message. --_000_E4FB19A270B2AE4E99E35D8BF51CEA3FC8FD0DCEFCNLCLUEXM03con_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <html> <head> <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Diso-8859-= 1"> <meta name=3D"Generator" content=3D"Microsoft Word 12 (filtered medium)"> <style><!-- /* Font Definitions */ @xxxxxxxx {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 0 0;} @xxxxxxxx {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 0 0;} @xxxxxxxx {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;} @xxxxxxxx {font-family:Tahoma; panose-1:2 11 6 4 3 5 4 4 2 4;} @xxxxxxxx {font-family:Consolas; panose-1:2 11 6 9 2 2 4 3 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0cm; margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Roman","serif"; color:black;} a:link, span.MsoHyperlink {mso-style-priority:99; color:blue; text-decoration:underline;} a:visited, span.MsoHyperlinkFollowed {mso-style-priority:99; color:purple; text-decoration:underline;} pre {mso-style-priority:99; mso-style-link:"HTML Preformatted Char"; margin:0cm; margin-bottom:.0001pt; font-size:10.0pt; font-family:"Courier New"; color:black;} p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph {mso-style-priority:34; margin-top:0cm; margin-right:0cm; margin-bottom:0cm; margin-left:36.0pt; margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Roman","serif"; color:black;} span.HTMLPreformattedChar {mso-style-name:"HTML Preformatted Char"; mso-style-priority:99; mso-style-link:"HTML Preformatted"; font-family:Consolas; color:black;} p.PrformatHTML, li.PrformatHTML, div.PrformatHTML {mso-style-name:"Pr=E9format=E9 HTML"; mso-style-link:"Pr=E9format=E9 HTML Car"; margin:0cm; margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Roman","serif"; color:black;} span.PrformatHTMLCar {mso-style-name:"Pr=E9format=E9 HTML Car"; mso-style-priority:99; mso-style-link:"Pr=E9format=E9 HTML"; font-family:Consolas; color:black;} span.EmailStyle21 {mso-style-type:personal; font-family:"Calibri","sans-serif"; color:#1F497D;} span.EmailStyle22 {mso-style-type:personal-reply; font-family:"Calibri","sans-serif"; color:#1F497D;} .MsoChpDefault {mso-style-type:export-only; font-size:10.0pt;} @xxxxxxxx WordSection1 {size:612.0pt 792.0pt; margin:70.85pt 70.85pt 70.85pt 70.85pt;} div.WordSection1 {page:WordSection1;} /* List Definitions */ @xxxxxxxx l0 {mso-list-id:926965819; mso-list-type:hybrid; mso-list-template-ids:344066808 1943972264 67698691 67698693 67698689 6769= 8691 67698693 67698689 67698691 67698693;} @xxxxxxxx l0:level1 {mso-level-start-at:0; mso-level-number-format:bullet; mso-level-text:-; mso-level-tab-stop:none; mso-level-number-position:left; text-indent:-18.0pt; font-family:"Calibri","sans-serif"; mso-fareast-font-family:Calibri; mso-bidi-font-family:"Times New Roman";} ol {margin-bottom:0cm;} ul {margin-bottom:0cm;} --></style><!--[if gte mso 9]><xml> <o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" /> </xml><![endif]--><!--[if gte mso 9]><xml> <o:shapelayout v:ext=3D"edit"> <o:idmap v:ext=3D"edit" data=3D"1" /> </o:shapelayout></xml><![endif]--> </head> <body bgcolor=3D"white" lang=3D"EN-US" link=3D"blue" vlink=3D"purple"> <div class=3D"WordSection1"> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca= libri&quot;,&quot;sans-serif&quot;;color:#1F497D">It is also possible to us= e PortAudio / pa_wavplay to make use of the ASIO4ALL drivers with existing = non-asio hardware.<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca= libri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span><= /p> <p class=3D"MsoNormal"><a href=3D"http://www.portaudio.com/">http://www.por= taudio.com/</a><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&qu= ot;,&quot;sans-serif&quot;;color:#1F497D"><o:p></o:p></span></p> <p class=3D"MsoNormal"><a href=3D"http://www.mathworks.com/matlabcentral/fi= leexchange/4017">http://www.mathworks.com/matlabcentral/fileexchange/4017</= a><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;san= s-serif&quot;;color:#1F497D"><o:p></o:p></span></p> <p class=3D"MsoNormal"><a href=3D"http://www.asio4all.com/">http://www.asio= 4all.com/</a><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot= ;,&quot;sans-serif&quot;;color:#1F497D"><o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca= libri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span><= /p> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca= libri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span><= /p> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca= libri&quot;,&quot;sans-serif&quot;;color:#1F497D">Sam Jelfs<o:p></o:p></spa= n></p> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca= libri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span><= /p> <div> <div style=3D"border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm = 0cm 0cm"> <p class=3D"MsoNormal"><b><span style=3D"font-size:10.0pt;font-family:&quot= ;Tahoma&quot;,&quot;sans-serif&quot;;color:windowtext">From:</span></b><spa= n style=3D"font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif= &quot;;color:windowtext"> AUDITORY - Research in Auditory Perception [mailt= o:AUDITORY@xxxxxxxx <b>On Behalf Of </b>Brian FG Katz<br> <b>Sent:</b> Monday 17 October 2011 16:36<br> <b>To:</b> AUDITORY@xxxxxxxx<br> <b>Subject:</b> Re: [AUDITORY] Audio Glitch in Matlab<o:p></o:p></span></p> </div> </div> <p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca= libri&quot;,&quot;sans-serif&quot;;color:#1F497D">This bug is quite present= in Windows. The solution is to not use the default system driver, but an A= SIO supported soundcard. This is also recommended for any sync play/rec situations, as the default Windows driver does not assure go= od or repeatable synchronization. <o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca= libri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span><= /p> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca= libri&quot;,&quot;sans-serif&quot;;color:#1F497D">-Brian FG Katz<o:p></o:p>= </span></p> <div> <p class=3D"MsoNormal"><span lang=3D"FR" style=3D"font-size:10.0pt;font-fam= ily:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#1F497D">--<o:p></o:p></= span></p> <p class=3D"MsoNormal"><span lang=3D"FR" style=3D"font-size:10.0pt;font-fam= ily:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#1F497D">Brian FG Katz, = Ph.D<o:p></o:p></span></p> <p class=3D"MsoNormal"><span lang=3D"FR" style=3D"font-size:10.0pt;font-fam= ily:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#1F497D">Audio &amp; Aco= ustique<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:&quot;Ar= ial&quot;,&quot;sans-serif&quot;;color:#1F497D">LIMSI-CNRS<o:p></o:p></span= ></p> <p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:&quot;Ar= ial&quot;,&quot;sans-serif&quot;;color:#1F497D">BP 133<o:p></o:p></span></p= > <p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:&quot;Ar= ial&quot;,&quot;sans-serif&quot;;color:#1F497D">F91403 Orsay<o:p></o:p></sp= an></p> <p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:&quot;Ar= ial&quot;,&quot;sans-serif&quot;;color:#1F497D">France<o:p></o:p></span></p= > <p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:&quot;Ar= ial&quot;,&quot;sans-serif&quot;;color:#1F497D">tel. (&#43;33) 01 69 85 81 = 55<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:&quot;Ar= ial&quot;,&quot;sans-serif&quot;;color:#1F497D">fax. (&#43;33) 01.69.85.80.= 88<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:&quot;Ar= ial&quot;,&quot;sans-serif&quot;;color:#1F497D">e-mail </span><span lang=3D"FR" style=3D"font-size:10.0pt;font-family:&quot;Arial&= quot;,&quot;sans-serif&quot;;color:#1F497D"><a href=3D"mailto:Brian.Katz@xxxxxxxx= msi.fr"><span lang=3D"EN-US">Brian.Katz@xxxxxxxx</span></a></span><span sty= le=3D"font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;= ;color:#1F497D"> &lt;</span><span lang=3D"FR" style=3D"font-size:10.0pt;font-family:&quot;A= rial&quot;,&quot;sans-serif&quot;;color:#1F497D"><a href=3D"mailto:Brian.Ka= tz@xxxxxxxx"><span lang=3D"EN-US">mailto:Brian.Katz@xxxxxxxx</span></a></sp= an><span style=3D"font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans= -serif&quot;;color:#1F497D">&gt;<o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:&quot;Ar= ial&quot;,&quot;sans-serif&quot;;color:#1F497D">web_theme: </span><span lang=3D"FR" style=3D"font-size:10.0pt;font-family:&quot;Arial&= quot;,&quot;sans-serif&quot;;color:#1F497D"><a href=3D"http://www.limsi.fr/= Scientifique/aa/thmsonesp/"><span lang=3D"EN-US">http://www.limsi.fr/Scient= ifique/aa/thmsonesp/</span></a></span><span style=3D"font-size:10.0pt;font-= family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p></o:p><= /span></p> <p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:&quot;Ar= ial&quot;,&quot;sans-serif&quot;;color:#1F497D">web_group: </span><span lang=3D"FR" style=3D"font-size:10.0pt;font-family:&quot;Arial&= quot;,&quot;sans-serif&quot;;color:#1F497D"><a href=3D"http://www.limsi.fr/= Scientifique/aa/"><span lang=3D"EN-US">http://www.limsi.fr/Scientifique/aa/= </span></a></span><span style=3D"font-size:10.0pt;font-family:&quot;Arial&q= uot;,&quot;sans-serif&quot;;color:#1F497D"><o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:&quot;Ar= ial&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p= > <p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:&quot;Ar= ial&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p= > </div> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca= libri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span><= /p> <div> <div style=3D"border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm = 0cm 0cm"> <p class=3D"MsoNormal"><b><span lang=3D"FR" style=3D"font-size:10.0pt;font-= family:&quot;Tahoma&quot;,&quot;sans-serif&quot;;color:windowtext">De&nbsp;= :</span></b><span lang=3D"FR" style=3D"font-size:10.0pt;font-family:&quot;T= ahoma&quot;,&quot;sans-serif&quot;;color:windowtext"> AUDITORY - Research i= n Auditory Perception [mailto:AUDITORY@xxxxxxxx <b>De la part de</b> Patrick Zurek<br> <b>Envoy=E9&nbsp;:</b> lundi 17 octobre 2011 09:57<br> <b>=C0&nbsp;:</b> AUDITORY@xxxxxxxx<br> <b>Objet&nbsp;:</b> [AUDITORY] Audio Glitch in Matlab<o:p></o:p></span></p> </div> </div> <p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p> <p class=3D"MsoNormal" style=3D"margin-bottom:12.0pt"><span style=3D"font-f= amily:&quot;Calibri&quot;,&quot;sans-serif&quot;">I'm writing to notify lis= t readers of a problem playing audio using Matlab. <br> <br> The problem is that brief signals are truncated, and it happens using any o= f the common commands for playing audio (wavplay, sound, and the play metho= d of the audioplayer object).<br> <br> I can't specify the exact conditions under which the truncation occurs. How= ever, with a sample rate of 44.1 kHz, signals shorter than about 500 msec a= re truncated. I haven't looked much at other sample rates.<br> <br> A simple work-around for the problem is to pad the end of the signal with a= sufficient number of zeros that truncation occurs during the zero segment.= I've found that at least 2000 zeros need to be added to assure no truncati= on of a 10-msec signal (with a sample rate of 44.1kHz).<br> <br> I've brought this problem to the attention of The Mathworks. They confirmed= the problem, which they attribute to a bug in their driver. <br> <br> The Mathworks also informed me that the problem has been solved in their la= test release (R2011b) for playing using audioplayer, but not necessarily fo= r the other audio commands. I've confirmed this in very limited tests. <br> <br> The following is a piece of code that you can use to observe the truncation= . It creates a 100-msec, 1-kHz sine wave, applies a hanning window, and the= n plays it first with zero-padding and then without. You should be able to = hear the click at the end of the second tone, which is not present on the first. If not, you can see it on = an oscilloscope.<br> <br> %%%%%%%%%%%%%%%%%%%%<br> fs =3D 44100;<br> f =3D 1000; <br> T =3D 0.1;<br> nPad =3D 2000;<br> <br> nS =3D round(fs*T);<br> <br> y =3D sin(2.*pi*f/fs*(1:nS)');<br> w =3D .5*(1 - cos(2*pi*(1:nS)'/(nS&#43;1)));<br> y =3D w.*y;<br> yPad =3D [y; zeros(nPad,1)];<br> <br> wavplay(yPad, fs, 'sync')<br> pause(0.5)<br> wavplay(y, fs, 'sync')<br> %%%%%%%%%%%%%%%%%%%%%</span><o:p></o:p></p> <pre>-- <o:p></o:p></pre> <pre>Patrick M. Zurek<o:p></o:p></pre> <pre>President <o:p></o:p></pre> <pre><o:p>&nbsp;</o:p></pre> <pre>Sensimetrics Corporation<o:p></o:p></pre> <pre>14 Summer St.<o:p></o:p></pre> <pre>Suite 403<o:p></o:p></pre> <pre>Malden, MA 02148<o:p></o:p></pre> <pre>Tel: 781-399-0858 x237<o:p></o:p></pre> <pre>Fax: 781-399-0853<o:p></o:p></pre> <pre>email: <a href=3D"mailto:pat@xxxxxxxx">pat@xxxxxxxx</a><o:p></o:p></pr= e> <pre>web: <a href=3D"http://www.sens.com">www.sens.com</a><o:p></o:p></pre> </div> <br> <hr> <font face=3D"Arial" color=3D"Gray" size=3D"1">The information contained in= this message may be confidential and legally protected under applicable la= w. The message is intended solely for the addressee(s). If you are not the = intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this message i= s strictly prohibited and may be unlawful. If you are not the intended reci= pient, please contact the sender by return e-mail and destroy all copies of= the original message.<br> </font> </body> </html> --_000_E4FB19A270B2AE4E99E35D8BF51CEA3FC8FD0DCEFCNLCLUEXM03con_--


This message came from the mail archive
/var/www/postings/2011/
maintained by:
DAn Ellis <dpwe@ee.columbia.edu>
Electrical Engineering Dept., Columbia University