From ba380ea2da0d138913580d56f933eeadfaecd18d Mon Sep 17 00:00:00 2001
From: Ed Rogers <etr@orc.soton.ac.uk>
Date: Thu, 8 Feb 2018 16:59:42 +0000
Subject: [PATCH] Sort playback of samples

---
 HearingTest.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/HearingTest.py b/HearingTest.py
index 67916ec..c11639c 100644
--- a/HearingTest.py
+++ b/HearingTest.py
@@ -26,7 +26,7 @@ import soundfile as sf
 import time
 
 
-class SoundLibrary():
+class SoundLibrary:
     def __init__(self, fs, sample_length, freqs):
         self._data = {}
         self.fs = fs
@@ -36,7 +36,7 @@ class SoundLibrary():
     def generate_sounds(self, freqs):
         t = np.arange(0, self.sample_length, 1 / self.fs)
         for f in freqs:
-            sound = np.sin(2*np.pi*f * t)
+            sound = np.sin(2 * np.pi * f * t)
             self._data[f] = sound
 
     @property
@@ -58,7 +58,7 @@ def main():
     f = [20, 50, 100, 200, 500, 1000, 2000, 5000, 10000]
 
     library = SoundLibrary(fs, length, f)
-    for freq in library.freqs:
+    for freq in sorted(library.freqs):
         library.play(freq)
         time.sleep(1)
 
-- 
GitLab