Commit c59cbd10 authored by hackEns's avatar hackEns
Browse files

Started code for Noel2013

parent 272c51d9
#!/usr/bin/env python3
# ============================================================================
# This script allows you to play music using a chorizo (or whatever food you
# like) keyboard ! See README for more info and links.
# Specially designed for our demo for Christmas 2013. Designed to fully handle
# 5 notes and play jingle bells.
# As all the other scripts in this repository, I release it under a very
# permissive license. To make a long story short : do whatever you want with
# this script (but try to have fun :), I don't mind. It would be cool to quote
# the origin of the script if you reuse it, but you don't have to. I'd like to
# be noticed of what you did cool with it (if you think it's worth). :)
# Ah, I almost forgot : If by chance we ever meet and you think this script is
# worth, you can buy me a soda :)
# Phyks
# =============================================================================
from sound4python import sound
from multiprocessing import Process
import math
class _Getch:
"""Gets a single character from standard input. Does not echo to the
def __call__(self):
import sys
import tty
import termios
fd = sys.stdin.fileno()
old_settings = termios.tcgetattr(fd)
ch =
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
return ch
getch = _Getch()
def play_wave(frequency=440, nb_secs=1.):
sine_wave = []
for i in range(math.ceil(nb_secs*framerate)+1):
framerate = 16000
processes = []
frequency = 440
# Handle serial opening
# *** TODO ***
# Handle calibration
# *** TODO ***
# Main loop
# *** TODO *** : Add fetch from the serial also
print("Running... Press q to quit.")
running = True
while running:
char = getch()
if char == "q":
running = False
elif char == "a":
frequency = 440
elif char == "b":
frequency = 493.88
elif char == "c":
frequency = 523.25
elif char == "d":
frequency = 587.33
elif char == "e":
frequency = 659.26
elif char == "f":
frequency = 698.46
elif char == "g":
frequency = 783.99
print("Playing "+char.upper())
math.floor(0.2 * frequency + 1) / frequency)))
for i in processes:
......@@ -35,6 +35,17 @@ __(working on)__
A script to play music using chorizo pads as a musical keyboard. See [our website]( (french, but vids are available, more coming soon) for infos and demos.
Launch `` and use your keyboard to play music for now (A, B, C, D, E, F and G keys).
# Noel2013
__(working on)__
Our code for a demo at Christmas party 2013. We wanted to play Jingle Bells using a chorizo player, 5 notes to fetch from the array and map to real sound.
Use the same basis as `` so it is also usable with a keyboard for fallback if whatever bad happen :)
### 3d view
__(working on)__
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