yue

Programmatic music library

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
import math
import os
import sys
import sounddevice as sd
import yue

# Number of times to sample each second
bitrate = 44100


note = []
for i in range(0, 24):
    note.append([yue.seething(yue.freq(4, i), j / bitrate) / 4 for j in range(0, 3 * bitrate)])

sd.default.samplerate = bitrate
print("READY")

while True:
    os.system("stty raw -echo")
    c = sys.stdin.read(1)
    os.system("stty -raw echo")

    x = "`1234567890-~!@#$%^&*()_".index(c)
    print(x)

    sd.play(note[x])