| 1 |
<?xml version="1.0" encoding="UTF-8"?> |
| 2 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" |
| 3 |
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
| 4 |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> |
| 5 |
<head> |
| 6 |
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" /> |
| 7 |
<meta name="generator" content="AsciiDoc 8.6.10" /> |
| 8 |
<title>Psychoacoustic Models in TwoLAME</title> |
| 9 |
<link rel="stylesheet" href="./asciidoc.css" type="text/css" /> |
| 10 |
|
| 11 |
|
| 12 |
<link rel="stylesheet" href="./twolame.css" type="text/css" /> |
| 13 |
<script type="text/javascript" src="./asciidoc.js"></script> |
| 14 |
<script type="text/javascript"> |
| 15 |
/*<![CDATA[*/ |
| 16 |
asciidoc.install(); |
| 17 |
/*]]>*/ |
| 18 |
</script> |
| 19 |
</head> |
| 20 |
<body class="article"> |
| 21 |
<div id="header"> |
| 22 |
<h1>Psychoacoustic Models in TwoLAME</h1> |
| 23 |
<span id="revnumber">version 0.4.0</span> |
| 24 |
</div> |
| 25 |
<div id="content"> |
| 26 |
<div class="sect1"> |
| 27 |
<h2 id="_introduction">Introduction</h2> |
| 28 |
<div class="sectionbody"> |
| 29 |
<div class="paragraph"><p>In MPEG audio encoding, a psychoacoustic model (PAM) is used to determine which |
| 30 |
are the sonically important parts of the waveform that is being encoded. The PAM |
| 31 |
looks for loud sounds which may mask soft sounds, noise which may affect the level |
| 32 |
of sounds nearby, sounds which are too soft for us to hear and should be ignored |
| 33 |
and so on. The information from the PAM is used to determine which parts of the |
| 34 |
spectrum should get more bits and thus be encoded at greater quality - and which |
| 35 |
parts are inaudible/unimportant and should thus get fewer bits.</p></div> |
| 36 |
<div class="paragraph"><p>In MPEG Audio LayerII encoding, 1152 sound samples are read in - this constitutes |
| 37 |
a <em>frame</em>. For each frame the PAM outputs just <strong>32</strong> values |
| 38 |
(The values are the Signal to Masking Ratio [SMR] in that subband). This is important! |
| 39 |
There are only 32 values to determine how to alloctate bits for 1152 samples - this |
| 40 |
is a pretty coarse technique.</p></div> |
| 41 |
<div class="paragraph"><p>The different PAMs listed below use different techniques to decide on these 32 |
| 42 |
values. Some models are better than others - meaning that the 32 values chosen |
| 43 |
are pretty good at spreading the bits where they should go. Even with a really |
| 44 |
bad PAM (e.g. Model -1) you can still get satisfactory results a lot of the time. |
| 45 |
All of these models have strengths and weaknesses. The model <em>you</em> end up using |
| 46 |
will be the one that produces the best sound for your ears, for your audio.</p></div> |
| 47 |
</div> |
| 48 |
</div> |
| 49 |
<div class="sect1"> |
| 50 |
<h2 id="_psychoacoustic_model_1">Psychoacoustic Model -1</h2> |
| 51 |
<div class="sectionbody"> |
| 52 |
<div class="paragraph"><p>This PAM doesn’t actually look at the samples being encoded to decide upon the |
| 53 |
output values. There is simply a set of 32 default values which are used, |
| 54 |
regardless of input.</p></div> |
| 55 |
<div class="paragraph"><p><strong>Pros</strong>: Faaaast. Low complexity. Surprisingly good. |
| 56 |
"Surprising" in that the other PAMs go to the effort of calculating FFTs |
| 57 |
and subbands and masking, and this one does absolutely <strong>nothing</strong>. |
| 58 |
Zip. Nada. Diddly Squat. This model might be the best example of why |
| 59 |
it is hard to make a good model - if having no computations sounds OK, |
| 60 |
how do you improve on it?</p></div> |
| 61 |
<div class="paragraph"><p><strong>Cons</strong>: Absolutely no attempt to consider any of the masking effects that |
| 62 |
would help the audio sound better.</p></div> |
| 63 |
</div> |
| 64 |
</div> |
| 65 |
<div class="sect1"> |
| 66 |
<h2 id="_psychoacoustic_model_0">Psychoacoustic Model 0</h2> |
| 67 |
<div class="sectionbody"> |
| 68 |
<div class="paragraph"><p>This PAM looks at the sizes of the <em>scalefactors</em> for the audio and combines |
| 69 |
it with the Absolute Threshold of Hearing (ATH) to make the 32 SMR values.</p></div> |
| 70 |
<div class="paragraph"><p><strong>Pros</strong>: Faaast. Low complexity.</p></div> |
| 71 |
<div class="paragraph"><p><strong>Cons</strong>: This model has absolutely no mathematical basis and does not use |
| 72 |
any perceptual model of hearing. It simply juggles some of the numbers of |
| 73 |
the input sound to determine the values. Feel free to hack the daylights out |
| 74 |
of this PAM - add multipliers, constants, log-tables <strong>anything</strong>. Tweak it until |
| 75 |
you begin to like the sound.</p></div> |
| 76 |
</div> |
| 77 |
</div> |
| 78 |
<div class="sect1"> |
| 79 |
<h2 id="_psychoacoustic_model_1_and_2">Psychoacoustic Model 1 and 2</h2> |
| 80 |
<div class="sectionbody"> |
| 81 |
<div class="paragraph"><p>These PAMs are from the ISO standard. Just because they are the standard, |
| 82 |
doesn’t mean that they are any good. Look at LAME which basically threw out |
| 83 |
the MP3 standard psycho models and made their own (GPSYCHO).</p></div> |
| 84 |
<div class="paragraph"><p><strong>Pros</strong>: A reference for future PAMs</p></div> |
| 85 |
<div class="paragraph"><p><strong>Cons</strong>: Terrible ISO code, buggy tables, poor documentation.</p></div> |
| 86 |
</div> |
| 87 |
</div> |
| 88 |
<div class="sect1"> |
| 89 |
<h2 id="_psychoacoustic_model_3">Psychoacoustic Model 3</h2> |
| 90 |
<div class="sectionbody"> |
| 91 |
<div class="paragraph"><p>A re-implementation of psychoacoustic model 1. ISO11172 was used as the guide |
| 92 |
for re-writing this PAM from the ground up.</p></div> |
| 93 |
<div class="paragraph"><p><strong>Pros</strong>: No more obscure tables of values from the ISO code. Hopefully a good |
| 94 |
base to work upon for tweaking PAMs</p></div> |
| 95 |
<div class="paragraph"><p><strong>Cons</strong>: At the moment, doesn’t really sound any better than PAM1</p></div> |
| 96 |
</div> |
| 97 |
</div> |
| 98 |
<div class="sect1"> |
| 99 |
<h2 id="_psychoacoustic_model_4">Psychoacoustic Model 4</h2> |
| 100 |
<div class="sectionbody"> |
| 101 |
<div class="paragraph"><p>A cleaned up version of PAM2.</p></div> |
| 102 |
<div class="paragraph"><p><strong>Pros</strong>: Faster than PAM2. No more obscure tables of values from the ISO |
| 103 |
standard. Hopefully a good base to work from for improving the PAMs</p></div> |
| 104 |
<div class="paragraph"><p><strong>Cons</strong>: Still has the same "warbling"/"Davros" problems as PAM2.</p></div> |
| 105 |
</div> |
| 106 |
</div> |
| 107 |
<div class="sect1"> |
| 108 |
<h2 id="_future_psychoacoustic_models">Future psychoacoustic models</h2> |
| 109 |
<div class="sectionbody"> |
| 110 |
<div class="paragraph"><p>There’s a heap that could be done. Unfortunately, I’ve got a set of tin |
| 111 |
ears, crappy speakers and a noisy computer room. If you’ve got the |
| 112 |
capability to do proper PAM testing then please feel free to do so. |
| 113 |
Otherwise, I’ll just keep plodding along with new ideas as they |
| 114 |
arise, such as:</p></div> |
| 115 |
<div class="ulist"><ul> |
| 116 |
<li> |
| 117 |
<p> |
| 118 |
Temporal masking (there’s no pre-echo or anything in TwoLAME) |
| 119 |
</p> |
| 120 |
</li> |
| 121 |
<li> |
| 122 |
<p> |
| 123 |
Left Right Masking |
| 124 |
</p> |
| 125 |
</li> |
| 126 |
<li> |
| 127 |
<p> |
| 128 |
A PAM that’s fully tuneable from the command line? |
| 129 |
</p> |
| 130 |
</li> |
| 131 |
<li> |
| 132 |
<p> |
| 133 |
Graphical output of SMR values etc. Would allow better debugging of PAMs |
| 134 |
</p> |
| 135 |
</li> |
| 136 |
<li> |
| 137 |
<p> |
| 138 |
Re-sampling routines |
| 139 |
</p> |
| 140 |
</li> |
| 141 |
<li> |
| 142 |
<p> |
| 143 |
Low/High pass filtering |
| 144 |
</p> |
| 145 |
</li> |
| 146 |
</ul></div> |
| 147 |
</div> |
| 148 |
</div> |
| 149 |
</div> |
| 150 |
<div id="footnotes"><hr /></div> |
| 151 |
<div id="footer"> |
| 152 |
<div id="footer-text"> |
| 153 |
Version 0.4.0<br /> |
| 154 |
Last updated |
| 155 |
2019-10-11 17:26:25 BST |
| 156 |
</div> |
| 157 |
</div> |
| 158 |
</body> |
| 159 |
</html> |