Repository for the paper Learning Hierarchical Metrical Structure Beyond Measures (to be presented on ISMIR 2022).
https://github.com/music-x-lab/Self-Supervised-Metrical-Structure.
See output
folder for demos from the validation and test split of RWC-Pop.
Each output MIDI file contains an extra MIDI track with name Layers
besides tracks from the original MIDI file. Layers
is a drum track that labels L drum notes on a level-L boundary beyond measures (better viewed in an DAW with track-wise piano rolls). A downbeat without any drum notes is interpreted as a level-0 boundary.
If you want to deploy the pre-trained model, download the pretrained weights simple_tcn_v2.0_filtered.sdict
here and put it in the cache_data
folder.
- RWC Pop: you need to manually acquire RWC-Pop's midi files here and put your own path in
settings.py
. For example, if you write insettings.py
the following code:
RWC_DATASET_PATH = '/my_dataset/rwc_pop_dataset'
Then all the RWC-Pop MIDI file should be located at:
/my_dataset/rwc_pop_dataset/AIST.RWC-MDB-P-2001.SMF_SYNC/RM-P001.SMF_SYNC.MID
/my_dataset/rwc_pop_dataset/AIST.RWC-MDB-P-2001.SMF_SYNC/RM-P002.SMF_SYNC.MID
/my_dataset/rwc_pop_dataset/AIST.RWC-MDB-P-2001.SMF_SYNC/RM-P003.SMF_SYNC.MID
...
- LMD dataset: to configure LMD dataset, download
LMD-matched
from here and put your own insettings.py
. For example, if you write insettings.py
the following code:
LMD_MATCHED_FOLDER = '/my_dataset/lmd_matched'
Then all the LMD MIDI file should be located at:
/my_dataset/lmd_matched/A/A/A/TRAAAGR128F425B14B/1d9d16a9da90c090809c153754823c2b.mid
/my_dataset/lmd_matched/A/A/A/TRAAAGR128F425B14B/5dd29e99ed7bd3cc0c5177a6e9de22ea.mid
/my_dataset/lmd_matched/A/A/A/TRAAAGR128F425B14B/b97c529ab9ef783a849b896816001748.mid
...
- Pop909 dataset: test midis already included in the repo.
To run the pretrained model on custom MIDI files:
- Make sure the MIDI file has correct metre, downbeat and beat labels derived from tempo change & time signature events (e.g., every tempo change events mark a downbeat position, you may use DAWs or python packages like
pretty_midi
to check this) - Run
python simple_tcn_eval.py path/to/your_midi.mid
. - A prediction plot will be shown and a
output/model_name/your_midi.mid_crf.mid
file will be generated.
To retrain the model:
- Configure RWC dataset path as instructed above
- Run
data_preprocessing_train.py
to generate the data npy file. - Run
simple_tcn.py
to train the model. The trained model will be saved incache_data
folder.
To reproduce experiments on RWC-Pop and Pop909:
- Download the pretrained model weights as instructed above
- Configure RWC dataset path as instructed above
- Run
python simple_tcn_eval.py
.
To reproduce experiments on baseline models:
- Configure RWC dataset path as instructed above
- Run
midi_structure.py
.
To reproduce experiments on LMD-matched:
- Download the pretrained model weights as instructed above
- Configure LMD dataset path as instructed above
- Run
python statistics.py
.