Skip to content

muspy.show_pianoroll bug when the music tracks are altered. #80

@Juno-T

Description

@Juno-T

To reproduce:

dataset = muspy.LakhMIDIAlignedDataset("path/to/dataset")
music = dataset[1].copy()
music.tracks = music.tracks[:1]
muspy.show_pianoroll(music, mode="hybrid", preset="frame")

The error:

File venv/lib/python3.10/site-packages/muspy/outputs/pianoroll.py:57, in to_pypianoroll(music)
     55 for tempo in music.tempos:
     56     tempo_arr[position : tempo.time] = qpm
---> 57     tempo_arr[tempo.time] = tempo.qpm
     58     position = tempo.time + 1
     59     qpm = tempo.qpm

IndexError: index 29085 is out of bounds for axis 0 with size 29085

The bug is probably how the music length is calculated.
i.e.
music.get_end_time() return the same number as music.tempos[-1].time if the tracks are altered.
I'm not sure if get_end_time() function or the piano roll function should be fixed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions