Coder Social home page Coder Social logo

musiclang's Introduction

Musiclang

MusicLang logo

Documentation Status

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. /!\ Please note that : we decoupled AI from the language itself in a new package called musiclang_predict. If you want to use AI capabilities of musiclang please install musiclang_predict package.

This framework is well suited to :

  • Generate musical ideas quickly.
  • Do symbolic music prediction or inpainting.
  • Create an interpretable and rich text representation of a midi file

Read our documentation.

How to install

MusicLang is available on Pypi :

pip install musiclang

Examples

  1. 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 (First degree of C major scale)
score = (I % I.M)(piano=[s0, s2, s4])

# Store it to midi
score.to_midi('c_major.mid')
  1. 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
score = score.get_counterpoint(fixed_parts=['violin__0'])

# Save it to musicxml
score.to_musicxml('happy_birthday.musicxml', signature=(3, 4), title='Happy birthday !')

# Et voilà !

Happy birthday score

  1. 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 / language modeling, 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.

musiclang's People

Contributors

floriangardin avatar datajms avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.