diff --git a/src/View/Results/Window.py b/src/View/Results/Window.py index a0687705..ccfe4689 100644 --- a/src/View/Results/Window.py +++ b/src/View/Results/Window.py @@ -1340,7 +1340,7 @@ class ResultsWindow(PamhyrWindow): return # results - results=self._results[self._current_results[0]] + results = self._results[self._current_results[0]] if results is None: return @@ -1352,16 +1352,20 @@ class ResultsWindow(PamhyrWindow): t = self._timestamps q = profile.get_key("Q") - scale=[] - low = 30; high = 84 + scale = [] + low = 30 + high = 84 for k in range(low, high): - note=440*2**((k-49)/12) + note = 440*2**((k-49)/12) scale.append(note) # add musical note n_notes = len(scale) # number of musical notes # rescale # we start at low to high - tmax = max(t); tmin = min(t); - qmax = max(q); qmin = min(q); qfact = (n_notes) / (qmax - qmin + 1) + tmax = max(t) + tmin = min(t) + qmax = max(q) + qmin = min(q) + qfact = (n_notes) / (qmax - qmin + 1) for i in range(len(q)): q[i] = int((q[i] - qmin) * qfact) nq = [q[0]] # (notes) @@ -1372,41 +1376,35 @@ class ResultsWindow(PamhyrWindow): else: nq.append(q[i+1]) dq.append(0.1) - wq=[] - for i in range(len(dq)): # loop over dataset observations, create one note per observation - volume = 2048 - new_w = get_sine_wave(frequency = scale[nq[i]], duration = dq[i], amplitude = volume) - wq = np.concatenate((wq,new_w)) + wq = [] + volume = 2048 + for i in range(len(dq)): + new_w = get_sine_wave(frequency=scale[nq[i]], + duration=dq[i], + amplitude=volume) + wq = np.concatenate((wq, new_w)) p = pyaudio.PyAudio() chunk = 1048 - stream = p.open(format = - p.get_format_from_width(2), - channels = 1, - rate = 44100, - output = True) - - + stream = p.open(format=p.get_format_from_width(2), + channels=1, + rate=44100, + output=True) def fn(): i = 0 while i < len(wq): stream.write( - wq[i:min(i+chunk,len(wq))].astype(np.int16).tobytes() + wq[i:min(i+chunk, len(wq))].astype(np.int16).tobytes() ) i += chunk - title = self._trad["playing_sound"] dlg = WaitingDialog( payload_fn=fn, - title=title, + title="playing_sound", parent=self ) dlg.exec_() - #stop stream stream.stop_stream() stream.close() - - #close PyAudio p.terminate() - diff --git a/src/View/Results/translate.py b/src/View/Results/translate.py index bea42fe9..7a1e7e9b 100644 --- a/src/View/Results/translate.py +++ b/src/View/Results/translate.py @@ -61,9 +61,6 @@ class ResultsTranslate(MainTranslate): self._dict["ImageCoordinates"] = _translate( "Results", "Image coordinates" ) - self._dict["playing_sound"] = _translate( - "Results", "Playing sound..." - ) self._sub_dict["table_headers_reach"] = { "name": _translate("Results", "Reach name"), diff --git a/src/View/Translate.py b/src/View/Translate.py index 30434d4f..8e22b8a2 100644 --- a/src/View/Translate.py +++ b/src/View/Translate.py @@ -239,6 +239,9 @@ class MainTranslate(UnitTranslate): "Results comparison with two " "incompatible study version" ) + self._dict["playing_sound"] = _translate( + "MainWindow", "Playing sound..." + ) self._dict["x"] = _translate("MainWindow", "X (m)") self._dict["y"] = _translate("MainWindow", "Y (m)")