<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <br>
    Dear all,<br>
    <br>
    I'm reviewing the wavread function code which I could find (on
    Windows 7) at the following path:<br>
    <br>
    <font face="Courier New, Courier, monospace">C:\Program
      Files\scilab-6.0.2\modules\sound\macros\wavread.sci <br>
      <br>
      <font face="Courier New, Courier, monospace">There is a code
        segment at the beginninig <font face="Courier New, Courier,
          monospace">intended to detect if the wavfile has or not the
          .wav extension:</font></font></font><span
      style="color:rgb(160,32,240);"><br>
    </span><span style="color:rgb(75,149,50);font-style:italic;"><br>
      // Append .wav extension if necessary</span><span
      style="color:rgb(160,32,240);"><br>
      if</span> <span style="color:rgb(74,85,219);">(</span> <span
      style="color:rgb(50,185,185);">strindex</span><span
      style="color:rgb(74,85,219);">(</span><span
      style="color:rgb(0,0,0);">wavfile</span><span
      style="color:rgb(0,0,0);">,</span> <span
      style="color:rgb(188,143,143);">"</span><span
      style="color:rgb(188,143,143);">.</span><span
      style="color:rgb(188,143,143);">"</span><span
      style="color:rgb(74,85,219);">)</span> <span
      style="color:rgb(92,92,92);">==</span> <span
      style="color:rgb(74,85,219);">[</span><span
      style="color:rgb(74,85,219);">]</span> <span
      style="color:rgb(74,85,219);">)</span> <span
      style="color:rgb(160,32,240);">then</span>
    <br>
        <span style="color:rgb(0,0,0);">wavfile</span> <span
      style="color:rgb(92,92,92);">=</span> <span
      style="color:rgb(0,0,0);">wavfile</span> <span
      style="color:rgb(92,92,92);">+</span> <span
      style="color:rgb(188,143,143);">"</span><span
      style="color:rgb(188,143,143);">.wav</span><span
      style="color:rgb(188,143,143);">"</span><span
      style="color:rgb(0,0,0);">;</span>
    <br>
    <span style="color:rgb(160,32,240);">end</span><font face="Courier
      New, Courier, monospace"><font face="Courier New, Courier,
        monospace"><font face="Courier New, Courier, monospace"><br>
          <br>
          This contains a bug, since the wavfile name might contain a
          dot different from the one bet<font face="Courier New,
            Courier, monospace">ween the name and the extension. The
            normal case would be<br>
            <br>
            <font face="Courier New, Courier, monospace">sound.wav<br>
              <br>
              <font face="Courier New, Courier, monospace">and in this
                case the code works fine if the trailing .wav is absent.
                Bu<font face="Courier New, Courier, monospace">t <font
                    face="Courier New, Courier, monospace">in a case
                    such as<br>
                    <br>
                    <font face="Courier New, Courier, monospace">sound_v1.1.wav<br>
                      <br>
                      the code will detect a dot within the abbreviated
                      name 'sound_v1.1' and will not append the .wav
                      extension, hence the function will fail to find
                      and open the file. <br>
                      <br>
                      <font face="Courier New, Courier, monospace">Fortunately
                        the issue is solved quite easily:<br>
                      </font></font></font></font></font></font></font></font></font></font><br>
    <span style="color:rgb(75,149,50);font-style:italic;">// Append .wav
      extension if necessary</span><span style="color:rgb(160,32,240);"><br>
      if</span> <span style="color:rgb(74,85,219);">(</span><span
      style="color:rgb(92,92,92);"> ~</span><span
      style="color:rgb(74,85,219);">(</span><span
      style="color:rgb(50,185,185);">max</span><span
      style="color:rgb(74,85,219);">(</span><span
      style="color:rgb(50,185,185);">strindex</span><span
      style="color:rgb(74,85,219);">(</span><span
      style="color:rgb(0,0,0);">wavfile</span><span
      style="color:rgb(0,0,0);">,</span><span
      style="color:rgb(188,143,143);">'</span><span
      style="color:rgb(188,143,143);">.wav</span><span
      style="color:rgb(188,143,143);">'</span><span
      style="color:rgb(74,85,219);">)</span><span
      style="color:rgb(74,85,219);">)</span> <span
      style="color:rgb(92,92,92);">==</span> <span
      style="color:rgb(50,185,185);">length</span><span
      style="color:rgb(74,85,219);">(</span><span
      style="color:rgb(0,0,0);">wavfile</span><span
      style="color:rgb(74,85,219);">)</span><span
      style="color:rgb(92,92,92);">-</span><span
      style="color:rgb(188,143,143);">3</span><span
      style="color:rgb(74,85,219);">)</span><span
      style="color:rgb(74,85,219);"></span> <span
      style="color:rgb(74,85,219);">)</span> <span
      style="color:rgb(160,32,240);">then</span>
    <br>
        <span style="color:rgb(0,0,0);">wavfile</span> <span
      style="color:rgb(92,92,92);">=</span> <span
      style="color:rgb(0,0,0);">wavfile</span> <span
      style="color:rgb(92,92,92);">+</span> <span
      style="color:rgb(188,143,143);">'</span><span
      style="color:rgb(188,143,143);">.wav'</span><span
      style="color:rgb(188,143,143);"></span><span
      style="color:rgb(0,0,0);">;</span>
    <br>
    <span style="color:rgb(160,32,240);">end</span><font face="Courier
      New, Courier, monospace"><font face="Courier New, Courier,
        monospace"><font face="Courier New, Courier, monospace"><br>
        </font></font></font><font face="Courier New, Courier,
      monospace"><font face="Courier New, Courier, monospace"><font
          face="Courier New, Courier, monospace"><font face="Courier
            New, Courier, monospace"><font face="Courier New, Courier,
              monospace"><font face="Courier New, Courier, monospace"><font
                  face="Courier New, Courier, monospace"><font
                    face="Courier New, Courier, monospace"><font
                      face="Courier New, Courier, monospace"><font
                        face="Courier New, Courier, monospace"><br>
                      </font></font></font></font></font></font></font>The
          proposed patch <font face="Courier New, Courier, monospace">tests
          </font>whether <font face="Courier New, Courier, monospace">'.wav'
            is the <font face="Courier New, Courier, monospace">last <font
                face="Courier New, Courier, monospace">sub-string</font>
              of the file name. <br>
              <br>
              No<font face="Courier New, Courier, monospace">te: '.wav'
                might appear more t<font face="Courier New, Courier,
                  monospace">han once or might even appear only once but
                  in the middle o<font face="Courier New, Courier,
                    monospace">f the name</font></font></font></font></font>.
          In such cases it is not a va<font face="Courier New, Courier,
            monospace">lid w<font face="Courier New, Courier, monospace">av
              extension. This case might appear unlikely, but it is a
              possibility<font face="Courier New, Courier, monospace">.
                <font face="Courier New, Courier, monospace">F</font>or
                instance, some educator might present an example called:<br>
                <br>
                <font face="Courier New, Courier, monospace">'example_of_.wav<font
                    face="Courier New, Courier, monospace">_</font>file.wav'<br>
                  <br>
                  <font face="Courier New, Courier, monospace">Regards,<br>
                    <br>
                    <font face="Courier New, Courier, monospace">Federico
                      Miyara</font><br>
                  </font></font></font><br>
              <br>
            </font></font>  <br>
        </font></font></font>
  <div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br /> <table style="border-top: 1px solid #D3D4DE;">
        <tr>
      <td style="width: 55px; padding-top: 18px;"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" width="46" height="29" style="width: 46px; height: 29px;" /></a></td>
                <td style="width: 470px; padding-top: 17px; color: #41424e; font-size: 13px; font-family: Arial, Helvetica, sans-serif; line-height: 18px;">Libre de virus. <a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank" style="color: #4453ea;">www.avast.com</a>           </td>
        </tr>
</table>
<a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"> </a></div></body>
</html>