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) -> 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._TITLE, self._SUBTITLE, random_steps) return output
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
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
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
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
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
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) -> 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
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
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
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
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
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
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
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
def get_exercise(self, quantity: int) -> exercise.Exercise: random_steps = [] for i in range(quantity): random_count = random.randint(2, 7) random_degrees = degree.Degree().get_random_degrees(7) sequence_txt = "" for n in range(random_count): 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) return output
def get_exercise(self, quantity: int, guitar: dict) -> exercise.Exercise: """ Returns random one liner exercises """ if guitar["kind"] != "instrument": return None random_steps = [] one_liners = [] for quantity_pos in range(0, quantity): # pylint: disable=W0612 if len(one_liners) == 0: one_liners = self._config["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, practice_category=self.category) return output
def get_exercise(self, quantity: int, guitar: dict) -> exercise.Exercise: """ Returns random scale on chord exercises """ if guitar["kind"] != "instrument": 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, AbstractPractice.get_random_position_suggestion_text() ) random_steps.append(random_step) output = exercise.Exercise( self._TITLE, ScaleOnChord._get_subtitle(), random_steps, practice_category=self.category) return output
def get_exercise(self, quantity: int, guitar: dict) -> exercise.Exercise: """ Returns random interval exercises """ if guitar["kind"] != "instrument": return None degree_obj = degree.Degree() mode_obj = mode.Mode() random_steps = [] for step_index in range(0, quantity): # pylint: disable=W0612 mode_text = f"{mode_obj.get_random_mode()} {self._get_direction()}" step_text = "" while True: degree_count = 2 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, practice_category=self.category) return output
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: # ---Preparation----- random_steps = [] position_obj = position.Position() # ---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: pass # ---Build return list----- for random_arp in random_stuff: suggested_position = position_obj.get_random_position() random_step = exercise_step.ExerciseStep( random_arp, "Suggested position: " + str(suggested_position)) random_steps.append(random_step) output = exercise.Exercise(self._TITLE, self._get_arpeggio_type(), random_steps) return output