Re: Audio Glitch in Matlab (Brian FG Katz )


Subject: Re: Audio Glitch in Matlab
From:    Brian FG Katz  <brian.katz@xxxxxxxx>
Date:    Mon, 17 Oct 2011 10:35:49 -0400
List-Archive:<http://lists.mcgill.ca/scripts/wa.exe?LIST=AUDITORY>

This is a multipart message in MIME format. ------=_NextPart_000_0084_01CC8CB8.8AAFF440 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable This bug is quite present in Windows. The solution is to not use the = default system driver, but an ASIO supported soundcard. This is also recommended = for any sync play/rec situations, as the default Windows driver does not = assure good or repeatable synchronization.=20 =20 -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 <mailto:Brian.Katz@xxxxxxxx> Brian.Katz@xxxxxxxx < <mailto:Brian.Katz@xxxxxxxx> mailto:Brian.Katz@xxxxxxxx> web_theme: <http://www.limsi.fr/Scientifique/aa/thmsonesp/> http://www.limsi.fr/Scientifique/aa/thmsonesp/ web_group: <http://www.limsi.fr/Scientifique/aa/> http://www.limsi.fr/Scientifique/aa/ =20 =20 =20 De : AUDITORY - Research in Auditory Perception [mailto:AUDITORY@xxxxxxxx De la part de Patrick Zurek Envoy=E9 : lundi 17 octobre 2011 09:57 =C0 : AUDITORY@xxxxxxxx Objet : [AUDITORY] Audio Glitch in Matlab =20 I'm writing to notify list readers of a problem playing audio using = Matlab.=20 The problem is that brief signals are truncated, and it happens using = any of the common commands for playing audio (wavplay, sound, and the play = method of the audioplayer object). I can't specify the exact conditions under which the truncation occurs. However, with a sample rate of 44.1 kHz, signals shorter than about 500 = msec are 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 = truncation 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.=20 The Mathworks also informed me that the problem has been solved in their latest release (R2011b) for playing using audioplayer, but not = necessarily for 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 = then 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. %%%%%%%%%%%%%%%%%%%% fs =3D 44100; f =3D 1000;=20 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') %%%%%%%%%%%%%%%%%%%%% --=20 Patrick M. Zurek President=20 =20 Sensimetrics Corporation 14 Summer St. Suite 403 Malden, MA 02148 Tel: 781-399-0858 x237 Fax: 781-399-0853 email: pat@xxxxxxxx web: www.sens.com ------=_NextPart_000_0084_01CC8CB8.8AAFF440 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; = charset=3Diso-8859-1"> <html xmlns:v=3D"urn:schemas-microsoft-com:vml" = xmlns:o=3D"urn:schemas-microsoft-com:office:office" = xmlns:w=3D"urn:schemas-microsoft-com:office:word" = xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" = xmlns=3D"http://www.w3.org/TR/REC-html40"><head><meta name=3DGenerator = content=3D"Microsoft Word 14 (filtered medium)"><style><!-- /* Font Definitions */ @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:"Pr=E9format=E9 HTML Car"; margin:0cm; margin-bottom:.0001pt; font-size:10.0pt; font-family:"Courier New"; 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.EmailStyle19 {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;} --></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=3Dwhite = lang=3DEN-US link=3Dblue vlink=3Dpurple><div class=3DWordSection1><p = class=3DMsoNormal><span = style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497= D'>This bug is quite present in Windows. The solution is to not use the = default system driver, but an ASIO supported soundcard. This is also = recommended for any sync play/rec situations, as the default Windows = driver does not assure good or repeatable synchronization. = <o:p></o:p></span></p><p class=3DMsoNormal><span = style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497= D'><o:p>&nbsp;</o:p></span></p><p class=3DMsoNormal><span = style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497= D'>-Brian FG Katz<o:p></o:p></span></p><div><p class=3DMsoNormal><span = lang=3DFR = style=3D'font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'= >--<o:p></o:p></span></p><p class=3DMsoNormal><span lang=3DFR = style=3D'font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'= >Brian FG Katz, Ph.D<o:p></o:p></span></p><p class=3DMsoNormal><span = lang=3DFR = style=3D'font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'= >Audio &amp; Acoustique<o:p></o:p></span></p><p class=3DMsoNormal><span = style=3D'font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'= >LIMSI-CNRS<o:p></o:p></span></p><p class=3DMsoNormal><span = style=3D'font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'= >BP 133<o:p></o:p></span></p><p class=3DMsoNormal><span = style=3D'font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'= >F91403 Orsay<o:p></o:p></span></p><p class=3DMsoNormal><span = style=3D'font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'= >France<o:p></o:p></span></p><p class=3DMsoNormal><span = style=3D'font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'= >tel. (+33) 01 69 85 81 55<o:p></o:p></span></p><p = class=3DMsoNormal><span = style=3D'font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'= >fax. (+33) 01.69.85.80.88<o:p></o:p></span></p><p = class=3DMsoNormal><span = style=3D'font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'= >e-mail </span><span lang=3DFR = style=3D'font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'= ><a href=3D"mailto:Brian.Katz@xxxxxxxx"><span lang=3DEN-US = style=3D'color:blue'>Brian.Katz@xxxxxxxx</span></a></span><span = style=3D'font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'= > &lt;</span><span lang=3DFR = style=3D'font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'= ><a href=3D"mailto:Brian.Katz@xxxxxxxx"><span lang=3DEN-US = style=3D'color:blue'>mailto:Brian.Katz@xxxxxxxx</span></a></span><span = style=3D'font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'= >&gt;<o:p></o:p></span></p><p class=3DMsoNormal><span = style=3D'font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'= >web_theme: </span><span lang=3DFR = style=3D'font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'= ><a href=3D"http://www.limsi.fr/Scientifique/aa/thmsonesp/"><span = lang=3DEN-US = style=3D'color:blue'>http://www.limsi.fr/Scientifique/aa/thmsonesp/</span= ></a></span><span = style=3D'font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'= ><o:p></o:p></span></p><p class=3DMsoNormal><span = style=3D'font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'= >web_group: </span><span lang=3DFR = style=3D'font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'= ><a href=3D"http://www.limsi.fr/Scientifique/aa/"><span lang=3DEN-US = style=3D'color:blue'>http://www.limsi.fr/Scientifique/aa/</span></a></spa= n><span = style=3D'font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'= ><o:p></o:p></span></p><p class=3DMsoNormal><span = style=3D'font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'= ><o:p>&nbsp;</o:p></span></p><p class=3DMsoNormal><span = style=3D'font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D'= ><o:p>&nbsp;</o:p></span></p></div><p class=3DMsoNormal><span = style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497= D'><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=3DMsoNormal><b><span lang=3DFR = style=3D'font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowt= ext'>De&nbsp;:</span></b><span lang=3DFR = style=3D'font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowt= ext'> AUDITORY - Research in 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=3DMsoNormal><o:p>&nbsp;</o:p></p><p class=3DMsoNormal><span = style=3D'font-family:"Calibri","sans-serif"'>I'm writing to notify list = readers of a problem playing audio using Matlab. <br><br>The problem is = that brief signals are truncated, and it happens using any of the common = commands for playing audio (wavplay, sound, and the play method of the = audioplayer object).<br><br>I can't specify the exact conditions under = which the truncation occurs. However, with a sample rate of 44.1 kHz, = signals shorter than about 500 msec are 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 truncation 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 latest release (R2011b) for = playing using audioplayer, but not necessarily for 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 = then 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+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><br><br><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></pre><pre>web: = <a = href=3D"http://www.sens.com">www.sens.com</a><o:p></o:p></pre></div></bod= y></html> ------=_NextPart_000_0084_01CC8CB8.8AAFF440--


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