-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomputer project.py
60 lines (34 loc) · 1.61 KB
/
computer project.py
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
50
51
52
53
54
55
56
57
58
59
60
from tkinter import *
from colour import Color
import sounddevice as sd
m = 6
fs = 44100 # frequency per second of the sound
time_seconds = m*m
# m*m is the time in seconds
print("please provide the audio input")
sound = sd.rec(int(time_seconds * fs), samplerate=fs, channels=2, dtype="int16")
# converting the audio signals into integer type array consisting of tuples with two entries
colour = Tk()
window = Canvas(colour, bg="white", width=210*m*10, height=210*m*10)
print("please wait for the sound file to be processed")
for x in range(210*m):
for y in range(210 * m):
a = len(str((abs(sound[x*y][0]))))
b = len(str((abs(sound[x*y][1]))))
h1 = int("1" + ("0" * a))
h2 = int("1" + ("0" * b))
e1 = abs(((sound[x*y][0]) / h1))
e2 = abs(((sound[x*y][1]) / h2))
e3=((((e1+e2)/2)+abs((e1-e2)))/2)
a1=sound[x*y][0]
a2=sound[x*y][1]
if ((a1 % 2 == 0) and (a2 % 2 == 0)):
window.create_rectangle(x * 10, y * 10, (x + 1) * 10, (y + 1) * 10, fill=Color(rgb=(e3, e2, e1)))
elif ((a1 % 2 == 0) and (a2 % 2 != 0)):
window.create_rectangle(x * 10, y * 10, (x + 1) * 10, (y + 1) * 10, fill=Color(rgb=(e3, e2, e1)))
elif ((a1 % 2 != 0) and (a2 % 2 == 0)):
window.create_rectangle(x * 10, y * 10, (x + 1) * 10, (y + 1) * 10, fill=Color(rgb=(e2, e3, e1)))
else:
window.create_rectangle(x * 10, y * 10, (x + 1) * 10, (y + 1) * 10, fill=Color(rgb=(e2, e3, e1)))
window.pack( pady = "30")
colour.mainloop()