示例#1
0
    def get_workout(self) -> workout.WorkOut:

        step_1_1 = exercise_step.ExerciseStep("Step 1.1", 2, "last 2 secs")
        step_1_2 = exercise_step.ExerciseStep("Step 1.2", 2, "last 2 secs")
        exercise_1 = exercise.Exercise("First exercise", "subinfo 1",
                                       [step_1_1, step_1_2])

        step_2_1 = exercise_step.ExerciseStep("Step 2.1", 2, "last 2 secs")
        step_2_2 = exercise_step.ExerciseStep("Step 2.2", 2, "last 2 secs")
        exercise_2 = exercise.Exercise("Second exercise", "subinfo 2",
                                       [step_2_1, step_2_2])

        output = workout.WorkOut([exercise_1, exercise_2])

        return output
    def get_exercise(self, quantity: int, guitar: dict) -> exercise.Exercise:
        """ Returns random chord exercises """
        if guitar["kind"] != "instrument":
            return None

        random_steps = []

        for chord_pos in range(0, quantity):  # pylint: disable=W0612
            context_count = random.randint(2, 4)
            stuff = chord.Chord().get_random_chords(context_count)

            stuff_txt = ""
            for stuff_char in stuff:
                if stuff_txt != "":
                    stuff_txt += " | "
                stuff_txt += stuff_char

            random_step = exercise_step.ExerciseStep(
                Chords._get_random_position(), stuff_txt)

            random_steps.append(random_step)

        output = exercise.Exercise(self._TITLE,
                                   self._SUBTITLE,
                                   random_steps,
                                   practice_category=self.category)

        return output
    def get_exercise(self, quantity: int, guitar: dict) -> exercise.Exercise:
        """ Returns random chord connection exercises """
        if guitar["kind"] != "instrument":
            return None

        random_steps = []
        random_improvs = improv.Improv().get_improvs(quantity)

        for random_improv in random_improvs:
            context_count = random.randint(2, 4)
            stuff = chord.Chord().get_random_chords(context_count)

            stuff_txt = ""
            for stuff_char in stuff:
                if stuff_txt != "":
                    stuff_txt += " | "
                stuff_txt += stuff_char

            random_step = exercise_step.ExerciseStep(random_improv, stuff_txt)
            random_steps.append(random_step)

        output = exercise.Exercise(self._TITLE,
                                   self._SUBTITLE,
                                   random_steps,
                                   practice_category=self.category)
        return output
示例#4
0
    def get_exercise(self, quantity: int) -> exercise.Exercise:

        random_steps = []
        improvs = []

        for i in range(0, quantity):
            if len(improvs) == 0:
                improvs = self._IMPROVS.copy()
            random_index = random.randint(0, len(improvs) - 1)
            random_main_improv = improvs.pop(random_index)
            sub_txt = ""

            sub_appended = False
            for i in range(2):
                if len(improvs) == 0:
                    break
                if sub_txt == "":
                    sub_txt += "followed by "
                if len(improvs) == 1:
                    random_index = 0
                else:
                    random_index = random.randint(0, len(improvs) - 1)
                random_sub_improv = improvs.pop(random_index)
                if sub_appended:
                    sub_txt += ", "
                else:
                    sub_appended = True
                sub_txt += random_sub_improv

            random_step = exercise_step.ExerciseStep(random_main_improv,
                                                     sub_txt)
            random_steps.append(random_step)

        output = exercise.Exercise(self._TITLE, self._SUBTITLE, random_steps)
        return output
示例#5
0
    def get_exercise(self, quantity: int) -> exercise.Exercise:

        degree_obj = degree.Degree()
        mode_obj = mode.Mode()
        random_steps = []

        for step_index in range(0, quantity):
            mode_text = mode_obj.get_random_mode() + " " + self._get_direction(
            )

            step_text = ""

            while True:
                degree_count = random.randint(2, 4)
                degrees = degree_obj.get_random_degrees(degree_count,
                                                        limit_octave=True)
                if not (
                    (degree_count == 2 and degrees[0] == degrees[1]) or
                    (degree_count == 2 and abs(degrees[1] - degrees[0]) == 1)):
                    break

            for deg in degrees:
                if step_text != "":
                    step_text += ", "
                step_text += str(deg)

            random_step = exercise_step.ExerciseStep(mode_text,
                                                     sub_text=step_text)
            random_steps.append(random_step)

        output = exercise.Exercise(self._TITLE, self._SUBTITLE, random_steps)
        return output
示例#6
0
 def get_exercise(self, quantity: int) -> exercise.Exercise:
     steps = []
     tech = technique.right_hand.RightHand().get_random_techniques(quantity)
     for i in range(0, len(tech)):
         new_step = exercise_step.ExerciseStep(tech[i], "")
         steps.append(new_step)
     return exercise.Exercise(self._TITLE, self._SUBTITLE, steps)
示例#7
0
    def get_exercise(self, quantity: int, guitar: dict) -> exercise.Exercise:
        """ Returns random chord exercises """
        random_steps = []
        key_signature = KeySignature()

        while len(random_steps) < quantity:
            chord_note = key_signature.get_random_note()
            melody_notes = []
            melody_notes_txt = ""
            while len(melody_notes) < 4:
                melody_note = key_signature.get_random_relative_note(chord_note)
                if any([melody_note in melody_notes, melody_note == chord_note]):
                    continue
                melody_notes.append(melody_note)
                if len(melody_notes) > 1:
                    melody_notes_txt += " | "
                melody_notes_txt += melody_note

            random_step = exercise_step.ExerciseStep(
                f"Chord: {chord_note}",
                f"Notes: {melody_notes_txt}")
            random_steps.append(random_step)

        output = exercise.Exercise(
            self._TITLE,
            self._SUBTITLE,
            random_steps,
            practice_category=self.category)

        return output
            
示例#8
0
    def get_exercise(self, quantity: int, guitar: dict) -> exercise.Exercise:
        """ Returns exercise """
        if guitar["kind"] != "instrument":
            return None
        if guitar["strings"] <= 0:
            subtitle = "Find the given notes on subsequent octaves"
            strings = guitar["octaves"]
        else:
            subtitle = "Find the given notes on subsequent strings"
            strings = guitar["strings"]

        note_obj = note.Note()
        random_steps = []

        for step_index in range(0, quantity):  # pylint: disable=W0612
            step_text = ""

            note_count = strings
            if self.min_note_count is not None and self.min_note_count > strings:
                note_count = self.min_note_count
            notes_of_step = note_obj.get_random_notes(note_count)
            for note_of_step in notes_of_step:
                if step_text != "":
                    step_text += ", "
                step_text += note_of_step

            random_step = exercise_step.ExerciseStep(step_text)
            random_steps.append(random_step)

        output = exercise.Exercise(self._TITLE,
                                   subtitle,
                                   random_steps,
                                   practice_category=self.category)

        return output
    def get_exercise(self, quantity: int, guitar: dict) -> exercise.Exercise:
        """ Returns metronome exercises """
        random_steps = []

        while len(random_steps) < quantity:
            random_dict = self._get_random_metronome_exercise()
            random_exercise = random_dict["exercise"]
            random_bpm = self._get_adjusted_random_bpm(random_dict)

            sub_text = f'{"External BPM:" if random_dict["external"] else "Internal BPM:"}' \
                       f' {str(random_bpm)}'

            random_step = exercise_step.ExerciseStep(random_exercise, sub_text)

            if random_dict["external"]:
                helper = get_external_metronome_helper(random_bpm)
            else:
                helper = ExerciseHelper(ExerciseHelperType.METRONOME,
                                        {"bpm": random_bpm})

            random_step.helpers = [helper]
            random_steps.append(random_step)

        output = exercise.Exercise(self._TITLE,
                                   "Run the following exercise",
                                   random_steps,
                                   practice_category=self.category)

        return output
示例#10
0
    def get_exercise(self, quantity: int) -> exercise.Exercise:
        random_steps = []

        for i in range(quantity):

            # Get chords
            number_of_chords = random.randint(1, 3)
            chords = chord.Chord().get_random_chords(number_of_chords)

            # Build chord text
            chord_txt = ""
            sub_txt = ""
            for ch in chords:
                if chord_txt == "":
                    chord_txt = ch
                else:
                    if sub_txt == "":
                        sub_txt = "followed by: "
                    else:
                        sub_txt += " | "
                    sub_txt += ch

            # Add to steps
            random_step = exercise_step.ExerciseStep(chord_txt, sub_txt)
            random_steps.append(random_step)

        output = exercise.Exercise(self._get_random_approach(), self._SUBTITLE,
                                   random_steps)
        return output
    def get_exercise(self, quantity: int, guitar: dict) -> exercise.Exercise:
        """ Returns exercise """
        if guitar["kind"] != "instrument":
            return None
        if guitar["strings"] <= 0:
            subtitle = "Find the given note(s) on each octave"
        else:
            subtitle = "Find the given note(s) on each string"

        note_obj = note.Note()
        random_steps = []

        for step_index in range(0, quantity):  # pylint: disable=W0612
            step_text = ""

            note_count_of_step = random.randint(1, self._MAX_NOTE_PER_STEP)
            notes_of_step = note_obj.get_random_notes(note_count_of_step)
            for note_of_step in notes_of_step:
                if step_text != "":
                    step_text += ", "
                step_text += note_of_step

            random_step = exercise_step.ExerciseStep(step_text)
            random_steps.append(random_step)

        output = exercise.Exercise(self._TITLE,
                                   subtitle,
                                   random_steps,
                                   practice_category=self.category)

        return output
示例#12
0
    def get_exercise(self, quantity: int, guitar: dict) -> exercise.Exercise:
        """ Returns random chord exercises """
        if guitar["kind"] != "instrument":
            return None

        random_steps = []
        chord = Chord()

        while len(random_steps) < quantity:
            random_chord_count = random.randint(2, 5)
            random_chords = []
            while len(random_chords) < random_chord_count:
                random_chord = chord.get_random_chord()
                random_chords.append(random_chord)

            random_chord_txt = ""
            for random_chord in random_chords:
                if random_chord_txt != "":
                    random_chord_txt += "  |  "
                random_chord_txt += random_chord

            random_step = exercise_step.ExerciseStep("Random Idea",
                                                     random_chord_txt)
            random_steps.append(random_step)

        output = exercise.Exercise(self._TITLE,
                                   self._SUBTITLE,
                                   random_steps,
                                   practice_category=self.category)

        return output
    def get_exercise(self, quantity: int, guitar: dict) -> exercise.Exercise:
        """ Returns scale degree sequence exercise """
        if guitar["kind"] != "instrument":
            return None
        random_steps = []

        for quantity_pos in range(quantity):  # pylint: disable=W0612
            random_count = random.randint(2, 7)  # pylint: disable=W0612
            random_degrees = degree.Degree().get_random_degrees(7)
            sequence_txt = ""
            for random_pos in range(random_count):  # pylint: disable=W0612
                if sequence_txt != "":
                    sequence_txt += ", "
                sequence_txt += str(random_degrees.pop(0))

            random_scale = scale.Scale().get_random_scale()

            random_step = exercise_step.ExerciseStep(random_scale,
                                                     sequence_txt)
            random_steps.append(random_step)

        output = exercise.Exercise(self._TITLE,
                                   self._SUBTITLE,
                                   random_steps,
                                   practice_category=self.category)

        return output
    def get_exercise(self, quantity: int, guitar: dict) -> exercise.Exercise:
        """ Returns the exercise object """
        random_steps = []

        for step_index in range(0, quantity):  # pylint: disable=W0612
            step_text = ""

            quiz_type = random.randint(0, 2)

            if quiz_type == 0:  # How many flats does Cm have
                chord, oddity = self._key_sig.get_random_chord_and_oddity()
                step_text = f"? {oddity} in {chord}"
            elif quiz_type == 1:  # Which maj has 2 flats
                chord_type = self._key_sig.get_random_chord_type()
                oddity_cnt = str(self._key_sig.get_random_oddity_count())
                oddity = self._key_sig.get_random_oddity()
                step_text = f"? {chord_type} has {oddity_cnt} {oddity}"
            elif quiz_type == 2:  # Name maj chords containing C
                chord_type = self._key_sig.get_random_chord_type()
                odd_note = self._key_sig.get_random_odd_node()
                step_text = f"? {chord_type} has {odd_note}"

            random_step = exercise_step.ExerciseStep(step_text)
            random_steps.append(random_step)

        output = exercise.Exercise(self._TITLE,
                                   self._SUBTITLE,
                                   random_steps,
                                   practice_category=self.category)

        output.helpers = self._produce_helpers()

        return output
    def get_exercise(self, quantity: int, guitar: dict) -> exercise.Exercise:
        """ Returns exercise """
        if guitar["kind"] != "instrument":
            return None
        random_steps = []
        random_scales = scale.Scale().get_random_scales(quantity)

        for random_scale in random_scales:

            # Build random secondary text
            if random.randint(0, 1) == 0:
                secondary_text = AbstractPractice.get_random_position_suggestion_text(
                )  # pylint: disable=C0301
            else:
                secondary_text = "Play at least 2 octaves"

            # Add step
            random_step = exercise_step.ExerciseStep(random_scale,
                                                     secondary_text)
            random_steps.append(random_step)

        output = exercise.Exercise(self._TITLE,
                                   ScaleDexterity._get_scale_exercise(guitar),
                                   random_steps,
                                   practice_category=self.category)
        return output
    def get_exercise(self, quantity: int, guitar: dict) -> exercise.Exercise:
        """ Returns voice exercise """
        if guitar["kind"] != "voice":
            return None
        step = exercise_step.ExerciseStep("Pick phone", "Use app")

        output = exercise.Exercise(self._TITLE,
                                   self._SUBTITLE, [step],
                                   practice_category=self.category)

        return output
示例#17
0
    def get_exercise(self, quantity: int) -> exercise.Exercise:

        random_steps = []

        random_chords = chord.Chord().get_random_chords(quantity)

        for random_chord in random_chords:
            random_step = exercise_step.ExerciseStep(random_chord, super(ScaleOnChord, self).get_random_position_suggestion_text())
            random_steps.append(random_step)

        output = exercise.Exercise(self._TITLE, self._SUBTITLE, random_steps)
        return output
示例#18
0
    def get_exercise(self, quantity: int) -> exercise.Exercise:
        random_steps = []

        random_modes = mode.Mode().get_random_modes(quantity)

        for random_mode in random_modes:
            random_step = exercise_step.ExerciseStep(
                random_mode,
                super(ScaleOfMode, self).get_random_position_suggestion_text())
            random_steps.append(random_step)

        output = exercise.Exercise(self._TITLE, self._SUBTITLE, random_steps)
        return output
示例#19
0
    def get_exercise(self, quantity: int, guitar: dict) -> exercise.Exercise:
        """ Returns anchor note exercise """
        if guitar["kind"] != "instrument":
            return None

        random_steps = []
        i = random.randint(0, 1)

        if i == 0:
            random_steps.append(exercise_step.ExerciseStep("random song"))
        else:
            for random_note in note.Note().get_random_notes(quantity):
                context_count = random.randint(1, 5)

                context_type = random.randint(0, 2)
                if context_type == 0:
                    stuff = chord.Chord().get_random_chords(context_count)
                elif context_type == 1:
                    stuff = mode.Mode().get_random_modes(context_count)
                else:
                    stuff = scale.Scale().get_random_scales(context_count)

                stuff_txt = ""
                for stuff_char in stuff:
                    if stuff_txt != "":
                        stuff_txt += " | "
                    stuff_txt += stuff_char

                random_step = exercise_step.ExerciseStep(
                    random_note, stuff_txt)
                random_steps.append(random_step)

        output = exercise.Exercise(self._TITLE,
                                   self._SUBTITLE,
                                   random_steps,
                                   practice_category=self.category)

        return output
    def get_exercise(self, quantity: int) -> exercise.Exercise:

        random_steps = []

        random_degrees = degree.Degree().get_random_degrees(quantity)
        random_scales_1 = mode.Mode().get_random_modes(quantity, with_note=False)
        random_scales_2 = mode.Mode().get_random_modes(quantity, with_note=False)

        for i in range(quantity):
            random_step = exercise_step.ExerciseStep(random_scales_1[i][:3] + " " + str(random_degrees[i]) + " = " + random_scales_2[i][:3] + " ?", "follow by playing on fretboard")
            random_steps.append(random_step)

        output = exercise.Exercise(self._TITLE, self._SUBTITLE, random_steps)
        return output
    def get_exercise(self, quantity: int, guitar: dict) -> exercise.Exercise:
        """ Returns improv exercises """
        if guitar["kind"] != "instrument":
            return None

        random_steps = []
        improvs = []

        for quantity_pos in range(0, quantity):  # pylint: disable=W0612
            if len(improvs) <= 0:
                improvs = self._config["improvs"].copy()

            try:
                random_index = random.randint(0, len(improvs) - 1)
            except Exception:
                break

            random_main_improv = improvs.pop(random_index)
            sub_txt = ""

            sub_appended = False
            for one_two in range(2):  # pylint: disable=W0612
                if len(improvs) == 0:
                    break
                if sub_txt == "":
                    sub_txt += "followed by "
                if len(improvs) == 1:
                    random_index = 0
                else:
                    random_index = random.randint(0, len(improvs) - 1)
                random_sub_improv = improvs.pop(random_index)
                if sub_appended:
                    sub_txt += ", "
                else:
                    sub_appended = True
                sub_txt += random_sub_improv

            random_step = exercise_step.ExerciseStep(random_main_improv,
                                                     sub_txt)
            random_steps.append(random_step)

        output = exercise.Exercise(self._TITLE,
                                   self._SUBTITLE,
                                   random_steps,
                                   practice_category=self.category)

        flukebox_helper = get_flukebox_helper("backing_playlist")
        if flukebox_helper is not None:
            output.helpers = [flukebox_helper]
        return output
示例#22
0
    def get_exercise(self, quantity: int) -> exercise.Exercise:

        random_steps = []

        random_chords = chord.Chord().get_random_chords(quantity)
        random_degrees = degree.Degree().get_random_degrees(quantity)

        for i in range(quantity):
            random_step = exercise_step.ExerciseStep(
                random_chords[i] + " deg " + str(random_degrees[i]),
                "follow by playing on fretboard")
            random_steps.append(random_step)

        output = exercise.Exercise(self._TITLE, self._SUBTITLE, random_steps)
        return output
示例#23
0
    def get_exercise(self, quantity: int) -> exercise.Exercise:

        random_steps = []
        one_liners = []

        for i in range(0, quantity):
            if len(one_liners) == 0:
                one_liners = self._ONE_LINERS.copy()
            random_index = random.randint(0, len(one_liners) - 1)
            random_one_liner = one_liners.pop(random_index)
            random_step = exercise_step.ExerciseStep(random_one_liner, "")
            random_steps.append(random_step)

        output = exercise.Exercise(self._TITLE, self._SUBTITLE, random_steps)
        return output
示例#24
0
    def get_exercise(self, quantity: int, guitar: dict) -> exercise.Exercise:
        """ Returns harmonic over random chord connection exercises """
        if guitar["strings"] <= 0:
            return None

        random_steps = []
        random_chords = chord.Chord().get_random_chords(quantity)

        for random_chord in random_chords:
            random_step = exercise_step.ExerciseStep(random_chord, "")
            random_steps.append(random_step)

        output = exercise.Exercise(self._TITLE,
                                   self._SUBTITLE,
                                   random_steps,
                                   practice_category=self.category)
        return output
示例#25
0
    def get_exercise(self, quantity: int, guitar: dict) -> exercise.Exercise:
        """ Returns improv exercises """
        if guitar["kind"] != "instrument":
            return None

        random_step = exercise_step.ExerciseStep("Pick random song",
                                                 "in FlukeBox")
        random_steps = [random_step]

        output = exercise.Exercise(self._TITLE,
                                   self._SUBTITLE,
                                   random_steps,
                                   practice_category=self.category)

        flukebox_helper = get_flukebox_helper("final_playlist", no_local=True)
        if flukebox_helper is not None:
            output.helpers = [flukebox_helper]
        return output
示例#26
0
    def get_exercise(self, quantity: int, guitar: dict) -> exercise.Exercise:
        """ Returns arpeggio exercise """
        if guitar["kind"] != "instrument":
            return None

        # ---Preparation-----

        random_steps = []
        random_scales = []

        # ---Build random list-----

        random_chords = chord.Chord().get_random_chords(quantity)
        quantity_left = quantity - len(random_chords)
        if quantity_left > 0:
            random_scales = scale.Scale().get_random_scales(quantity_left)

        random_stuff = []

        for i in range(len(random_chords)):
            random_stuff.append(random_chords[i])

        try:
            for i in range(len(random_scales)):
                random_stuff.append(random_scales[i])
        except Exception:
            pass

        # ---Build return list-----

        for random_arp in random_stuff:
            suggested_position = Position.get_random_chord_position()

            random_step = exercise_step.ExerciseStep(
                random_arp, f"Suggested position: {str(suggested_position)}")

            random_steps.append(random_step)

        output = exercise.Exercise(self._TITLE,
                                   self._get_arpeggio_type(),
                                   random_steps,
                                   practice_category=self.category)

        return output
示例#27
0
    def get_exercise(self, quantity: int, guitar: dict) -> exercise.Exercise:
        """ Returns degree memo exercises """
        random_steps = []
        random_chords = chord.Chord().get_random_chords(quantity)
        random_degrees = degree.Degree().get_random_degrees(
            quantity, exclude_unison=True)

        for quantity_pos in range(quantity):
            random_step = exercise_step.ExerciseStep(
                f"{random_chords[quantity_pos]} deg {str(random_degrees[quantity_pos])}",
                "follow by playing")
            random_steps.append(random_step)

        output = exercise.Exercise(self._TITLE,
                                   self._SUBTITLE,
                                   random_steps,
                                   practice_category=self.category)

        return output
示例#28
0
    def get_exercise(self, quantity: int) -> exercise.Exercise:

        note_obj = note.Note()
        random_steps = []

        for step_index in range(0, quantity):
            step_text = ""

            notes_of_step = note_obj.get_random_notes(self._STRINGS)
            for note_of_step in notes_of_step:
                if step_text != "":
                    step_text += ", "
                step_text += note_of_step

            random_step = exercise_step.ExerciseStep(step_text)
            random_steps.append(random_step)

        output = exercise.Exercise(self._TITLE, self._SUBTITLE, random_steps)
        return output
示例#29
0
    def get_exercise(self, quantity: int, guitar: dict) -> exercise.Exercise:
        """ Returns random online lesson """
        if guitar["kind"] != "instrument":
            return None
        if not AbstractUrlList._is_guitar_eligible(guitar):
            return None
        if self._config_section not in self._config:
            return None
        if len(self._config[self._config_section]) <= 0:
            return None

        lesson = self._current_lesson
        step = exercise_step.ExerciseStep(lesson["name"], lesson["url"])
        steps = [step]
        output = exercise.Exercise(self._title,
                                   self._subtitle,
                                   steps,
                                   practice_category=self.category)
        output.helpers = self._produce_helpers()
        return output
    def get_exercise(self, quantity: int, guitar: dict) -> exercise.Exercise:
        """ Returns lazy fingers exercises """
        if guitar["kind"] != "instrument":
            return None
        string_count = guitar["strings"]
        if string_count <= 0:
            return None

        metronome = Metronome()
        random_steps = []
        hand = Hand()
        while len(random_steps) < quantity:
            permutation_count = randint(LeftFingerPermutations._AT_LEAST,
                                        self._config["max_left_permutation"])
            permutations = hand.get_random_fret_finger_permutations(
                permutation_count)
            permutation_text = ""
            for permutation in permutations:
                if permutation_text != "":
                    permutation_text += " |"
                for finger in permutation:
                    permutation_text += " " + str(finger.number)
            first_fret = LeftFingerPermutations._get_random_fret()
            random_bpm = metronome.get_random_bpm()
            random_step = exercise_step.ExerciseStep(
                f"Fret {str(first_fret)} ({str(random_bpm)} bpm)",
                sub_text=permutation_text)

            random_step.helpers = [
                ExerciseHelper(ExerciseHelperType.METRONOME,
                               {"bpm": random_bpm})
            ]

            random_steps.append(random_step)

        output = exercise.Exercise(self._TITLE,
                                   self._SUBTITLE,
                                   random_steps,
                                   practice_category=self.category)

        return output