<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.3"/> <title>PulseAudio: Volume Control</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="navtree.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="resize.js"></script> <script type="text/javascript" src="navtree.js"></script> <script type="text/javascript"> $(document).ready(initResizable); $(window).load(resizeHeight); </script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">PulseAudio  <span id="projectnumber">2.1</span> </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.3 --> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li class="current"><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="annotated.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><!-- top --> <div id="side-nav" class="ui-resizable side-nav-resizable"> <div id="nav-tree"> <div id="nav-tree-contents"> <div id="nav-sync" class="sync"></div> </div> </div> <div id="splitbar" style="-moz-user-select:none;" class="ui-resizable-handle"> </div> </div> <script type="text/javascript"> $(document).ready(function(){initNavTree('volume.html','');}); </script> <div id="doc-content"> <div class="header"> <div class="headertitle"> <div class="title">Volume Control </div> </div> </div><!--header--> <div class="contents"> <div class="textblock"><h1><a class="anchor" id="overv_sec"></a> Overview</h1> <p>Sinks, sources, sink inputs and samples can all have their own volumes. To deal with these, The PulseAudio library contains a number of functions that ease handling.</p> <p>The basic volume type in PulseAudio is the <a class="el" href="volume_8h.html#a6d671c65284ff2e94d3773c7368a0352">pa_volume_t</a> type. Most of the time, applications will use the aggregated <a class="el" href="structpa__cvolume.html" title="A structure encapsulating a per-channel volume.">pa_cvolume</a> structure that can store the volume of all channels at once.</p> <p>Volumes commonly span between muted (0%), and normal (100%). It is possible to set volumes to higher than 100%, but clipping might occur.</p> <h1><a class="anchor" id="calc_sec"></a> Calculations</h1> <p>The volumes in PulseAudio are logarithmic in nature and applications shouldn't perform calculations with them directly. Instead, they should be converted to and from either dB or a linear scale:</p> <ul> <li>dB - <a class="el" href="volume_8h.html#ad638dfbc737f126e743584665ea8f557" title="Convert a decibel value to a volume (amplitude, not power).">pa_sw_volume_from_dB()</a> / <a class="el" href="volume_8h.html#a297851419c1e994d9fd2cfbb49aa480a" title="Convert a volume to a decibel value (amplitude, not power).">pa_sw_volume_to_dB()</a> </li> <li>Linear - <a class="el" href="volume_8h.html#aafb4825a03178ee327e55ae0866b7471" title="Convert a linear factor to a volume.">pa_sw_volume_from_linear()</a> / <a class="el" href="volume_8h.html#a04da6c4572a758a0244bbfc81d370cfb" title="Convert a volume to a linear factor.">pa_sw_volume_to_linear()</a></li> </ul> <p>For simple multiplication, <a class="el" href="volume_8h.html#a1ca01f5bd640e7c5b2d3a6dad9093226" title="Multiply two volume specifications, return the result.">pa_sw_volume_multiply()</a> and <a class="el" href="volume_8h.html#a6ae924bdad225c405c1e2f40c22b041b" title="Multiply two per-channel volumes and return the result in *dest.">pa_sw_cvolume_multiply()</a> can be used.</p> <p>Calculations can only be reliably performed on software volumes as it is commonly unknown what scale hardware volumes relate to.</p> <p>The functions described above are only valid when used with software volumes. Hence it is usually a better idea to treat all volume values as opaque with a range from PA_VOLUME_MUTED (0%) to PA_VOLUME_NORM (100%) and to refrain from any calculations with them.</p> <h1><a class="anchor" id="conv_sec"></a> Convenience Functions</h1> <p>To handle the <a class="el" href="structpa__cvolume.html" title="A structure encapsulating a per-channel volume.">pa_cvolume</a> structure, the PulseAudio library provides a number of convenience functions:</p> <ul> <li><a class="el" href="volume_8h.html#aba14d00682b29838ef39ca5a9afe8972" title="Return TRUE when the passed cvolume structure is valid, FALSE otherwise.">pa_cvolume_valid()</a> - Tests if a <a class="el" href="structpa__cvolume.html" title="A structure encapsulating a per-channel volume.">pa_cvolume</a> structure is valid. </li> <li><a class="el" href="volume_8h.html#a84b52cdbff47aad9c058df783f342b57" title="Return non-zero when *a == *b.">pa_cvolume_equal()</a> - Tests if two <a class="el" href="structpa__cvolume.html" title="A structure encapsulating a per-channel volume.">pa_cvolume</a> structures are identical. </li> <li><a class="el" href="volume_8h.html#a2dd140d5c2fadd1d8cb7aa0eace05109" title="Return non-zero if the volume of all channels is equal to the specified value.">pa_cvolume_channels_equal_to()</a> - Tests if all channels of a <a class="el" href="structpa__cvolume.html" title="A structure encapsulating a per-channel volume.">pa_cvolume</a> structure have a given volume. </li> <li><a class="el" href="volume_8h.html#a6b8766a2f30420a83457d2e1f0f139b2" title="Return 1 if the specified volume has all channels muted.">pa_cvolume_is_muted()</a> - Tests if all channels of a <a class="el" href="structpa__cvolume.html" title="A structure encapsulating a per-channel volume.">pa_cvolume</a> structure are muted. </li> <li><a class="el" href="volume_8h.html#a0b374bbe16de9ac047fc4e5f6994390c" title="Return 1 if the specified volume has all channels on normal level.">pa_cvolume_is_norm()</a> - Tests if all channels of a <a class="el" href="structpa__cvolume.html" title="A structure encapsulating a per-channel volume.">pa_cvolume</a> structure are at a normal volume. </li> <li><a class="el" href="volume_8h.html#a0777581d85a1d4bf9c831bdacaac51ac" title="Set the volume of the specified number of channels to the volume v.">pa_cvolume_set()</a> - Set the first n channels of a <a class="el" href="structpa__cvolume.html" title="A structure encapsulating a per-channel volume.">pa_cvolume</a> structure to a certain volume. </li> <li><a class="el" href="volume_8h.html#aa2701828c290031c9bca9036f5148c72" title="Set the volume of the first n channels to PA_VOLUME_NORM.">pa_cvolume_reset()</a> - Set the first n channels of a <a class="el" href="structpa__cvolume.html" title="A structure encapsulating a per-channel volume.">pa_cvolume</a> structure to a normal volume. </li> <li><a class="el" href="volume_8h.html#a04805cb4b83ded75deca9c122977d8fb" title="Set the volume of the first n channels to PA_VOLUME_MUTED.">pa_cvolume_mute()</a> - Set the first n channels of a <a class="el" href="structpa__cvolume.html" title="A structure encapsulating a per-channel volume.">pa_cvolume</a> structure to a muted volume. </li> <li><a class="el" href="volume_8h.html#a0f34f2c6d1b4738bf7f11ff06775dc1f" title="Return the average volume of all channels.">pa_cvolume_avg()</a> - Return the average volume of all channels. </li> <li><a class="el" href="volume_8h.html#a99f2e389f425b888d3a02ade86d7c85f" title="Pretty print a volume structure.">pa_cvolume_snprint()</a> - Pretty print a <a class="el" href="structpa__cvolume.html" title="A structure encapsulating a per-channel volume.">pa_cvolume</a> structure. </li> </ul> </div></div><!-- contents --> </div><!-- doc-content --> <!-- start footer part --> <div id="nav-path" class="navpath"><!-- id is needed for treeview function! --> <ul> <li class="footer">Generated by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.3 </li> </ul> </div> </body> </html>