File: FFTSubbandFlatness.schelp

package info (click to toggle)
supercollider-sc3-plugins 3.7.1~repack-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 14,332 kB
  • ctags: 11,704
  • sloc: cpp: 140,180; lisp: 14,746; ansic: 2,133; xml: 86; makefile: 82; haskell: 21; sh: 8
file content (54 lines) | stat: -rw-r--r-- 1,611 bytes parent folder | download | duplicates (4)
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
CLASS:: FFTSubbandFlatness
summary:: Spectral flatness, divided into subbands
categories:: UGens>Analysis, UGens>FFT
related:: Classes/FFTSubbandPower

DESCRIPTION::
Calculates the spectral flatness measure, in the same manner as FFTFlatness, but divides the spectrum into (adjacent, non-overlapping) subbands, so returns separate measures for the different subbands.

The parameter cutfreqs can only be specified on initialisation - they can't be modulated.


CLASSMETHODS::

METHOD:: kr
argument:: chain

argument:: cutfreqs
must be an array of frequencies. For example, to divide a 44100Hz signal into three subbands we might specify  [ 5512, 11025 ]  as the cutfreqs, giving subbands of 0-5512Hz, 5512-11025Hz, and 11025-22050Hz. (Frequencies above the Nyquist frequency are not included.)

returns:: #[flatness1, flatness2, ... flatnessN+1]

EXAMPLES::

In this example we take a "flat" sound (white noise) and an "unflat" sound (a sawtooth wave) and mix them together bandwise using [PV_BinWipe]. With the spectrum divided into three bands you should be able to see the results.

code::
s.boot;
b = Buffer.alloc(s,2048,1);
c = Buffer.alloc(s,2048,1);
(
x = {
var inA, inB, chainA, chainB, chain, vals, cutfreqs;
//in = LPF.ar(WhiteNoise.ar, MouseX.kr(10,10000, 1));

inA = WhiteNoise.ar;
inB = Saw.ar;

chainA = FFT(b.bufnum, inA);
chainB = FFT(c.bufnum, inB);

chain = PV_BinWipe(chainA, chainB, MouseX.kr(-1, 1));

vals = FFTSubbandPower.kr(chain, [300, 500, 1500]);

vals[3].poll(10, "hi ");
vals[2].poll(10, "med");
vals[1].poll(10, "low");

Out.ar(0, IFFT(chain).dup * 0.2);
}.play(s);
)
x.free;
::