2 summary:: Extraction of instantaneous loudness in sones
3 categories:: UGens>Analysis>Amplitude
4 related:: Classes/BeatTrack, Classes/MFCC, Classes/Onsets, Classes/Pitch, Classes/KeyTrack
7 A perceptual loudness function which outputs loudness in sones; this is a variant of an MP3 perceptual model, summing excitation in ERB bands. It models simple spectral and temporal masking, with equal loudness contour correction in ERB bands to obtain phons (relative dB), then a phon to sone transform. The final output is typically in the range of 0 to 64 sones, though higher values can occur with specific synthesised stimuli.
14 [fft] Audio input to track, which has been pre-analysed by the link::Classes/FFT:: link::Classes/UGen::; see examples below for the expected FFT size.
17 [sk] Spectral masking param: lower bins mask higher bin power within ERB bands, with a power falloff (leaky integration multiplier) of smask per bin.
20 [sk] Temporal masking param: the phon level let through in an ERB band is the maximum of the new measurement, and the previous minus tmask phons.
24 // assumes hop of half fftsize, fine
25 b = Buffer.alloc(s, 1024, 1); // for sampling rates 44100 and 48000
26 //b = Buffer.alloc(s, 2048, 1); // for sampling rates 88200 and 96000
27 d = Buffer.read(s, Help.dir +/+ "sounds/a11wlk01.wav");
29 // analyse loudness and poll result
32 var in, fft, loudness;
34 in = PlayBuf.ar(1, d, BufRateScale.kr(d), 1, 0, 1);
38 loudness = Loudness.kr(fft).poll(50);
40 Out.ar(0, Pan2.ar(in));
46 // sones = 2 ** ((phon - 40) / 10)
47 // sine of 40 dB = 40 phon at 1000 kHz = 1 sone
49 // -60.dbamp = 0.001 = 1 sone
50 // -40.dbamp = 0.01 = 4 sone
51 // -20.dbamp= 0.1 = 16 sone
52 // 0.dbamp= 1 = 64 sone
55 var in, fft, loudness;
57 in = SinOsc.ar(1000, 0, 0.001); //should be 1 sone
58 //in = SinOsc.ar(1000, 0, 0.01); //should be 4 sone
59 //in = SinOsc.ar(1000, 0, 0.1); //should be 16 sone
60 //in = SinOsc.ar(1000, 0, 1); //should be 64 sone
61 //in = Saw.ar * SinOsc.ar(4);
63 //in = Silent.ar; // should be small, around 2 ** ((0 - 40) / 10) = 2 ** (-4) = 0.0625
65 //in = SinOsc.ar(22050, pi * 0.5, 1);
67 //in = SinOsc.ar(1000, 0, Line.kr(0, 1, 2));
68 //in = SinOsc.ar(1000, 0, Line.kr(0, 1, 2) ** 2);
69 //in = WhiteNoise.ar(Line.kr(0, 1, 2));
70 //in = PlayBuf.ar(1, d, BufRateScale.kr(d), 1, 0, 1);
74 loudness = Loudness.kr(fft, 0.25, 6).poll(50);
76 Out.ar(0, Pan2.ar(in));
77 K2A.ar(loudness * 0.016)
82 Research note: This link::Classes/UGen:: is an informal juxtaposition of perceptual coding, and a Zwicker and Glasberg/Moore/Stone loudness model.