# «Formant filter using the Vowel Quark» byjulian.rohrhuber

on 16 Aug'15 17:50 in

A function to get the n loudest partials, or all partials louder than a threshold, for a formant filter using Klank and Vowel

```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```
```// a function to get the n loudest partials for a formant filter using Klank and Vowel

// needs the Vowel quark:

"Vowel".include;

// tenor, for instance
a = "aeiou".as(Array).collect { |x| Vowel(x.asSymbol, \tenor) };

// function for threshold
(
f = { |vowel, thresh = 0.3|
var freqs = (40..10000).collect { |x| x + 0.5.rand2 };
var result = [];
freqs.do { |freq|
var amp = vowel.ampAt(freq);
if(amp > thresh) {
}
};
result.size.postln;
result.flop
};
)
// or alternatively, for number of partials
(
g = { |vowel, numPartials = 30|
var freqs = (40..10000).collect { |x| x + 0.5.rand2 };
var result = [];
freqs.do { |freq|
var amp = vowel.ampAt(freq);
};

result = result.sort { |a, b| a[1] > b[1] }.keep(numPartials);

result.flop
};
)

// some examples

Ndef(\vow, { Klank.ar(`(f.(a[0], 0.7) ++ 0.2), Impulse.ar(MouseX.kr(1, 1000, 1))) * 0.001 }).play;
Ndef(\vow, { Klank.ar(`(f.(a[0], 0.3) ++ 0.2), Impulse.ar(MouseX.kr(1, 1000, 1))) * 0.001 }).play;
Ndef(\vow, { Klank.ar(`(f.(a[2], 0.7) ++ 0.2), Impulse.ar(MouseX.kr(1, 1000, 1))) * 0.001 }).play;
Ndef(\vow, { Klank.ar(`(f.(a[2], 0.3) ++ 0.2), Impulse.ar(MouseX.kr(1, 1000, 1))) * 0.001 }).play;

// use for instance to get the 42 loudest partials, for each vowel
z = a.collect { |x| g.(x, 42) }.flopDeep(1);```
raw 1406 chars (focus & ctrl+a+c to copy)
reception