Last active
April 7, 2019 21:25
-
-
Save pocc/eafb6768eb50aba5f87798d49f4389fa to your computer and use it in GitHub Desktop.
Play a full octave using pysine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Play all notes between 440-880hz, inclusive | |
from pysine import sine | |
def get_freq(key): | |
# For a given piano key, return the frequency | |
# Taken from https://en.wikipedia.org/wiki/Piano_key_frequencies | |
return 2**((key-49)/12) * 440 | |
for key in range(49, 62): | |
freq = get_freq(key) | |
print("Playing at", round(freq), "Hz") | |
sine(frequency=freq, duration=0.2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment