Skip to content

Commit

Permalink
Port MIDI utils and tests (#1)
Browse files Browse the repository at this point in the history
* add skeleton

* port midi.py

* update path for maestro metadata json

* add tests and ci
  • Loading branch information
loubbrad authored Nov 18, 2024
1 parent b487c93 commit da74e2d
Show file tree
Hide file tree
Showing 12 changed files with 1,641 additions and 2 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Python CI

on:
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: install
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: install
run: |
python -m pip install --upgrade pip
pip install .[dev]
- name: black
run: |
black --check .
- name: mypy
run: |
mypy ariautils
mypy tests
- name: Run tests with pytest
run: |
pytest
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# ariautils
MIDI tokenizers and pre-processing utils.
# aria-utils

An extremely lightweight and simple library for pre-processing and tokenizing MIDI files.


Empty file added ariautils/ __init__.py
Empty file.
242 changes: 242 additions & 0 deletions ariautils/config/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
{
"data": {
"tests": {
"max_programs":{
"run": false,
"args": {
"max": 12
}
},
"max_instruments":{
"run": false,
"args": {
"max": 7
}
},
"total_note_frequency":{
"run": false,
"args": {
"min_per_second": 1.5,
"max_per_second": 30
}
},
"note_frequency_per_instrument":{
"run": false,
"args": {
"min_per_second": 1.0,
"max_per_second": 25
}
},
"min_length":{
"run": false,
"args": {
"min_seconds": 30
}
}
},
"pre_processing": {
"remove_instruments": {
"run": true,
"args": {
"piano": false,
"chromatic": true,
"organ": false,
"guitar": false,
"bass": false,
"strings": false,
"ensemble": false,
"brass": false,
"reed": false,
"pipe": false,
"synth_lead": false,
"synth_pad": true,
"synth_effect": true,
"ethnic": true,
"percussive": true,
"sfx": true
}
}
},
"metadata": {
"functions": {
"composer_filename": {
"run": false,
"args": {
"composer_names": ["bach", "beethoven", "mozart", "chopin", "rachmaninoff", "liszt", "debussy", "schubert", "brahms", "ravel", "satie", "scarlatti"]
}
},
"composer_metamsg": {
"run": false,
"args": {
"composer_names": ["bach", "beethoven", "mozart", "chopin", "rachmaninoff", "liszt", "debussy", "schubert", "brahms", "ravel", "satie", "scarlatti"]
}
},
"form_filename": {
"run": false,
"args": {
"form_names": ["sonata", "prelude", "nocturne", "etude", "waltz", "mazurka", "impromptu", "fugue"]
}
},
"maestro_json": {
"run": false,
"args": {
"composer_names": ["bach", "beethoven", "mozart", "chopin", "rachmaninoff", "liszt", "debussy", "schubert", "brahms", "ravel", "satie", "scarlatti"],
"form_names": ["sonata", "prelude", "nocturne", "étude", "waltz", "mazurka", "impromptu", "fugue"]
}
},
"listening_model": {
"run": false,
"args": {
"tag_names": ["happy", "sad"]
}
},
"abs_path": {
"run": true,
"args": {}
}
},
"manual": {
"genre": ["classical", "jazz"],
"form": ["sonata", "prelude", "nocturne", "étude", "waltz", "mazurka", "impromptu", "fugue"],
"composer": ["bach", "beethoven", "mozart", "chopin", "rachmaninoff", "liszt", "debussy", "schubert", "brahms", "ravel", "satie", "scarlatti"]
}
},
"finetuning": {
"min_noisy_interval_ms": 5000,
"max_noisy_interval_ms": 60000,
"min_clean_interval_ms": 60000,
"max_clean_interval_ms": 200000,
"noising": {
"activation_prob": 0.95,
"remove_notes": {
"activation_prob": 0.75,
"min_ratio": 0.1,
"max_ratio": 0.4
},
"adjust_velocity": {
"activation_prob": 0.3,
"min_adjust": 1,
"max_adjust": 30,
"max_ratio": 0.1,
"min_ratio": 0.30
},
"adjust_onsets": {
"activation_prob": 0.5,
"min_adjust_s": 0.03,
"max_adjust_s": 0.07,
"max_ratio": 0.15,
"min_ratio": 0.5
},
"quantize_onsets": {
"activation_prob": 0.15,
"min_quant_s": 0.05,
"max_quant_s": 0.15,
"max_vel_delta": 45
}
}
}
},

"tokenizer": {
"rel": {
"ignore_instruments": {
"piano": false,
"chromatic": true,
"organ": false,
"guitar": false,
"bass": false,
"strings": false,
"ensemble": false,
"brass": false,
"reed": false,
"pipe": false,
"synth_lead": false,
"synth_pad": true,
"synth_effect": true,
"ethnic": true,
"percussive": true,
"sfx": true
},
"instrument_programs": {
"piano": 0,
"chromatic": 13,
"organ": 16,
"guitar": 24,
"bass": 32,
"strings": 40,
"ensemble": 48,
"brass": 56,
"reed": 64,
"pipe": 73,
"synth_lead": 80,
"synth_pad": 88,
"synth_effect": 96,
"ethnic": 104,
"percussive": 112,
"sfx": 120
},
"drum_velocity": 60,
"velocity_quantization": {
"step": 15
},
"time_quantization": {
"num_steps": 500,
"step": 10
},
"composer_names": ["bach", "beethoven", "mozart", "chopin", "rachmaninoff", "liszt", "debussy", "schubert", "brahms", "ravel", "satie", "scarlatti"],
"form_names": ["sonata", "prelude", "nocturne", "étude", "waltz", "mazurka", "impromptu", "fugue"],
"genre_names": ["jazz", "classical"]
},
"abs": {
"ignore_instruments": {
"piano": false,
"chromatic": true,
"organ": false,
"guitar": false,
"bass": false,
"strings": false,
"ensemble": false,
"brass": false,
"reed": false,
"pipe": false,
"synth_lead": false,
"synth_pad": true,
"synth_effect": true,
"ethnic": true,
"percussive": true,
"sfx": true
},
"instrument_programs": {
"piano": 0,
"chromatic": 13,
"organ": 16,
"guitar": 24,
"bass": 32,
"strings": 40,
"ensemble": 48,
"brass": 56,
"reed": 64,
"pipe": 73,
"synth_lead": 80,
"synth_pad": 88,
"synth_effect": 96,
"ethnic": 104,
"percussive": 112,
"sfx": 120
},
"drum_velocity": 60,
"velocity_quantization": {
"step": 10
},
"abs_time_step_ms": 5000,
"max_dur_ms": 5000,
"time_step_ms": 10,
"composer_names": ["bach", "beethoven", "mozart", "chopin", "rachmaninoff", "liszt", "debussy", "schubert", "brahms", "ravel", "satie", "scarlatti"],
"form_names": ["sonata", "prelude", "nocturne", "étude", "waltz", "mazurka", "impromptu", "fugue"],
"genre_names": ["jazz", "classical"]
},
"lm": {
"tags": ["happy", "sad"]
}
}
}
Loading

0 comments on commit da74e2d

Please sign in to comment.