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 ...@@ -26,7 +26,7 @@ import soundfile as sf
import time import time
class SoundLibrary(): class SoundLibrary:
def __init__(self, fs, sample_length, freqs): def __init__(self, fs, sample_length, freqs):
self._data = {} self._data = {}
self.fs = fs self.fs = fs
...@@ -36,7 +36,7 @@ class SoundLibrary(): ...@@ -36,7 +36,7 @@ class SoundLibrary():
def generate_sounds(self, freqs): def generate_sounds(self, freqs):
t = np.arange(0, self.sample_length, 1 / self.fs) t = np.arange(0, self.sample_length, 1 / self.fs)
for f in freqs: for f in freqs:
sound = np.sin(2*np.pi*f * t) sound = np.sin(2 * np.pi * f * t)
self._data[f] = sound self._data[f] = sound
@property @property
...@@ -58,7 +58,7 @@ def main(): ...@@ -58,7 +58,7 @@ def main():
f = [20, 50, 100, 200, 500, 1000, 2000, 5000, 10000] f = [20, 50, 100, 200, 500, 1000, 2000, 5000, 10000]
library = SoundLibrary(fs, length, f) library = SoundLibrary(fs, length, f)
for freq in library.freqs: for freq in sorted(library.freqs):
library.play(freq) library.play(freq)
time.sleep(1) 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