-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
36 lines (25 loc) · 823 Bytes
/
test.py
File metadata and controls
36 lines (25 loc) · 823 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from village.devices.sound_device import sound_device
from village.settings import settings
import numpy as np
import time
import pandas as pd
duration = 0.2
fs = float(settings.get("SAMPLERATE"))
span = 1000
end = 40001
start = span
amp = 0.05
frequencies = np.arange(start, end, span)
t = np.linspace(0, duration, int(fs * duration), endpoint=False)
signal = np.zeros_like(t)
for f in frequencies:
signal = amp*np.sin(2 * np.pi * f * t)
sound_device.load(right=signal, left=signal)
sound_device.play()
time.sleep(duration+0.1) # Wait for the sound to finish playing
sound_device.stop()
#signal /= len(frequencies)
#signal += amp*np.sin(2 * np.pi * f * t)
#sound_device.load(right=signal, left=signal)
#sound_device.play()
#time.sleep(duration + 0.5) # Wait for the sound to finish playing