/usr/share/SuperCollider/HelpSource/Classes/AmpCompA.schelp is in supercollider-common 1:3.8.0~repack-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | class:: AmpCompA
summary:: Basic psychoacoustic amplitude compensation (ANSI A-weighting curve).
related:: Classes/AmpComp
categories:: UGens>Analysis>Amplitude
Description::
Higher frequencies are normally perceived as louder, which AmpCompA
compensates. Following the measurements by Fletcher and Munson, the
ANSI standard describes a function for loudness vs. frequency.
Note that this curve is only valid for standardized amplitude.
footnote::
Function freq → dB,
derived from http://www.beis.de/Elektronik/AudioMeasure/WeightingFilters.html
and modified to map freq → amp.
code::
(
var k = 3.5041384e16;
var c1 = 424.31867740601;
var c2 = 11589.093052022;
var c3 = 544440.67046057;
var c4 = 148698928.24309;
f = {|f|
var r = squared(f);
var m1 = pow(r,4);
var n1 = squared(c1 + r);
var n2 = c2 + r;
var n3 = c3 + r;
var n4 = squared(c4 + r);
var level = k * m1 / (n1 * n2 * n3 * n4);
sqrt(level)
};
)
::
::
For a simpler but more flexible curve, see link::Classes/AmpComp::
classmethods::
method::ar, kr, ir
argument::freq
Input frequency value. For freq == root, the output is rootAmp.
argument::root
Root freq relative to which the curve is calculated (usually lowest freq).
argument::minAmp
Amplitude at the minimum point of the curve (around 2512 Hz).
argument::rootAmp
Amplitude at the root frequency.
discussion::
Apart from code::freq::, the values are not modulatable
Examples::
code::
// compare a sine without compensation
{ SinOsc.ar(MouseX.kr(300, 15000, 1)) * 0.1 }.play;
// with one that uses amplitude compensation
(
{
var freq;
freq = MouseX.kr(300, 15000, 1);
SinOsc.ar(freq) * 0.3 * AmpCompA.kr(freq)
}.play;
)
// adjust the minimum and root amp
// (in this way one can flatten out the curve for higher amplitudes)
(
{
var freq;
freq = MouseX.kr(300, 18000, 1);
Formant.ar(300, freq, 20, 0.1) * AmpCompA.kr(freq, 300, 0.6, 0.3)
}.play;
)
// the curve:
{ AmpCompA.ar(Line.ar(48, 120, 1).midicps, 48.midicps) }.plot(1.0);
// freqs:
{ AmpCompA.ar(Line.ar(0, 20000, 1)) }.plot(1.0);
// compare with AmpComp (exponential decay)
{ AmpComp.ar(Line.ar(48, 120, 1).midicps, 48.midicps) }.plot(1.0);
// freqs:
{ AmpComp.ar(Line.ar(40, 20000, 1), 40) }.plot(1.0);
// amplitude compensation in frequency modulation (using Fletscher-Munson curve)
(
{
var freq;
freq = MouseX.kr(300, 15000, 1);
freq = freq * SinOsc.ar(MouseY.kr(3, 200, 1), 0, 0.5, 1);
SinOsc.ar(freq) * 0.1 * AmpCompA.ar(freq, 300)
}.play;
)
// amplitude compensation in frequency modulation (using AmpComp exponential decay)
(
{
var freq;
freq = MouseX.kr(300, 15000, 1);
freq = freq * SinOsc.ar(MouseY.kr(3, 200, 1), 0, 0.5, 1);
SinOsc.ar(freq) * 0.1 * AmpComp.ar(freq, 300)
}.play;
)
// without amplitude compensation
(
{
var freq;
freq = MouseX.kr(300, 15000, 1);
freq = freq * SinOsc.ar(MouseY.kr(3, 200, 1), 0, 0.5, 1);
SinOsc.ar(freq) * 0.1
}.play;
)
[1] Function freq -> dB,
derived from http://www.beis.de/Elektronik/AudioMeasure/WeightingFilters.html
and modified to map freq -> amp
(
var k = 3.5041384e16;
var c1 = 424.31867740601;
var c2 = 11589.093052022;
var c3 = 544440.67046057;
var c4 = 148698928.24309;
f = {|f|
var r = squared(f);
var m1 = pow(r,4);
var n1 = squared(c1 + r);
var n2 = c2 + r;
var n3 = c3 + r;
var n4 = squared(c4 + r);
var level = k * m1 / (n1 * n2 * n3 * n4);
sqrt(level)
};
)
::
|