示例#1
0
    def __init__(self):
        self.stream = None
        self.fm_process = None
        self.streaming = None
        self.sample_rate = None
        self.num_channels = None
        self.music_file = None
        self.fft_calc = None
        self.light_delay = None
        self.cache_found = None
        self.cache_matrix = None
        self.cache_filename = None
        self.config_filename = None
        self.song_filename = None
        self.terminal = None

        self.output = lambda raw_data: None

        self.mean = np.array([12.0 for _ in range(cm.hardware.gpio_len)],
                             dtype='float32')
        self.std = np.array([1.5 for _ in range(cm.hardware.gpio_len)],
                            dtype='float32')

        self.attenuate_pct = cm.lightshow.attenuate_pct
        self.sd_low = cm.lightshow.SD_low
        self.sd_high = cm.lightshow.SD_high

        self.decay_factor = cm.lightshow.decay_factor
        self.decay = np.zeros(cm.hardware.gpio_len, dtype='float32')
        self.physical_gpio_len = cm.hardware.physical_gpio_len
        self.network = hc.network
        self.server = self.network.networking == "server" or self.network.networking == "serverjson"
        self.client = self.network.networking == "client"

        if cm.lightshow.use_fifo:
            if os.path.exists(cm.lightshow.fifo):
                os.remove(cm.lightshow.fifo)
            os.mkfifo(cm.lightshow.fifo, 0777)

        self.chunk_size = cm.audio_processing.chunk_size  # Use a multiple of 8

        atexit.register(self.exit_function)

        # Remove traceback on Ctrl-C
        signal.signal(signal.SIGINT, lambda x, y: sys.exit(0))
        signal.signal(signal.SIGTERM, lambda x, y: sys.exit(0))

        if cm.terminal.enabled:
            self.terminal = bright_curses.BrightCurses(cm.terminal)
            curses.wrapper(self.launch_curses)
示例#2
0
    :param screen: window object representing the entire screen
    """
    terminal.init(screen)
    main()


def main():
    if "-in" in cm.lightshow.mode:
        audio_in()
    elif client:
        network_client()
    else:
        play_song()


if __name__ == "__main__":
    # Make sure one of --playlist or --file was specified
    if args.file is None and args.playlist is None:
        print "One of --playlist or --file must be specified"
        sys.exit()

    if cm.terminal.enabled:
        try:
            terminal = bright_curses.BrightCurses(cm.terminal)
            curses.wrapper(launch_curses)
        except KeyboardInterrupt:
            print "Got KeyboardInterrupt exception. Exiting..."
            exit()
    else:
        main()