Administrator approval is now required for registering new accounts. If you are registering a new account, and are external to the University, please ask the repository owner to contact ServiceLine to request your account be approved. Repository owners must include the newly registered email address, and specific repository in the request for approval.

Commit 6c44759a authored by Ed Rogers's avatar Ed Rogers
Browse files

Add 'graphic equaliser'

parent 37b2859b
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<orderEntry type="jdk" jdkName="Python 3.5 (pyGUI)" jdkType="Python SDK" />
<orderEntry type="jdk" jdkName="Python 3.6 (pyGUI)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyCompatibilityInspection" enabled="false" level="WARNING" enabled_by_default="false">
<option name="ourVersions">
<list size="1">
<item index="0" class="java.lang.String" itemvalue="3.6" />
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.5 (pyGUI)" project-jdk-type="Python SDK" />
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6 (pyGUI)" project-jdk-type="Python SDK" />
\ No newline at end of file
......@@ -21,7 +21,6 @@ Display agregated scores in second window
import sounddevice as sd
import numpy as np
import matplotlib.pyplot as plt
import soundfile as sf
import time
from PyQt5 import QtCore, QtWidgets, QtGui
......@@ -31,6 +30,63 @@ from PyQt5.QtCore import QSize
import sys
from SoundLibrary import SoundLibrary
import random
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure
class HearingResult:
upper_lim = 100
lower_lim = 0
n_blocks = 20
def get_block_size():
return (HearingResult.upper_lim - HearingResult.lower_lim)/HearingResult.n_blocks
def __init__(self, bands):
self.bands = bands
self.lower_bounds = np.ones_like(bands) * self.lower_lim
self.upper_bounds = np.ones_like(bands) * self.upper_lim
class HearingMplCanvas(FigureCanvas):
"""Ultimately, this is a QWidget (as well as a FigureCanvasAgg, etc.)."""
def __init__(self, parent=None, width=5, height=4, dpi=100):
fig = Figure(figsize=(width, height), dpi=dpi)
self.axes = fig.add_subplot(111)
# self.compute_initial_figure()
FigureCanvas.__init__(self, fig)
def plot_result(self, result: HearingResult):
inds = np.arange(0, result.bands.size)
baseline = -10
self.axes.set_axis_bgcolor('k'), result.upper_bounds-baseline, color=(0, 0.5, 0), bottom=baseline), result.lower_bounds-baseline, color=(0, 1, 0), bottom=baseline)
xlim = self.axes.get_xlim()
for i in np.arange(result.lower_lim+baseline, result.upper_lim, result.get_block_size()):
self.axes.plot(self.axes.get_xlim(), np.ones(2)*i, color='k')
labels = [str(b) for b in result.bands]
labels.insert(0, '')
self.axes.set_ylim(-10, 110)
class HearingTestThread(QtCore.QThread):
......@@ -76,8 +132,11 @@ class TestWindow(QMainWindow):
self.graph = HearingMplCanvas(parent=self)
grid_layout.addWidget(self.title, 0, 0)
grid_layout.addWidget(self.log, 1, 0)
grid_layout.addWidget(self.graph, 2, 0)
def keyPressEvent(self, event: QtGui.QKeyEvent):
if not self.test_running:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment