[BACK]Return to audio-port.html CVS log [TXT][DIR] Up to [local] / www

Diff for /www/Attic/audio-port.html between version 1.7 and 1.8

version 1.7, 2002/06/18 01:44:05 version 1.8, 2003/03/06 13:51:31
Line 1 
Line 1 
   <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
           "http://www.w3.org/TR/html4/loose.dtd">
 <html>  <html>
  <head>   <head>
   <meta http-equiv="Content-Type"    <meta http-equiv="Content-Type"
Line 25 
Line 27 
   dealing with synthesizers and waveform tables are welcome.    dealing with synthesizers and waveform tables are welcome.
   
 </p>  </p>
   <p>
         Audio applications tend to be hard to port, as this is a domain where          Audio applications tend to be hard to port, as this is a domain where
         interfaces are not standardized at all, though approaches don't vary          interfaces are not standardized at all, though approaches don't vary
         much between operating systems.          much between operating systems.
   </p>
   
     <h2><font color="#e00000">Using <code>ossaudio</code></font></h2>
   
   <h2><font color=#e00000>Using <code>ossaudio</code></font></h2>  
   
   The <code>ossaudio</code> emulation is possibly the simplest way, but    The <code>ossaudio</code> emulation is possibly the simplest way, but
   it won't always work, and it is not such a great idea usually.    it won't always work, and it is not such a great idea usually.
   <ul>    <ul>
Line 48 
Line 50 
   
   </ul>    </ul>
   
   <h2><font color=#e00000>Using existing NetBSD or FreeBSD code</font></h2>    <h2><font color="#e00000">Using existing NetBSD or FreeBSD code</font></h2>
   Since we share part of the audio interface with NetBSD and FreeBSD,    Since we share part of the audio interface with NetBSD and FreeBSD,
   starting from a NetBSD port is reasonable. Be aware that some files    starting from a NetBSD port is reasonable. Be aware that some files
   changed places, and that some entries in <code>sys/audioio.h</code>    changed places, and that some entries in <code>sys/audioio.h</code>
Line 56 
Line 58 
   work on only one type of machine. Some changes are bound to be    work on only one type of machine. Some changes are bound to be
   necessary, though.  Read through the next part.    necessary, though.  Read through the next part.
   
   <h2><font color=#e00000>Writing OpenBSD code</font></h2>    <h2><font color="#e00000">Writing OpenBSD code</font></h2>
           <h3><font color=#0000e0>Hardware independence</font></h3>            <h3><font color="#0000e0">Hardware independence</font></h3>
   
    <p>     <p>
         <strong>YOU SHOULDN'T ASSUME ANYTHING ABOUT THE AUDIO HARDWARE USED.          <strong>YOU SHOULDN'T ASSUME ANYTHING ABOUT THE AUDIO HARDWARE USED.
Line 66 
Line 68 
         field against 8 or 16 bits, and assumes unsigned or signed samples based          field against 8 or 16 bits, and assumes unsigned or signed samples based
         on soundblaster behavior. You should check the sample type explicitly,          on soundblaster behavior. You should check the sample type explicitly,
         and code according to that. Simple example:          and code according to that. Simple example:
       </p>
         <pre>          <pre>
     AUDIO_INIT_INFO(&amp;a_info);      AUDIO_INIT_INFO(&amp;a_info);
     a_info.play.encoding = AUDIO_ENCODING_SLINEAR;      a_info.play.encoding = AUDIO_ENCODING_SLINEAR;
Line 96 
Line 99 
     /* now don't forget to check what sampling frequency you actually got */      /* now don't forget to check what sampling frequency you actually got */
         </pre>          </pre>
   
   </p>    <p>
   This is about the smallest code fragment that will deal with most issues.    This is about the smallest code fragment that will deal with most issues.
   
         <h3><font color=#0000e0>16 bit formats and endianess</font></h3>          <h3><font color="#0000e0">16 bit formats and endianess</font></h3>
         In normal usage, you just ask for an encoding type (e.g.,          In normal usage, you just ask for an encoding type (e.g.,
         <code>AUDIO_ENCODING_SLINEAR</code>, and you retrieve          <code>AUDIO_ENCODING_SLINEAR</code>, and you retrieve
         an encoding with endianess (e.g., <code>AUDIO_ENCODING_SLINEAR_LE</code>).          an encoding with endianess (e.g., <code>AUDIO_ENCODING_SLINEAR_LE</code>).
Line 120 
Line 123 
         playing a sound sample which happens to be in your sound card native          playing a sound sample which happens to be in your sound card native
         format.          format.
   
         <h3><font color=#0000e0>Audio quality</font></h3>          <h3><font color="#0000e0">Audio quality</font></h3>
         <p>          <p>
         Hardware may have some weird limitations, such as being unable to get          Hardware may have some weird limitations, such as being unable to get
         over 22050 Hz in stereo, but up to 44100 in mono.  In such cases, you          over 22050 Hz in stereo, but up to 44100 in mono.  In such cases, you
Line 175 
Line 178 
         a volume scaling option.          a volume scaling option.
         </p>          </p>
   
         <h3><font color=#0000e0>Audio performance</font></h3>          <h3><font color="#0000e0">Audio performance</font></h3>
         <p>          <p>
         Low-end applications usually don't have much to worry about.  Keep in          Low-end applications usually don't have much to worry about.  Keep in
         mind that some of us do use OpenBSD on low-end 68030, and that if a          mind that some of us do use OpenBSD on low-end 68030, and that if a
Line 191 
Line 194 
         <p>          <p>
         For high performance audio applications, such as mpegI-layer3, some          For high performance audio applications, such as mpegI-layer3, some
         points should be taken into account:          points should be taken into account:
           </p>
         <ul>          <ul>
             <li>The audio interface does provide you with the natural hardware              <li>The audio interface does provide you with the natural hardware
             blocksize. Using multiples of that for your output buffer is              blocksize. Using multiples of that for your output buffer is
Line 215 
Line 219 
             audio device can be assumed to be reasonably optimal, so don't              audio device can be assumed to be reasonably optimal, so don't
             replace it with quickly hacked up code.              replace it with quickly hacked up code.
         </ul>          </ul>
         </p>  
   
         <p>A model you may have to follow to get optimal results is to first          <p>A model you may have to follow to get optimal results is to first
         compile a small test program that enquires about the specific audio          compile a small test program that enquires about the specific audio
Line 225 
Line 228 
         hardware, provided it makes a difference.          hardware, provided it makes a difference.
         </p>          </p>
   
         <h3><font color=#0000e0>Real time or synchronized</font></h3>          <h3><font color="#0000e0">Real time or synchronized</font></h3>
         <p>          <p>
         Considering that OpenBSD is not real time, you may still wish to write          Considering that OpenBSD is not real time, you may still wish to write
         audio applications that are mostly real time, for instance games. In          audio applications that are mostly real time, for instance games. In
Line 247 
Line 250 
         some lag between what the audio reports, what's currently playing, and          some lag between what the audio reports, what's currently playing, and
         the time it takes for XWindow to display something.          the time it takes for XWindow to display something.
         </p>          </p>
   <h2><font color=#e00000>Contributing code back</font></h2>    <h2><font color="#e00000">Contributing code back</font></h2>
    <p>In the case of audio applications, working with the original program's     <p>In the case of audio applications, working with the original program's
         author is very important. If his code does only work with soundblaster          author is very important. If his code does only work with soundblaster
         cards for instance, there is a good chance he will have to cope with          cards for instance, there is a good chance he will have to cope with
Line 257 
Line 260 
         <p>          <p>
         <strong>If you don't sent your comments to him by then, your work will          <strong>If you don't sent your comments to him by then, your work will
         have been useless</strong>.</p>          have been useless</strong>.</p>
           <p>
         It may also be that the author has already noticed whatever problems          It may also be that the author has already noticed whatever problems
         you are currently dealing with, and is addressing them in his current          you are currently dealing with, and is addressing them in his current
         development tree.  If the patches you are writing amount to more than          development tree.  If the patches you are writing amount to more than
         a handful of lines, cooperation is almost certainly a very good idea.          a handful of lines, cooperation is almost certainly a very good idea.
           </p>
   
   
   <hr>    <hr>
   <a href="porting.html"><img height=24 width=24 src=back.gif    <a href="porting.html"><img height=24 width=24 src=back.gif
    border=0 alt=Porting></a>     border=0 alt=Porting></a>
   <a href=mailto:www@openbsd.org>www@openbsd.org</a>    <a href="mailto:www@openbsd.org">www@openbsd.org</a>
 <br><small>$OpenBSD$</small>  <br><small>$OpenBSD$</small>
  </body>   </body>
 </html>  </html>

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8