Ejemplo n.º 1
0
    def test_invert_string(self):
        self.assertEqual(invert_string_number(0), False);
        self.assertEqual(invert_string_number(7), False);

        self.assertEqual(invert_string_number(1), 6)
        self.assertEqual(invert_string_number(2), 5)
        self.assertEqual(invert_string_number(3), 4)
        self.assertEqual(invert_string_number(4), 3)
        self.assertEqual(invert_string_number(5), 2)
        self.assertEqual(invert_string_number(6), 1)
Ejemplo n.º 2
0
    def __init__(self):
        self.strings_tmp = list(self.strings)

        self.files = list_files(config['sounds_folder'], config['low_e_file'])

        inclusive = False

        parser = argparse.ArgumentParser()
        parser.add_argument('-d', '--day', default=0,
                            help='the day of your 12 day challenge')
        parser.add_argument('-l', '--level', default='easy',
                            help='beginner|easy|medium|hard|impossible')
        parser.add_argument('-i', '--inclusive',
                            help="Whether the session includes previous days' notes",
                            action="store_true")
        parser.add_argument('-ns', '--no-sound', help="Don't play note samples",
                            action="store_true")
        parser.add_argument('-fb', '--fretboard', help="Show fretboard. Experimental",
                            action="store_true")
        parser.add_argument('-f', '--from-str', default=1, help="from (from) string")
        parser.add_argument('-t', '--to-str', default=6, help="to (to) string")
        parser.add_argument('-n', '--name', help="Say string name rather than string number", action="store_true")

        args = parser.parse_args()

        day = int(args.day)

        self.to_string = invert_string_number(int(args.to_str))
        self.from_string = invert_string_number(int(args.from_str))

        if args.inclusive:
            self.inclusive = True
        else:
            self.inclusive = False

        if args.no_sound:
            sound = False
        else:
            sound = True

        if args.fretboard:
            show_fretboard = True
        else:
            show_fretboard = False

        if args.name:
            say_name = True
        else:
            say_name = False

        playback, sleep_from, sleep_to, rate = self.play_back_options(args)

        def string_name(current_string, say_name):
            if say_name:
                string = self.string_names[current_string]
            else:
                string = self.string[current_string]
            return string

        def main(stdscr):

            curses.curs_set(0)
            # Clear screen
            stdscr.clear()

            stdscr.addstr(0, 0, "Day %s of 12. Today is a %s day\n" % (
            day, self.notes[self.order[day - 1]]))
            stdscr.addstr(2, 0, self.notes_by_day(day) + '\n')
            stdscr.refresh()

            time.sleep(1)

            try:
                while True:

                    stdscr.clear()

                    current_string = self.get_current_string()

                    file, note = self.get_note_and_file(current_string, day,
                                                        self.notes)

                    name = string_name(current_string, say_name)
                    
                    out = self.display_string_and_note(name, note)

                    stdscr.addstr(0, 0, "Day %s of 12. Today is a %s day\n" % (
                    day, self.notes[self.order[day - 1]]))
                    stdscr.addstr(2, 0, self.notes_by_day(day) + '\n')
                    stdscr.addstr(4, 0, out, curses.A_BOLD)
                    if show_fretboard:
                        stdscr.addstr(6, 0, self.fretboard(0, 0))
                        self.draw_fretboard_dots(stdscr)
                    stdscr.refresh()

                    self.say_string_and_note(out, rate)

                    self.sleep(sleep_from, sleep_to)

                    if show_fretboard:
                       stdscr.addstr(6, 0, self.fretboard(self.string_indices[current_string], note))
                       self.draw_fretboard_dots(stdscr)

                    stdscr.refresh()

                    if sound:
                        self.play_sound(file, playback)

            except KeyboardInterrupt:
                sys.exit(0)

        wrapper(main)