-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtil.py
More file actions
48 lines (34 loc) · 1.14 KB
/
Util.py
File metadata and controls
48 lines (34 loc) · 1.14 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
42
43
44
45
46
47
48
import numpy as np
def construct_2D_audio_frame(cube_size, val):
"""
:param cube_size:
:param val: array of size cube_size, contains values from 0 to 100
:return: frame
"""
div = 100 / cube_size
if len(val) != cube_size:
return None
translated_values = []
for x in val:
translated_values = translated_values + [round(x / div)]
frame = []
for x in range(cube_size ** 2):
frame = frame + [1 if translated_values[x % 8] >= int(np.ceil(((cube_size ** 2) - x) / 8)) else 0]
return frame
def construct_2D_audio_frame(cube_size, val, layer):
"""
:param cube_size:
:param val: array of size cube_size, contains values from 0 to 100
:return: frame
"""
div = 100 / cube_size
if len(val) != cube_size:
return None
translated_values = []
for x in val:
translated_values = translated_values + [round(x / div)]
frame = []
for x in range(cube_size ** 2):
frame = frame + [1 if np.sqrt(translated_values[x % 8] * translated_values[layer]) >= int(
np.ceil(((cube_size ** 2) - x) / 8)) - 1 else 0]
return frame