Commit ba380ea2 authored by Ed Rogers's avatar Ed Rogers
Browse files

Sort playback of samples

parent 6bfdb8be
......@@ -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)
......
Supports Markdown
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