专栏名称: GitHubStore
分享有意思的开源项目
目录
相关文章推荐
艾邦高分子  ·  【邀请函】2025可持续环保材料论坛(5月2 ... ·  18 小时前  
高分子科学前沿  ·  普渡大学窦乐添最新Nature大子刊:全碳主 ... ·  昨天  
高分子科技  ·  华中师大曹郁教授团队 Polym. ... ·  4 天前  
高分子科技  ·  国科大杨晗课题组诚聘博士后、副研究员 - ... ·  4 天前  
51好读  ›  专栏  ›  GitHubStore

Musiclang:用于编写、分析、转换和预测音乐

GitHubStore  · 公众号  ·  · 2024-03-17 08:44

正文

项目简介


MusicLang 简称为“音乐语言”,是一个 Python 框架,实现了一种用于音调音乐的新语言。这种语言允许作曲家以简单、浓缩和高级的方式加载、编写、转换和预测象征性音乐。

MusicLang 在内部使用LLM(大型语言模型)来预测乐谱中接下来会发生什么。/!\ 请注意:我们在一个名为 musiclang_predict 的新包中将 AI 与语言本身解耦。如果您想使用 musiclang 的 AI 功能,请安装musiclang_predict包。

这个框架非常适合:

  • 快速产生音乐创意。

  • 做象征性的音乐预测或修复。

  • 创建 MIDI 文件的可解释的富文本表示形式


如何安装

MusicLang 可在 Pypi 上找到:

pip install musiclang


例子

  1. 一个在 musiclang 中创建 C 大调和弦并将其保存到 midi 的 hello world 示例:

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 midiscore.to_midi('c_major.mid')


  1. 快速创建、转换和协调主题:

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 oboeacc_melody = r + s0.o(-1).q * 3 + s0.o(-1).haccomp = {'cello__0': acc_melody, 'oboe__0': acc_melody.o(1)}
# Play it in F-majorscore = (I % IV.M)(violin__0=melody, **accomp)
# Repeat the score a second time in F-minor and fortescore += (score % I.m).f
# Just to create an anachrusis at the first barscore = (I % I.M)(violin__0=r.h) + score
# Transform a bit the accompaniment by applying counterpoint rules automaticallyscore = score.get_counterpoint(fixed_parts=['violin__0'])
# Save it to musicxmlscore.to_musicxml('happy_birthday.musicxml', signature=(3, 4), title='Happy birthday !')
# Et voilà !

  1. 使用在 musiclang 语言上训练的深度学习模型预测乐谱:




项目链接

http://github.com/MusicLang/musiclang







请到「今天看啥」查看全文