|
|
@ -69,14 +69,13 @@ class Soundd: |
|
|
|
for sound in sound_list: |
|
|
|
for sound in sound_list: |
|
|
|
filename, play_count, volume = sound_list[sound] |
|
|
|
filename, play_count, volume = sound_list[sound] |
|
|
|
|
|
|
|
|
|
|
|
wavefile = wave.open(BASEDIR + "/selfdrive/assets/sounds/" + filename, 'r') |
|
|
|
with wave.open(BASEDIR + "/selfdrive/assets/sounds/" + filename, 'r') as wavefile: |
|
|
|
|
|
|
|
assert wavefile.getnchannels() == 1 |
|
|
|
|
|
|
|
assert wavefile.getsampwidth() == 2 |
|
|
|
|
|
|
|
assert wavefile.getframerate() == SAMPLE_RATE |
|
|
|
|
|
|
|
|
|
|
|
assert wavefile.getnchannels() == 1 |
|
|
|
length = wavefile.getnframes() |
|
|
|
assert wavefile.getsampwidth() == 2 |
|
|
|
self.loaded_sounds[sound] = np.frombuffer(wavefile.readframes(length), dtype=np.int16).astype(np.float32) / (2**16/2) |
|
|
|
assert wavefile.getframerate() == SAMPLE_RATE |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
length = wavefile.getnframes() |
|
|
|
|
|
|
|
self.loaded_sounds[sound] = np.frombuffer(wavefile.readframes(length), dtype=np.int16).astype(np.float32) / (2**16/2) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_sound_data(self, frames): # get "frames" worth of data from the current alert sound, looping when required |
|
|
|
def get_sound_data(self, frames): # get "frames" worth of data from the current alert sound, looping when required |
|
|
|
|
|
|
|
|
|
|
|