Administrator approval is now required for registering new accounts. If you are registering a new account, and are external to the University, please ask the repository owner to contact ServiceLine to request your account be approved. Repository owners must include the newly registered email address, and specific repository in the request for approval.

Commit 2f5a090f authored by Edward Rogers's avatar Edward Rogers
Browse files

Simple code to play a sound of a given frequency

parent b08bbdec
......@@ -2,7 +2,7 @@
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.5 (pyGUI)" jdkType="Python SDK" />
<orderEntry type="jdk" jdkName="Python 3.6 GUI (QT)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.5 (pyGUI)" project-jdk-type="Python SDK" />
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6 GUI (QT)" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
......@@ -22,16 +22,26 @@ Display agregated scores in second window
import sounddevice as sd
import numpy as np
import matplotlib.pyplot as plt
import soundfile as sf
import time
if __name__ == '__main__':
fs = 48000
print(sd.default.device['output'])
device = sd.query_devices(sd.default.device['output'])
fs = device['default_samplerate']
length = 0.5
f = 100
norm = 32000
f = 5000
# sound = np.zeros(int(length*fs))
t = np.arange(0, length, 1/fs)
sound = np.sin(f*t)*norm
plt.plot(t, sound)
plt.show()
print(sd.query_devices())
sd.play(sound, fs, device=1, blocking=True)
#
# sound = np.sin(f*t)*norm
# sound, fs = sf.read('C:\Windows\media\Windows Background.wav', dtype='float32')
# t = np.arange(0, sound.shape[0]) * (1 / fs)
# plt.plot(t, sound)
# plt.show()
# print(device)
# sd.play(sound, fs, blocking=False)
# time.sleep(1)
t = np.arange(0, length, 1 / fs)
sound2 = np.sin(f*t)
sd.play(sound2, fs, blocking=True)
Markdown is supported
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