-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest3.py
More file actions
41 lines (35 loc) · 1.01 KB
/
Copy pathtest3.py
File metadata and controls
41 lines (35 loc) · 1.01 KB
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
from FilterGraph.axes import linear_axis_info, log_axis_info
from FilterGraph.WavRead import WavReader
from FilterGraph import transform
import numpy as np
import time
t0 = time.time()
wr = WavReader()
wr.filename = r"res\morn2.wav"
la = log_axis_info(80,0,79,scale=np.power(np.power(2,1/12),-49)*440,base=np.power(2,1/12))
wrfftis = transform(wr) \
.extended(mode="zeros",axes=0) \
.RFFT(window=np.hamming(2**12),spacing=1/44100) \
.interpolated(axes=2,mode="linear") \
.coordspace(axes=2) \
.sampled(domains=(None,None,la)) \
.done()
t1 = time.time()
print(f"setup: {t1-t0}")
b = wrfftis[0:wr.shape[0]:44100/5, 0, 0:80:0.2]
t2 = time.time()
print(f"FFT: {t2-t1}")
b = np.abs(b)
mi = np.min(b)
ma = np.max(b)
b = (b-mi)/(ma-mi) * (2**16)
b = b.astype(np.uint16)
b = np.flip(b,0)
t3 = time.time()
print(f"Tune: {t3-t2}")
import PIL, PIL.Image
#save the file
img = PIL.Image.fromarray(b,"I;16")
img.save(r"out\spec.png")
t4 = time.time()
print(f"Save: {t4-t3}")