Skip to content

get_piano_roll sustains some notes too long #242

@drscotthawley

Description

@drscotthawley

Hi Colin! I see a number of issues and PRs related to get_piano_roll(), yet I'm not sure which of them my issue fits best with so I'm opening a new one:

I notice many notes in the piano roll are sustained for much longer than they should be, resulting in long horizontal lines, independent of the choice for fs.

For example, here is a plt.imshow() for the get_piano_roll output for piano instrument in file number 028/028.mid in the POP909 Dataset:

def plot_piano_roll(pr_array): 
    plt.figure(figsize=(8, 8))
    plt.imshow(np.flipud(pr_array), aspect='auto')
    plt.show()

for instrument in pm.instruments: 
  name = instrument.name.upper()
        if  name in ['MELODY', 'PIANO']:
            print(f"get_piano_rolls: instrument.name = {name}")
            piano_rolls[name] = instrument.get_piano_roll(fs=fs)
            if name == 'PIANO':
                plot_piano_roll(piano_rolls[name])

Figure_0

The same part displayed in Logic Pro looks different; it does not have the long horizontal lines:
Screenshot 2024-02-17 at 7 30 15 PM

Also, when I plot it using the method from the Magenta music_generation.ipynb Colab Notebook, there are no long horizontal lines:
pr_long_way

I've tried different fs values (from 4 to 1000) and different image sizes to see if the long horizontal lines in the first image are just some sort of plotting artifact, but... I can't get rid of them.

This issue applies to both the instrument.get_piano_roll() and the full pm.get_piano_roll().
The issue applies to several other files in that POP909 dataset, e.g. 028, 030, 038, 039, 040, 046, 047, 050, 052, 057, 061, 064, 065, 066, 068,... I stopped counting. Logic and other viewers show them ok, but get_piano_roll seems to incorrectly sustain notes for many, many measures.

Is there something I'm doing wrong that 's leading to the "long horizontal lines"? I'd like an array that reflects something more like from the other two plotting methods.

Thanks!

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