Exemple #1
0
def _note(mn,
          attr_name_idx_map=None,
          attr_val_default_map=None,
          num_attributes=None):
    mn.attr_name_idx_map = attr_name_idx_map or ATTR_NAME_IDX_MAP
    mn.attr_val_default_map = attr_val_default_map or ATTR_VAL_DEFAULT_MAP
    mn.num_attributes = num_attributes or NUM_ATTRIBUTES
    return NoteSequence.new_note(mn)
    for _ in range(NUM_MEASURES):
        note_config = MakeNoteConfig.copy(NOTE_CONFIG)
        ostinato_measure = Measure(num_notes=notes_per_measure,
                                   meter=METER,
                                   swing=swing,
                                   mn=note_config)

        for i in range(notes_per_measure):
            note_values = NoteValues(ATTR_NAMES)
            note_values.time = i * dur_val
            note_values.duration = dur_val
            note_values.velocity = int(BASE_VELOCITY - (
                (i % notes_per_measure) / VELOCITY_FACTOR))
            note_values.pitch = SCALE[i % NUM_NOTES_IN_SCALE].pitch
            note_config.attr_val_default_map = note_values.as_dict()
            note = NoteSequence.new_note(note_config)
            ostinato_measure.append(note)
        ostinato_measure.apply_swing()
        ostinato_track.append(ostinato_measure)

    # Chords
    octave = OCTAVE - 2
    dur = NoteDur.WHOLE

    # noinspection PyTypeChecker
    dur_val: float = dur.value
    notes_per_measure = int((1 / dur_val) * (BEATS_PER_MEASURE * BEAT_DUR_VAL))
    for _ in range(NUM_MEASURES):
        note_config = MakeNoteConfig.copy(NOTE_CONFIG)
        chords_measure = Measure(meter=METER,
                                 swing=swing,