Ejemplo n.º 1
0
 def __init__(self):
     self.pixels = neopixel.NeoPixel(
         board.D18,
         AppConfig.instance().conf["pixel_count"],
         brightness=AppConfig.instance().conf["brightness"],
         pixel_order="GRB",
     )
     self.pixels.fill((0, 0, 0))  # Clear Board
     self.synthesia_pixels = [(0, 0, 0) for _ in range(AppConfig.instance().conf["pixel_count"])]
     self.in_song = False
Ejemplo n.º 2
0
    def keyboard_position(self):
        if self.note > 92:
            note_offset = 2
        elif self.note > 55:
            note_offset = 1
        else:
            note_offset = 0

        pos = (self.note - 20) * 2 - note_offset
        if AppConfig.instance().conf['invert']:
            pos = AppConfig.instance().conf.get('pixel_count') - pos

        return pos
Ejemplo n.º 3
0
    def set_led(self, msg, color):
        adjusted_color = tuple([int(val * msg.brightness) for val in color])

        pos = msg.keyboard_position()

        if msg.from_synthesia:
            self.pixels[pos] = adjusted_color
            self.synthesia_pixels[pos] = adjusted_color
        elif self.in_song:
            if self.synthesia_pixels[pos] == (0, 0, 0):
                self.pixels[pos] = hex_to_rgb(AppConfig.instance().conf["colors"]["error"])
            else:
                self.pixels[pos] = adjusted_color
        else:
            self.pixels[pos] = adjusted_color
Ejemplo n.º 4
0
 def end_synthesia_song(self):
     self.synthesia_pixels = [(0, 0, 0) for _ in range(AppConfig.instance().conf["pixel_count"])]
     self.in_song = False
Ejemplo n.º 5
0
import time
from lib.midi_message import MidiMessage
from lib.app_config import AppConfig
from lib.light_strip import LightStrip
from lib.midi_device import MidiDevice
from helpers.functions import hex_to_rgb
from lib.lcd_manager import LcdManager

CONFIG = AppConfig.instance().conf
lcd_manager = LcdManager.instance()

synthesia = MidiDevice(CONFIG["devices"]["synthesia"])
piano = MidiDevice(CONFIG["devices"]["piano"])

light_strip = LightStrip.instance()
light_strip.play_boot_sequence()


def play_note(msg):
    color_conf = CONFIG["colors"]
    color = color_conf["default"]

    if msg.is_left_hand() and msg.is_black_key():
        color = color_conf["left_black"]
    elif msg.is_left_hand() and not msg.is_black_key():
        color = color_conf["left"]
    elif msg.is_right_hand() and msg.is_black_key():
        color = color_conf["right_black"]
    elif msg.is_right_hand() and not msg.is_black_key():
        color = color_conf["right"]