Skip to content

Instantly share code, notes, and snippets.

@mathigatti
Created September 24, 2020 03:07
Show Gist options
  • Save mathigatti/2a7973e192fabecad45d0f9a553275d8 to your computer and use it in GitHub Desktop.
Save mathigatti/2a7973e192fabecad45d0f9a553275d8 to your computer and use it in GitHub Desktop.
import curses, os
def main(stdscr):
# do not wait for input when calling getch
stdscr.nodelay(1)
while True:
# get keyboard input, returns -1 if none available
c = stdscr.getch()
if c != -1:
# print numeric value
stdscr.addstr(str(c) + ' ')
if 47 < c < 60:
os.system(f"sox --buffer 2048 -c 1 -r 48000 -t alsa default -t alsa default pitch {(c-48)*100} &> /dev/null")
else:
os.system("pkill sox")
stdscr.refresh()
# return curser to start position
stdscr.move(0, 0)
if __name__ == '__main__':
curses.wrapper(main)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment