|
| 1 | +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 2 | +<html xmlns="http://www.w3.org/1999/xhtml"> |
| 3 | +<head> |
| 4 | +<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> |
| 5 | +<meta http-equiv="X-UA-Compatible" content="IE=9"/> |
| 6 | +<meta name="generator" content="Doxygen 1.9.1"/> |
| 7 | +<meta name="viewport" content="width=device-width, initial-scale=1"/> |
| 8 | +<title>swift: src/blacksound/dsp/SimpleGain.h Source File</title> |
| 9 | +<link href="tabs.css" rel="stylesheet" type="text/css"/> |
| 10 | +<script type="text/javascript" src="jquery.js"></script> |
| 11 | +<script type="text/javascript" src="dynsections.js"></script> |
| 12 | +<link href="search/search.css" rel="stylesheet" type="text/css"/> |
| 13 | +<script type="text/javascript" src="search/searchdata.js"></script> |
| 14 | +<script type="text/javascript" src="search/search.js"></script> |
| 15 | +<link href="doxygen.css" rel="stylesheet" type="text/css" /> |
| 16 | +<link href="doxygen-awesome.css" rel="stylesheet" type="text/css"/> |
| 17 | +</head> |
| 18 | +<body> |
| 19 | +<div id="top"><!-- do not remove this div, it is closed by doxygen! --> |
| 20 | +<div id="titlearea"> |
| 21 | +<table cellspacing="0" cellpadding="0"> |
| 22 | + <tbody> |
| 23 | + <tr style="height: 56px;"> |
| 24 | + <td id="projectalign" style="padding-left: 0.5em;"> |
| 25 | + <div id="projectname">swift |
| 26 | + </div> |
| 27 | + </td> |
| 28 | + </tr> |
| 29 | + </tbody> |
| 30 | +</table> |
| 31 | +</div> |
| 32 | +<!-- end header part --> |
| 33 | +<!-- Generated by Doxygen 1.9.1 --> |
| 34 | +<script type="text/javascript"> |
| 35 | +/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ |
| 36 | +var searchBox = new SearchBox("searchBox", "search",false,'Search','.html'); |
| 37 | +/* @license-end */ |
| 38 | +</script> |
| 39 | +<script type="text/javascript" src="menudata.js"></script> |
| 40 | +<script type="text/javascript" src="menu.js"></script> |
| 41 | +<script type="text/javascript"> |
| 42 | +/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ |
| 43 | +$(function() { |
| 44 | + initMenu('',true,false,'search.php','Search'); |
| 45 | + $(document).ready(function() { init_search(); }); |
| 46 | +}); |
| 47 | +/* @license-end */</script> |
| 48 | +<div id="main-nav"></div> |
| 49 | +<!-- window showing the filter options --> |
| 50 | +<div id="MSearchSelectWindow" |
| 51 | + onmouseover="return searchBox.OnSearchSelectShow()" |
| 52 | + onmouseout="return searchBox.OnSearchSelectHide()" |
| 53 | + onkeydown="return searchBox.OnSearchSelectKey(event)"> |
| 54 | +</div> |
| 55 | + |
| 56 | +<!-- iframe showing the search results (closed by default) --> |
| 57 | +<div id="MSearchResultsWindow"> |
| 58 | +<iframe src="javascript:void(0)" frameborder="0" |
| 59 | + name="MSearchResults" id="MSearchResults"> |
| 60 | +</iframe> |
| 61 | +</div> |
| 62 | + |
| 63 | +<div id="nav-path" class="navpath"> |
| 64 | + <ul> |
| 65 | +<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_12c808cff225019d616728af7d9c2555.html">blacksound</a></li><li class="navelem"><a class="el" href="dir_c0c7ca085f0248a6642a28bd99f998cb.html">dsp</a></li> </ul> |
| 66 | +</div> |
| 67 | +</div><!-- top --> |
| 68 | +<div class="header"> |
| 69 | + <div class="headertitle"> |
| 70 | +<div class="title">SimpleGain.h</div> </div> |
| 71 | +</div><!--header--> |
| 72 | +<div class="contents"> |
| 73 | +<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> <span class="comment">/*</span></div> |
| 74 | +<div class="line"><a name="l00002"></a><span class="lineno"> 2</span> <span class="comment"> * Gain Functions (header)</span></div> |
| 75 | +<div class="line"><a name="l00003"></a><span class="lineno"> 3</span> <span class="comment"> *</span></div> |
| 76 | +<div class="line"><a name="l00004"></a><span class="lineno"> 4</span> <span class="comment"> * File : SimpleGain.h</span></div> |
| 77 | +<div class="line"><a name="l00005"></a><span class="lineno"> 5</span> <span class="comment"> * Library : SimpleSource</span></div> |
| 78 | +<div class="line"><a name="l00006"></a><span class="lineno"> 6</span> <span class="comment"> * Version : 1.12</span></div> |
| 79 | +<div class="line"><a name="l00007"></a><span class="lineno"> 7</span> <span class="comment"> * Class : </span></div> |
| 80 | +<div class="line"><a name="l00008"></a><span class="lineno"> 8</span> <span class="comment"> *</span></div> |
| 81 | +<div class="line"><a name="l00009"></a><span class="lineno"> 9</span> <span class="comment"> * 2006, ChunkWare Music Software, OPEN-SOURCE</span></div> |
| 82 | +<div class="line"><a name="l00010"></a><span class="lineno"> 10</span> <span class="comment"> *</span></div> |
| 83 | +<div class="line"><a name="l00011"></a><span class="lineno"> 11</span> <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining a</span></div> |
| 84 | +<div class="line"><a name="l00012"></a><span class="lineno"> 12</span> <span class="comment"> * copy of this software and associated documentation files (the "Software"),</span></div> |
| 85 | +<div class="line"><a name="l00013"></a><span class="lineno"> 13</span> <span class="comment"> * to deal in the Software without restriction, including without limitation</span></div> |
| 86 | +<div class="line"><a name="l00014"></a><span class="lineno"> 14</span> <span class="comment"> * the rights to use, copy, modify, merge, publish, distribute, sublicense,</span></div> |
| 87 | +<div class="line"><a name="l00015"></a><span class="lineno"> 15</span> <span class="comment"> * and/or sell copies of the Software, and to permit persons to whom the</span></div> |
| 88 | +<div class="line"><a name="l00016"></a><span class="lineno"> 16</span> <span class="comment"> * Software is furnished to do so, subject to the following conditions:</span></div> |
| 89 | +<div class="line"><a name="l00017"></a><span class="lineno"> 17</span> <span class="comment"> *</span></div> |
| 90 | +<div class="line"><a name="l00018"></a><span class="lineno"> 18</span> <span class="comment"> * The above copyright notice and this permission notice shall be included in</span></div> |
| 91 | +<div class="line"><a name="l00019"></a><span class="lineno"> 19</span> <span class="comment"> * all copies or substantial portions of the Software.</span></div> |
| 92 | +<div class="line"><a name="l00020"></a><span class="lineno"> 20</span> <span class="comment"> *</span></div> |
| 93 | +<div class="line"><a name="l00021"></a><span class="lineno"> 21</span> <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR</span></div> |
| 94 | +<div class="line"><a name="l00022"></a><span class="lineno"> 22</span> <span class="comment"> * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</span></div> |
| 95 | +<div class="line"><a name="l00023"></a><span class="lineno"> 23</span> <span class="comment"> * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL</span></div> |
| 96 | +<div class="line"><a name="l00024"></a><span class="lineno"> 24</span> <span class="comment"> * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</span></div> |
| 97 | +<div class="line"><a name="l00025"></a><span class="lineno"> 25</span> <span class="comment"> * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING</span></div> |
| 98 | +<div class="line"><a name="l00026"></a><span class="lineno"> 26</span> <span class="comment"> * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER</span></div> |
| 99 | +<div class="line"><a name="l00027"></a><span class="lineno"> 27</span> <span class="comment"> * DEALINGS IN THE SOFTWARE.</span></div> |
| 100 | +<div class="line"><a name="l00028"></a><span class="lineno"> 28</span> <span class="comment"> */</span></div> |
| 101 | +<div class="line"><a name="l00029"></a><span class="lineno"> 29</span>  </div> |
| 102 | +<div class="line"><a name="l00030"></a><span class="lineno"> 30</span>  </div> |
| 103 | +<div class="line"><a name="l00031"></a><span class="lineno"> 31</span> <span class="preprocessor">#ifndef __SIMPLE_GAIN_H__</span></div> |
| 104 | +<div class="line"><a name="l00032"></a><span class="lineno"> 32</span> <span class="preprocessor">#define __SIMPLE_GAIN_H__</span></div> |
| 105 | +<div class="line"><a name="l00033"></a><span class="lineno"> 33</span>  </div> |
| 106 | +<div class="line"><a name="l00034"></a><span class="lineno"> 34</span> <span class="preprocessor">#include "SimpleHeader.h"</span> <span class="comment">// common header</span></div> |
| 107 | +<div class="line"><a name="l00035"></a><span class="lineno"> 35</span>  </div> |
| 108 | +<div class="line"><a name="l00036"></a><span class="lineno"> 36</span> <span class="keyword">namespace </span>chunkware_simple</div> |
| 109 | +<div class="line"><a name="l00037"></a><span class="lineno"> 37</span> {</div> |
| 110 | +<div class="line"><a name="l00038"></a><span class="lineno"> 38</span>  <span class="comment">//-------------------------------------------------------------</span></div> |
| 111 | +<div class="line"><a name="l00039"></a><span class="lineno"> 39</span>  <span class="comment">// gain functions</span></div> |
| 112 | +<div class="line"><a name="l00040"></a><span class="lineno"> 40</span>  <span class="comment">//-------------------------------------------------------------</span></div> |
| 113 | +<div class="line"><a name="l00041"></a><span class="lineno"> 41</span>  </div> |
| 114 | +<div class="line"><a name="l00042"></a><span class="lineno"> 42</span>  <span class="comment">// linear -> dB conversion</span></div> |
| 115 | +<div class="line"><a name="l00043"></a><span class="lineno"> 43</span>  <span class="keyword">static</span> INLINE <span class="keywordtype">double</span> lin2dB( <span class="keywordtype">double</span> lin ) {</div> |
| 116 | +<div class="line"><a name="l00044"></a><span class="lineno"> 44</span>  <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">double</span> LOG_2_DB = 8.6858896380650365530225783783321; <span class="comment">// 20 / ln( 10 )</span></div> |
| 117 | +<div class="line"><a name="l00045"></a><span class="lineno"> 45</span>  <span class="keywordflow">return</span> log( lin ) * LOG_2_DB;</div> |
| 118 | +<div class="line"><a name="l00046"></a><span class="lineno"> 46</span>  }</div> |
| 119 | +<div class="line"><a name="l00047"></a><span class="lineno"> 47</span>  </div> |
| 120 | +<div class="line"><a name="l00048"></a><span class="lineno"> 48</span>  <span class="comment">// dB -> linear conversion</span></div> |
| 121 | +<div class="line"><a name="l00049"></a><span class="lineno"> 49</span>  <span class="keyword">static</span> INLINE <span class="keywordtype">double</span> dB2lin( <span class="keywordtype">double</span> dB ) {</div> |
| 122 | +<div class="line"><a name="l00050"></a><span class="lineno"> 50</span>  <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">double</span> DB_2_LOG = 0.11512925464970228420089957273422; <span class="comment">// ln( 10 ) / 20</span></div> |
| 123 | +<div class="line"><a name="l00051"></a><span class="lineno"> 51</span>  <span class="keywordflow">return</span> exp( dB * DB_2_LOG );</div> |
| 124 | +<div class="line"><a name="l00052"></a><span class="lineno"> 52</span>  }</div> |
| 125 | +<div class="line"><a name="l00053"></a><span class="lineno"> 53</span>  </div> |
| 126 | +<div class="line"><a name="l00054"></a><span class="lineno"> 54</span> } <span class="comment">// end namespace chunkware_simple</span></div> |
| 127 | +<div class="line"><a name="l00055"></a><span class="lineno"> 55</span>  </div> |
| 128 | +<div class="line"><a name="l00056"></a><span class="lineno"> 56</span> <span class="preprocessor">#endif </span><span class="comment">// end __SIMPLE_GAIN_H__</span></div> |
| 129 | +</div><!-- fragment --></div><!-- contents --> |
| 130 | +<!-- start footer part --> |
| 131 | +<hr class="footer"/><address class="footer"><small> |
| 132 | +Generated on Sun Dec 3 2023 17:47:27 for swift by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1 |
| 133 | +</small></address> |
| 134 | +</body> |
| 135 | +</html> |
0 commit comments