Evaluation metrics for machine-composed symbolic music.
Python implementation of the evaluation metrics proposed in Section 5 of our paper:
The supported input format is event token sequences that can be mapped to MIDIs, rather than general MIDIs. See this paper (Huang and Yang, 2020) for a thorough introduction.
initPaths.m
: for MATLAB (SM Toolbox) importssm_compute_scapeplot.m
: MATLAB script for computing SSMs and scape plotsrun_matlab_scapeplot.py
: Python program that invokes the MATLAB script aboverun_python_scapeplot.py
: Python-native equivalent of run_matlab_scapeplot.py
vis_scapeplot.py
: visualizes the computed scape plotsrun_all_metrics.py
: runs all evaluation metrics and outputs resultsmusdr/
testdata/
: contains example testdataeval_metrics.py
: contains the implementation of the 4 metrics mentioned aboveside_utils.py
: some I/O and computation utilitiesmueller_audio_tools/
: contains the Python equivalents of the required utilities in SM Toolbox, retrieved from FMP NotebooksClone this repository
Get Python 3.6 (with which we tested our functions and scripts)
Install the requirements with pip3
(or pip
, depending on your system)
pip3 install -r requirements.txt
NOTE: all of the following commands run on the example testdata under musdr/testdata/
-- required for metric SI
More tedious setup, but runs faster
Get MATLAB (if you don't have one)
Download the "SM Toolbox" (Müller et. al, 2013) for scape plot computation
MATLAB_SM-Toolbox_1.0/MATLAB-Chroma-Toolbox_2.0/wav_to_audio.m
(line 107, 108)if strcmp(ext,'.wav')
[f_audio,fs,nbits] = wavread(strcat(dirAbs,dirRel,wavfilename));
if ~( strcmp(ext,'.mp3') && strcmp(ext, '.wav') )
[f_audio,fs] = audioread(strcat(dirAbs,dirRel,wavfilename));
nbits = 24;
Run the Python script that invokes the MATLAB function to compute scape plots
python3 run_matlab_scapeplot.py \
-a musdr/testdata/audio \
-s musdr/testdata/ssm \
-p musdr/testdata/scplot \
-j 1
-a
: input audio directory-s
: output directory for SSMs-p
: output directory for scape plots-j
: number of processes spawned for scape plot computation (optional, defaults to 1
; 2~4
is recommended)python3 run_python_scapeplot.py \
-a musdr/testdata/audio \
-s musdr/testdata/ssm \
-p musdr/testdata/scplot \
-j 1
-a
: input audio directory-s
: output directory for SSMs-p
: output directory for scape plots-j
: number of processes spawned for scape plot computation (optional, defaults to 1
; 2~4
is recommended).mat
and .npy
formats
python3 vis_scapeplot.py \
-p musdr/testdata/scplot \ # input scape plots directory
-f musdr/testdata/scfig # scape plot figures output directory
run_all_metrics.py
when you have computed the fitness scape plots
python3 run_all_metrics.py \
-s musdr/testdata/symbolic \
-p musdr/testdata/scplot \
-o testout.csv \
--timescale_bounds 3 8 15
-s
: input symbolic music directory-p
: input scape plots directory (having the same pieces as the symbolic music directory)-o
: path to output file for results--timescale_bounds
: timescale bounds for short-, mid-, and long-term SI metric (optional, defaults to 3 8 15
)librosa
This repository makes use of the following open-source utilities: