def extract_events(input_path): note_items, tempo_items = utils.read_items(input_path) note_items = utils.quantize_items(note_items) max_time = note_items[-1].end items = tempo_items + note_items groups = utils.group_items(items, max_time) events = utils.item2event(groups) return events
def extract_events(self, input_path): note_items, tempo_items = utils.read_items(input_path) note_items = utils.quantize_items(note_items) max_time = note_items[-1].end if 'chord' in self.checkpoint_path: chord_items = utils.extract_chords(note_items) items = chord_items + tempo_items + note_items else: items = tempo_items + note_items groups = utils.group_items(items, max_time) events = utils.item2event(groups) return events
def extract_events(input_path, extract_chords=True): try: note_items, tempo_items = utils.read_items(input_path) note_items = utils.quantize_items(note_items) max_time = note_items[-1].end if extract_chords: chord_items = utils.extract_chords(note_items) items = chord_items + tempo_items + note_items else: items = tempo_items + note_items groups = utils.group_items(items, max_time) events = utils.item2event(groups) except: return None return ['{}_{}'.format(e.name, e.value) for e in events]
def extract_events(self, input_path, transposition_steps=0): if self.transpose_input_midi_to_key: transposition_steps = transpose.get_number_of_steps_for_transposition_to( input_path, self.transpose_input_midi_to_key) if transposition_steps != 0: print("Transposing {} steps to {}.".format( transposition_steps, self.transpose_input_midi_to_key)) note_items, tempo_items = utils.read_items( input_path, transposition_steps=transposition_steps) note_items = utils.quantize_items(note_items) max_time = note_items[-1].end if self.use_chords: chord_items = utils.extract_chords(note_items) items = chord_items + tempo_items + note_items else: items = tempo_items + note_items groups = utils.group_items(items, max_time) events = utils.item2event(groups) return events
def mtom_extract_events(self, input_path, ticks=120): """Parse midi file to extract events (e.g. Note On, Note Velocity, etc.). Args: input_path: path to current midi file. ticks: used to quantize timings of items in song. Return values: events: list of events for song. normal_six_seven_note_items: list of note items for normal 6/7's in song. raised_six_seven_note_items: list of note items for raised 6/7's in song. """ note_items, \ normal_six_seven_note_items, \ raised_six_seven_note_items, \ tempo_items = self.mtom_read_items(input_path) normal_six_seven_note_indices = self.get_six_seven_note_indices(note_items, normal_six_seven_note_items) raised_six_seven_note_indices = self.get_six_seven_note_indices(note_items, raised_six_seven_note_items) note_items = utils.quantize_items(note_items, ticks) normal_six_seven_note_items = [note_items[idx] for idx in normal_six_seven_note_indices] raised_six_seven_note_items = [note_items[idx] for idx in raised_six_seven_note_indices] max_time = note_items[-1].end if 'chord' in self.checkpoint_path: chord_items = utils.extract_chords(note_items) items = chord_items + tempo_items + note_items else: items = tempo_items + note_items groups = utils.group_items(items, max_time) events = utils.item2event(groups) return events, normal_six_seven_note_items, raised_six_seven_note_items