Exemple #1
0
def add_tuples_to_track(track, df):
    for row in df.iterrows():
        data = row[1]
        pitch = data["pitch"] if isinstance(
            data["pitch"], int) else Note.index_from_string(data["pitch"])
        track.append(data["event_type_fun"](tick=data["tick"],
                                            velocity=data["velocity"],
                                            pitch=pitch))
    return track
Exemple #2
0
    def get_list_of_chord_notes_from_chord(chord_notes):
        """Extract the string representations of a list of Note objects.

        :param chord_notes: a list of Note objects

        :return: a list of string representations of a list of Note objects.
        """
        return [
            Note.index_from_string(chord_note.note + str(chord_note.octave))
            for chord_note in chord_notes
        ]
Exemple #3
0
 def _create_melody_note_tuple(self, start_tick):
     velocity = random.randint(50, 90)
     cur_note = random.choice(self.available_notes)
     cur_note = Note.index_from_string(cur_note.note + str(cur_note.octave))
     note_length = random.choice(self.note_len_choices)
     # ["event_type_fun", "tick", "duration", "pitch", "velocity"]
     return [
         MidiEventStager(midi.NoteOnEvent, start_tick, note_length,
                         cur_note, velocity),
         MidiEventStager(midi.NoteOffEvent, start_tick + note_length,
                         note_length, cur_note, 0)
     ]