<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>PulseAudio: Sample Format Specifications</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> <link href="tabs.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.5.5 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="main.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="classes.html"><span>Data Structures</span></a></li> <li><a href="files.html"><span>Files</span></a></li> <li><a href="examples.html"><span>Examples</span></a></li> </ul> </div> </div> <div class="contents"> <h1><a class="anchor" name="sample">Sample Format Specifications </a></h1><h2><a class="anchor" name="overv_sec"> Overview</a></h2> PulseAudio is capable of handling a multitude of sample formats, rates and channels, transparently converting and mixing them as needed.<h2><a class="anchor" name="format_sec"> Sample Format</a></h2> PulseAudio supports the following sample formats:<p> <ul> <li>PA_SAMPLE_U8 - Unsigned 8 bit integer PCM. </li> <li>PA_SAMPLE_S16LE - Signed 16 integer bit PCM, little endian. </li> <li>PA_SAMPLE_S16BE - Signed 16 integer bit PCM, big endian. </li> <li>PA_SAMPLE_FLOAT32LE - 32 bit IEEE floating point PCM, little endian. </li> <li>PA_SAMPLE_FLOAT32BE - 32 bit IEEE floating point PCM, big endian. </li> <li>PA_SAMPLE_ALAW - 8 bit a-Law. </li> <li>PA_SAMPLE_ULAW - 8 bit mu-Law. </li> <li>PA_SAMPLE_S32LE - Signed 32 bit integer PCM, little endian. </li> <li>PA_SAMPLE_S32BE - Signed 32 bit integer PCM, big endian.</li> </ul> The floating point sample formats have the range from -1 to 1.<p> The sample formats that are sensitive to endianness have convenience macros for native endian (NE), and reverse endian (RE).<h2><a class="anchor" name="rate_sec"> Sample Rates</a></h2> PulseAudio supports any sample rate between 1 Hz and 4 GHz. There is no point trying to exceed the sample rate of the output device though as the signal will only get downsampled, consuming CPU on the machine running the server.<h2><a class="anchor" name="chan_sec"> Channels</a></h2> PulseAudio supports up to 16 individiual channels. The order of the channels is up to the application, but they must be continous. To map channels to speakers, see <a class="el" href="channelmap.html">Channel Maps</a>.<h2><a class="anchor" name="calc_sec"> Calculations</a></h2> The PulseAudio library contains a number of convenience functions to do calculations on sample formats:<p> <ul> <li><a class="el" href="sample_8h.html#674c3449416e97b71a75feb64ca59ad4" title="Return the amount of bytes playback of a second of audio with the specified sample...">pa_bytes_per_second()</a> - The number of bytes one second of audio will take given a sample format. </li> <li><a class="el" href="sample_8h.html#035d79171e183f6315e6e65436f5e939" title="Return the size of a frame with the specific sample type.">pa_frame_size()</a> - The size, in bytes, of one frame (i.e. one set of samples, one for each channel). </li> <li><a class="el" href="sample_8h.html#ae286d84c2975248f65f804d4c24ef39" title="Return the size of a sample with the specific sample type.">pa_sample_size()</a> - The size, in bytes, of one sample. </li> <li><a class="el" href="sample_8h.html#b3c5f4af357686fdc7df46c9581154bd" title="Calculate the time the specified bytes take to play with the specified sample type...">pa_bytes_to_usec()</a> - Calculate the time it would take to play a buffer of a certain size.</li> </ul> <h2><a class="anchor" name="util_sec"> Convenience Functions</a></h2> The library also contains a couple of other convenience functions:<p> <ul> <li><a class="el" href="sample_8h.html#0d9ad972ee71ef6bff8aaafd44fdb229" title="Return non-zero when the sample type specification is valid.">pa_sample_spec_valid()</a> - Tests if a sample format specification is valid. </li> <li><a class="el" href="sample_8h.html#c4c2262bf88bd90fc68767e69fb6810c" title="Return non-zero when the two sample type specifications match.">pa_sample_spec_equal()</a> - Tests if the sample format specifications are identical. </li> <li><a class="el" href="sample_8h.html#70804b50d5507f9a7680d4e809e337ed" title="Return a descriptive string for the specified sample format.">pa_sample_format_to_string()</a> - Return a textual description of a sample format. </li> <li><a class="el" href="sample_8h.html#2819db448dd45edb5d777b7568dd3236" title="Parse a sample format text.">pa_parse_sample_format()</a> - Parse a text string into a sample format. </li> <li><a class="el" href="sample_8h.html#3dd4815bbd51d5467b40e28d05ad948d" title="Pretty print a sample type specification to a string.">pa_sample_spec_snprint()</a> - Create a textual description of a complete sample format specification. </li> <li><a class="el" href="sample_8h.html#4992ec70d79de601c6f8f6cc5cab8e59" title="Pretty print a byte size value.">pa_bytes_snprint()</a> - Pretty print a byte value (e.g. 2.5 MiB). </li> </ul> </div> <hr size="1"><address style="text-align: right;"><small>Generated on Wed Mar 26 12:02:40 2008 for PulseAudio by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.5 </small></address> </body> </html>