A python package for music notation and generation
Project description
Musiclang
The Python framework to write, analyze, transform and predict music.
What is MusicLang ?
MusicLang which simply stands for "music language" is a Python framework implementing a new language for tonal music. This language allows composers to load, write, transform and predict symbolic music in a simple, condensed and high level manner. MusicLang internally uses a LLM (Large Language Model) to predict what could happen next in a musical score. This framework is well suited to :
- Generate musical ideas quickly.
- Predict what could happen next in an existing midi file
- Create an interpretable and information rich text representation of a midi file
How to install
MusicLang is available on Pypi :
pip install musiclang
Examples
- A hello world example to create a C-major chord in musiclang and save it to midi :
from musiclang.library import *
# Write A C major chord
score = (I % I.M)(piano=[s0, s2, s4])
# Store it to midi
score.to_midi('c_major.mid')
- Create, transform and harmonize a theme quickly :
from musiclang.library import *
# Create a cool melody (the beginning of happy birthday, independant of any harmonic context)
melody = s4.ed + s4.s + s5 + s4 + s0.o(1) + s6.h
# Create a simple accompaniment with a cello and a oboe
acc_melody = r + s0.o(-1).q * 3 + s0.o(-1).h
accomp = {'cello__0': acc_melody, 'oboe__0': acc_melody.o(1)}
# Play it in F-major
score = (I % IV.M)(violin__0=melody, **accomp)
# Repeat the score a second time in F-minor and forte
score += (score % I.m).f
# Just to create an anachrusis at the first bar
score = (I % I.M)(violin__0=r.h) + score
# Transform a bit the accompaniment by applying counterpoint rules automatically
from musiclang.transform.library import create_counterpoint_on_score
score = create_counterpoint_on_score(score, fixed_parts=['violin__0'])
# Save it to musicxml
score.to_musicxml('happy_birthday.musicxml', signature=(3, 4), title='Happy birthday !')
# Et voilà !
- Predict a score using a deep learning model trained on musiclang language :
See MusicLang Predict for more information.
Contact us
If you want to help shape the future of open source music generation, please contact us
License
The MusicLang base language (this package) is licensed under the BSD 3-Clause License. The MusicLang predict package and its associated models is licensed under the GPL-3.0 License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for musiclang-0.20.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 110f59a7bba444b8d5e802dfdb64c93ea9d0a3b96cffdafc427b47f61a3e9f17 |
|
MD5 | 8fa4c1922217bca6631eb26e5c248ad8 |
|
BLAKE2b-256 | 21b5e3e27f39a7af3ff9e31e8728679a5eb94e1822f679a3511dd2a82f1f48f5 |