Natooz / MidiTok

MIDI / symbolic music tokenizers for Deep Learning models 🎶
https://miditok.readthedocs.io/
MIT License
693 stars 84 forks source link

Dration token meaning in REMI #174

Closed PRamoneda closed 4 months ago

PRamoneda commented 5 months ago

Hi! Thank you for this amazing library @Natooz

i would want to understand the duration token!

Screenshot from 2024-05-31 13-43-23

Bar_None TimeSig_4/4 Position_0 Tempo_121.29 Pitch_69 Velocity_91 Duration_4.0.4 Bar_None TimeSig_4/4 Position_0 Pitch_69 Velocity_91 Duration_2.0.8 Position_16 Pitch_69 Velocity_91 Duration_2.0.8 Bar_None TimeSig_4/4 Position_0 Pitch_69 Velocity_91 Duration_1.0.8 Position_8 Pitch_69 Velocity_91 Duration_1.0.8 Position_16 Pitch_69 Velocity_91 Duration_1.0.8 Position_24 Pitch_69 Velocity_91 Duration_1.0.8 Bar_None TimeSig_4/4 Position_0 Pitch_69 Velocity_91 Duration_0.4.8 Position_4 Pitch_69 Velocity_91 Duration_0.4.8 Position_8 Pitch_69 Velocity_91 Duration_0.4.8 Position_12 Pitch_69 Velocity_91 Duration_0.4.8 Position_16 Pitch_69 Velocity_91 Duration_0.4.8 Position_20 Pitch_69 Velocity_91 Duration_0.4.8 Position_24 Pitch_69 Velocity_91 Duration_0.4.8 Position_28 Pitch_69 Velocity_91 Duration_0.4.8 Bar_None TimeSig_4/4 Position_0 Pitch_69 Velocity_91 Duration_0.2.8 Position_2 Pitch_69 Velocity_91 Duration_0.2.8 Position_4 Pitch_69 Velocity_91 Duration_0.2.8 Position_6 Pitch_69 Velocity_91 Duration_0.2.8 Position_8 Pitch_69 Velocity_91 Duration_0.2.8 Position_10 Pitch_69 Velocity_91 Duration_0.2.8 Position_12 Pitch_69 Velocity_91 Duration_0.2.8 Position_14 Pitch_69 Velocity_91 Duration_0.2.8 Position_16 Pitch_69 Velocity_91 Duration_0.2.8 Position_18 Pitch_69 Velocity_91 Duration_0.2.8 Position_20 Pitch_69 Velocity_91 Duration_0.2.8 Position_22 Pitch_69 Velocity_91 Duration_0.2.8 Position_24 Pitch_69 Velocity_91 Duration_0.2.8 Position_26 Pitch_69 Velocity_91 Duration_0.2.8 Position_28 Pitch_69 Velocity_91 Duration_0.2.8 Position_30 Pitch_69 Velocity_91 Duration_0.2.8 Bar_None TimeSig_4/4 Position_0 Pitch_69 Velocity_91 Duration_0.1.8 Position_1 Pitch_69 Velocity_91 Duration_0.1.8 Position_2 Pitch_69 Velocity_91 Duration_0.1.8 Position_3 Pitch_69 Velocity_91 Duration_0.1.8 Position_4 Pitch_71 Velocity_91 Duration_0.1.8 Position_5 Pitch_69 Velocity_91 Duration_0.1.8

I have search for it in the docs but i can not find it

Natooz commented 5 months ago

Hi, thank you for your message!

The Duration (and TimeShift) tokens take the form of a tuple as: (num_beats, num_samples, resolution) Here the resolution is in "samples" per beat. So for instance the time value of token (2, 3, 8) will be of 2 beats and 3/8 of a beat. For (2, 2, 4) it would be of 2 beats and a half beat (2.5). Note that depending on the beat_res value of the tokenizer's configuration, it can handle different resolutions for different time values, especially higher resolutions for short time duration (i.e. short values will be represented with greater accuracy) and lower resolutions for higher time values (that generally doesn't need to be represented with great accuracy).

Sorry if this wasn't very clear in the documentation. I am actually currently rewriting it, I will make sure to describe in the best terms how MidiTok handles the time and resolutions as you're not the first person to get confused. :)

PRamoneda commented 5 months ago

Thank you so much! I think is important also to clarify that is not the exact implementation of original REMI https://arxiv.org/pdf/2002.00212

github-actions[bot] commented 5 months ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 4 months ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 4 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.