`pianoroll_str_to_df` does not recreate input when it should.
JamesOwers opened this issue · 1 comments
JamesOwers commented
Whilst this is not a requirement necessarily, this error gives me concern that it is not working as expected.
To recreate the error:
from mdtk.formatters import df_to_pianoroll_str, pianoroll_str_to_df
pitches = [60, 60, 62, 64, 62, 60, 64, 60, 64]
bpm = 120
beat_dur = 60/bpm * 1000
durations = [1, 1, 1, 1, 1, .5, .5, 2, 2]
durations = [int(beats*beat_dur) for beats in durations]
onsets = [0, 1, 2, 3, 4, 5.5, 5.5, 6, 6]
onsets = [int(beats*beat_dur) for beats in onsets]
excerpt = pd.DataFrame(
{
"onset": onsets,
"track": 0,
"pitch": pitches,
"dur": durations,
}
)
pianoroll_str = df_to_pianoroll_str(excerpt, time_increment=250)
note_df = pianoroll_str_to_df(pianoroll_str, time_increment=250)
assert note_df.equals(excerpt), "oops"
The diff is index 4, duration increases from 500 to 750 i.e. the silence is ignored.
Additionally the docstring is incorrect - it creates a note df, not a pianoroll