// title: Formant filter using the Vowel Quark // author: julian.rohrhuber // description: // A function to get the n loudest partials, or all partials louder than a threshold, for a formant filter using Klank and Vowel // code: // 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 = result.add([freq, amp]) } }; 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.add([freq, amp]) }; 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);