version 1.9, 2004/11/05 21:57:05 |
version 1.10, 2007/06/01 19:54:48 |
|
|
<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 endianness</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 endianness (e.g., <code>AUDIO_ENCODING_SLINEAR_LE</code>). |
Considering that a soundcard does not have to use the same endianess |
Considering that a soundcard does not have to use the same endianness |
as your platform, you should be prepared to deal with that. |
as your platform, you should be prepared to deal with that. |
The easiest way is probably to prepare a full audio buffer, and to use |
The easiest way is probably to prepare a full audio buffer, and to use |
<code>swab(3)</code> if an endianess change is required. |
<code>swab(3)</code> if an endianness change is required. |
Dealing with external samples usually amounts to: |
Dealing with external samples usually amounts to: |
<ol> |
<ol> |
<li>Parsing the sample format, |
<li>Parsing the sample format, |
<li>Getting the sample in, |
<li>Getting the sample in, |
<li>Swapping endianess if it is not your native format, |
<li>Swapping endianness if it is not your native format, |
<li>Computing what you want to output into a buffer, |
<li>Computing what you want to output into a buffer, |
<li>Swapping endianess if the sound card is not in your native format, |
<li>Swapping endianness if the sound card is not in your native format, |
<li>Playing the buffer. |
<li>Playing the buffer. |
</ol> |
</ol> |
Obviously, you may be able to remove steps 3 and 5 if you are simply |
Obviously, you may be able to remove steps 3 and 5 if you are simply |