Skip to content

Instantly share code, notes, and snippets.

@sammosummo
Created March 17, 2019 17:22
Show Gist options
  • Save sammosummo/ea1b006d1541c4f26ed6d554433d9c96 to your computer and use it in GitHub Desktop.
Save sammosummo/ea1b006d1541c4f26ed6d554433d9c96 to your computer and use it in GitHub Desktop.
Simply generates a pure tone using numpy and plays it via sounddevice.
"""Simply generates a pure tone using numpy and plays it via sounddevice.
As always, make sure your volume settings are low before running this script, especially
if you are using headphones!
"""
import numpy as np
import sounddevice as sd
if __name__ == '__main__':
tone = np.sin(2 * np.pi * 440 * np.arange(0, 1, 1/44100)) # generate the tone
sd.play(tone, 44100) # play it
sd.wait() # wait for the tone to finish
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment