musicaiz
A python framework for symbolic music generation, evaluation and analysis
Science Score: 67.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 2 DOI reference(s) in README -
✓Academic publication links
Links to: arxiv.org, sciencedirect.com -
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (12.2%) to scientific vocabulary
Keywords
Repository
A python framework for symbolic music generation, evaluation and analysis
Basic Info
- Host: GitHub
- Owner: carlosholivan
- License: agpl-3.0
- Language: Python
- Default Branch: main
- Homepage: https://carlosholivan.github.io/musicaiz
- Size: 5.36 MB
Statistics
- Stars: 185
- Watchers: 4
- Forks: 18
- Open Issues: 4
- Releases: 5
Topics
Metadata Files
README.md

MUSICAIZ
A Python library for symbolic music generation, analysis and visualization.
Published in SoftwareX 2023.
| CI |
|
|---|---|
| Paper |
|
| PyPI |
|
| Activity |
|
| QA |
|
| Code |
|
The modules contained in this library are:
- Loaders
contains the basic initialization to import files.
````python from musicaiz.loaders import Musa
midi = Musa(
file="my_midifile.mid"
)
````
- Structure
contains the structure elements in music (instruments, bars and notes).
````python
Define a Note object
from musicaiz.structure import Note
note = Note(
pitch=12,
start=0.0,
end=1.0,
velocity=75,
bpm=120,
resolution=96
)
````
- Harmony
contains the harmonic elements in music (intervals, chords and keys).
````python from musicaiz.structure import Chords, Tonality
# Initialize a chord by its notation
chord_name = "Cm7b5"
chord = Chord(chord_name)
# get the notes in the chord
chord.get_notes(inversion=0)
# Initialize Tonality
tonality = Tonality.E_MINOR
# get different scales
tonality.natural
tonality.harmonic
tonality.melodic
# get the notes in a scale
tonality.scale_notes("NATURAL")
# get a chord from a scale degree
Tonality.get_chord_from_degree(
tonality="E_MINOR",
degree="V",
scale="NATURAL",
chord_type="triad",
)
````
- Rhythm
contains rhythmic or timing elements in music (quantization). - Features
contains classic features to analyze symbolic music data (pitch class histograms...). - Algorithms
contains algorithms for chord prediction, key prediction, harmonic transposition... - Plotters
contains different ways of plotting music (pinorolls or scores).
````python from musicaiz.plotters import Pianoroll, PianorollHTML
# Matplotlib
musa_obj = Musa(midi_sample)
plot = Pianoroll(musa_obj)
plot.plot_instruments(
program=[48, 45],
bar_start=0,
bar_end=4,
print_measure_data=True,
show_bar_labels=False,
show_grid=False,
show=True,
)
# Pyplot HTML
musa_obj = Musa(midi_sample)
plot = PianorollHTML(musa_obj)
plot.plot_instruments(
program=[48, 45],
bar_start=0,
bar_end=4,
show_grid=False,
show=False
)
````
- Tokenizers
contains different encodings to prepare symbolic music data to train a sequence model.
````python from musicaiz.tokenizers import MMMTokenizer, MMMTokenizerArguments
# Tokenize file
midi = "my_midifile.mid"
args = MMMTokenizerArguments(
windowing=True,
time_unit="SIXTEENTH",
num_programs=None,
shuffle_tracks=True,
track_density=False,
window_size=4,
hop_length=1,
time_sig=False,
velocity=False,
quantize=False,
tempo=True,
)
# save configs
MMMTokenizerArguments.save(args, "./")
tokenizer = MMMTokenizer(midi, args)
got = tokenizer.tokenize_file()
# get tokens analysis
my_tokens = "PIECE_START TRACK_START ..."
MMMTokenizer.get_tokens_analytics(my_tokens)
# Convert tokens to Musa objects
MMMTokenizer.tokens_to_musa(
tokens=my_tokens,
absolute_timing=True,
time_unit="SIXTEENTH",
time_sig="4/4",
resolution=96
)
# get vocabulary
MMMTokenizer.get_vocabulary(
dataset_path="apth/to/dataset/tokens",
)
````
- Converters
contains converters to other formats (JSON,...).
````python from musicaiz.loaders import Musa from musicaiz.loaders import musatoproto, prototomusa
# Convert a musicaiz objects in protobufs midi = Musa(midisample, structure="bars") protobuf = musato_proto(midi)
# Convert a protobuf to musicaiz objects musa = prototomusa(protobuf)
````
- Datasets
contains helper methods to work with MIR open-source datasets.
````python from musicaiz.tokenizers import MMMTokenizer, MMMTokenizerArguments from musicaiz.datasets import JSBChorales
# Tokenize a dataset in musicaiz
output_path = "path/to/store/tokens"
args = MMMTokenizerArguments(
prev_tokens="",
windowing=True,
time_unit="HUNDRED_TWENTY_EIGHT",
num_programs=None,
shuffle_tracks=True,
track_density=False,
window_size=32,
hop_length=16,
time_sig=True,
velocity=True,
)
dataset = JSBChorales()
dataset.tokenize(
dataset_path="path/to/JSB Chorales/midifiles",
output_path=output_path,
output_file="token-sequences",
args=args,
tokenize_split="all"
)
vocab = MMMTokenizer.get_vocabulary(
dataset_path=output_path
)
````
- Models
contains ML models to generate symbolic music.
License
This project is licensed under the terms of the AGPL v3 license.
Install
To install the latest stable version run: pip install musicaiz
To install the latest version, clone this repository and run:
pip install -e .
If you want to train the models in the models submodule, you must install apex. Follow the instructions on https://github.com/NVIDIA/apex.
Develop
Conda dev environment
Run the following commands to create a conda env. Note that if you skip the first command, a newer python version might be installed and the package will not work.
conda create --name python=3.9
conda env update -f environment.yml
conda activate musicaiz
Linting
flake8 and black
Typing
Use mypy package to check variables tpyes:
mypy musicaiz
Examples
See docs.
Citing
If you use this software for your research, please cite:
@article{HERNANDEZOLIVAN2023101365,
title = {Musicaiz: A python library for symbolic music generation, analysis and visualization},
journal = {SoftwareX},
volume = {22},
pages = {101365},
year = {2023},
issn = {2352-7110},
doi = {https://doi.org/10.1016/j.softx.2023.101365},
url = {https://www.sciencedirect.com/science/article/pii/S2352711023000614},
author = {Carlos Hernandez-Olivan and Jose R. Beltran},
}
Contributing
Musicaiz software can be extended in different ways, see some example in TODOs. If you want to contribute, please follow the guidelines in Develop
Owner
- Name: Carlos Hernández Oliván
- Login: carlosholivan
- Kind: user
- Location: Zaragoza, Spain
- Company: Universidad de Zaragoza
- Website: carlosholivan.github.io
- Twitter: carlosheroliv
- Repositories: 7
- Profile: https://github.com/carlosholivan
PhD student researching in Machine Learning and Music.
Citation (CITATION.cff)
cff-version: 1.2.0
message: "If you use this software, please cite it as shown below."
title: musicaiz
authors:
- family-names: Hernandez-Olivan
given-names: Carlos
preferred-citation:
type: article
authors:
- family-names: Hernandez-Olivan
given-names: Carlos
orcid: "https://orcid.org/0000-0002-0235-2267"
- family-names: Beltran
given-names: Jose R.
orcid: "https://orcid.org/0000-0002-7500-4650"
title: "musicaiz: A Python Library for Symbolic Music Generation, Analysis and Visualization"
journal: arXiv
year: 2022
license: AGPL-3.0
date-released: 2022-09-15
url: "https://carlosholivan.github.io/musicaiz/"
repository-code: "https://github.com/carlosholivan/musicaiz"
GitHub Events
Total
- Issues event: 3
- Watch event: 18
- Issue comment event: 2
- Fork event: 1
Last Year
- Issues event: 3
- Watch event: 18
- Issue comment event: 2
- Fork event: 1
Committers
Last synced: almost 3 years ago
All Time
- Total Commits: 107
- Total Committers: 2
- Avg Commits per committer: 53.5
- Development Distribution Score (DDS): 0.009
Top Committers
| Name | Commits | |
|---|---|---|
| carlosholivan | c****n@g****m | 106 |
| sonia | 7****6@u****s | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 7
- Total pull requests: 4
- Average time to close issues: 1 day
- Average time to close pull requests: about 2 hours
- Total issue authors: 5
- Total pull request authors: 3
- Average comments per issue: 1.86
- Average comments per pull request: 0.5
- Merged pull requests: 4
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 2
- Pull requests: 0
- Average time to close issues: 2 days
- Average time to close pull requests: N/A
- Issue authors: 2
- Pull request authors: 0
- Average comments per issue: 1.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- juancopi81 (3)
- JLenzy (1)
- hansli112 (1)
- enricocupellini (1)
- dumblob (1)
Pull Request Authors
- carlosholivan (2)
- soniarubiollamas (1)
- aibeatz-dm (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 54 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 5
- Total maintainers: 1
pypi.org: musicaiz
A python framework for symbolic music generation, evaluation and analysis
- Homepage: https://carlosholivan.github.io/musicaiz
- Documentation: https://carlosholivan.github.io/musicaiz/docs
- License: ISC
-
Latest release: 0.1.2
published almost 3 years ago
Rankings
Maintainers (1)
Dependencies
- nbsphinx ==0.8.8
- numpydoc ==1.1.0
- pandoc ==2.2
- sphinx ==4.3.2
- sphinx-design ==0.1.0
- sphinx-gallery ==0.10.1
- sphinx-multiversion ==0.2.4
- sphinx-rtd-theme ==1.0.0
- sphinx_panels ==0.6.0
- sphinxcontrib-svg2pdfconverter ==1.2.0
- coverage ==6.2
- gradio ==3.0.15
- matplotlib ==3.4.3
- mypy ==0.960
- networkx ==2.8.3
- plotly ==5.8.0
- pre-commit *
- pretty_midi ==0.2.9
- prettytable ==3.3.0
- pytest ==6.2.4
- seaborn *
- sklearn ==0.0
- torchsummary ==1.5.1
- tqdm *
- actions/cache v2 composite
- actions/checkout v2 composite
- codecov/codecov-action v3 composite
- conda-incubator/setup-miniconda v2 composite
- actions/checkout v2 composite
- actions/create-release v1 composite
- actions/setup-python v2 composite
- actions/upload-release-asset v1 composite
- pypa/gh-action-pypi-publish main composite
- actions/checkout v2 composite
- actions/setup-python v2 composite
- peaceiris/actions-gh-pages v3 composite