Repository navigation
Expand file tree
/
Copy pathcontroller.py
More file actions
75 lines (63 loc) · 2.57 KB
/
Copy pathcontroller.py
File metadata and controls
75 lines (63 loc) · 2.57 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
from turtledemo.chaos import f
import matplotlib.pyplot as plt
import numpy as np
class Controller:
def __init__(self, model, view):
self.model = model
self.view = view
def display_waveform(self, wave_file):
# Assuming wave_file is the path to the .wav file
waveform, sample_rate = self.model.load_waveform(wave_file)
time = np.arange(0, len(waveform)) / sample_rate
# Plot the waveform
plt.figure()
plt.plot(time, waveform)
plt.title('Waveform')
plt.xlabel('Time (s)')
plt.ylabel('Amplitude')
plt.show()
def display_rt60_plot(self):
# Assuming the model has methods to compute RT60 for low, mid, and high frequencies
low_rt60 = self.model.calculate_rt60('low')
mid_rt60 = self.model.calculate_rt60('mid')
high_rt60 = self.model.calculate_rt60('high')
# Plot RT60 for Low, Mid, and High frequencies
plt.figure()
plt.bar(['Low', 'Mid', 'High'], [low_rt60, mid_rt60, high_rt60])
plt.title('RT60 Plot')
plt.xlabel('Frequency Band')
plt.ylabel('RT60 (s)')
plt.show()
def combine_plots(self):
# Combine the waveform and RT60 plots into a single plot
plt.figure()
# Plot the waveform
plt.subplot(2, 1, 1)
waveform, sample_rate = self.model.get_waveform()
time = np.arange(0, len(waveform)) / sample_rate
plt.plot(time, waveform)
plt.title('Waveform')
plt.xlabel('Time (s)')
plt.ylabel('Amplitude')
# Plot RT60 for Low, Mid, and High frequencies
plt.subplot(2, 1, 2)
low_rt60 = self.model.calculate_rt60('low')
mid_rt60 = self.model.calculate_rt60('mid')
high_rt60 = self.model.calculate_rt60('high')
plt.bar(['Low', 'Mid', 'High'], [low_rt60, mid_rt60, high_rt60])
plt.title('RT60 Plot')
plt.xlabel('Frequency Band')
plt.ylabel('RT60 (s)')
plt.tight_layout()
plt.show()
def add_button_and_visual_data(self):
# Assuming you have a method to retrieve additional visual data from the model
additional_data = self.model.get_additional_data()
# Plot the additional visual data
plt.figure()
# Plot your additional visual data (replace 'x' and 'y' with actual data)
plt.plot(additional_data['x'], additional_data['y'])
plt.title('Additional Visual Data')
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.show()