File: 06_fft_vectral.py

package info (click to toggle)
python-pyo 1.0.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 52,332 kB
  • sloc: python: 135,133; ansic: 127,822; javascript: 16,116; sh: 395; makefile: 388; cpp: 242
file content (42 lines) | stat: -rw-r--r-- 921 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/env python
# encoding: utf-8
"""
Spectral gate and blur.

"""
from pyo import *

s = Server(duplex=0).boot()

snd = "../snds/ounkmaster.aif"

chnls = sndinfo(snd)[3]
size = 2048
olaps = 8
win = 5

snd = SfPlayer(snd, loop=True, mul=0.3)

fin = FFT(snd, size=size, overlaps=olaps, wintype=win)

pol = CarToPol(fin["real"], fin["imag"])

# bin-by-bin amplitude threshold
thresh = Sig(0.2)
thresh.ctrl([SLMap(0.0001, 1, "log", "value", 0.2)], title="Gate Threshold")

# attenuation
mult = Sig(0.1)
mult.ctrl([SLMap(0.0001, 1, "log", "value", 0.0001)], title="Gate Attenuation")

amp = Compare(pol["mag"] * 50, thresh, ">")
scl = amp * (1 - mult) + mult

delta = Vectral(pol["mag"] * scl, framesize=size, overlaps=olaps, down=0.35)
delta.ctrl(title="Blur controls")

car = PolToCar(delta, pol["ang"])

fout = IFFT(car["real"], car["imag"], size=size, overlaps=olaps, wintype=win).mix(chnls).out()

s.gui(locals())