An open API service indexing awesome lists of open source software.

https://github.com/genius-society/mathematica_music_pack

This macro package simplifies the arrangement input structure in the Mathematica platform sound module, reducing the amount of code keyed in by the composer and removing a lot of repetitive code structure and functional flaws in the original synthesis on special sounds.|此宏包可简化Mathematica平台声音模块中的编曲输入结构,降低作曲者键入代码量,去除原有合成中大量重复的代码结构和特殊音效上的功能缺陷。
https://github.com/genius-society/mathematica_music_pack

macro mathematica midi music-composition

Last synced: about 1 month ago
JSON representation

This macro package simplifies the arrangement input structure in the Mathematica platform sound module, reducing the amount of code keyed in by the composer and removing a lot of repetitive code structure and functional flaws in the original synthesis on special sounds.|此宏包可简化Mathematica平台声音模块中的编曲输入结构,降低作曲者键入代码量,去除原有合成中大量重复的代码结构和特殊音效上的功能缺陷。

Awesome Lists containing this project

README

          

# Mathematica Music Package 编曲简化宏包
[![license](https://img.shields.io/badge/license-CC--BY--NC--SA-74c853.svg)](https://github.com/Genius-Society/mathematica_music_pack/blob/main/LICENSE)
[![cloudflare](https://img.shields.io/badge/cloudflare-mathemusica-f6821f.svg)](https://mathemusica.pages.dev)
[![bili](https://img.shields.io/badge/bilibili-BV14krgYJEJU-fc8bab.svg)](https://www.bilibili.com/video/BV14krgYJEJU)

A macro package for simplifying composition on Mathematica

一款用于简化 Mathematica 编曲的宏包

## Code download 源码下载
```bash
git clone git@github.com:Genius-Society/mathematica_music_pack.git
cd mathematica_music_pack
```

## User manual 用户手册
We use vectors and numbers to replace complicated SoundNote[] functions. A complete song has many sections, its format is as follow:

我们使用向量和数字来代替复杂的 SoundNote[] 系列函数。 经简化后的一首完整歌曲格式如下:
```txt
track1 = {
{params of section 1}, (*{片段1参数}*)
{notes of section 1}, (*{片段1乐谱}*)

{params of section 2}, (*{片段2参数}*)
{notes of section 2}, (*{片段2乐谱}*)

...

{params of section m}, (*{片段m参数}*)
{notes of section m} (*{片段m乐谱}*)
};

track2 = {
{params of section 1}, (*{片段1参数}*)
{notes of section 1}, (*{片段1乐谱}*)

{params of section 2}, (*{片段2参数}*)
{notes of section 2}, (*{片段2乐谱}*)

...

{params of section n}, (*{片段n参数}*)
{notes of section n} (*{片段n乐谱}*)
};

...

player[track1, soundfont1, track2, soundfont2, ...]
(*player[track1, 音色1, track2, 音色2, ...]*)
```

One section consists of an info part and a note part, the info part includes 4 required params(tonality, central note, transposition, tempo) and one optional param(volume number or volume change vector); While the note part contains melodies and chords. The info part follows below format rules:

一个片段由参数域和乐谱域组成,参数域包含4个必要参数(音调、中心音、移调、速度)和一个可选参数(音量 或 音量变化);其中参数域遵循以下规则:


Table 1: Param part format (表 1: 参数域格式)

|

Format 格式
| Remark 符号 |
| :--------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| *{m, c, s, t}* | *m* is 0(major) or 1(minor) 为大小调(0大调,1小调);
*c* is central note integer 为中心音 ([0, 11]);
*s* is transposing(The whole piece moves up s semitones) 为移调(片段整体移动s个半音);
*t* is tempo(the number = a quarter note) 为速度(即乐谱左上角标记的一个四分音符所等于的数字); |
| *{m, c, s, t, v}* | *v* is volume 为音量 ([0, 1]); |
| *{m, c, s, t, {vs, vt}}* | Volume fades from *vs* to *vt* (音量从 *vs* 渐变到 *vt*) |

The central note list is as follow:

如下为中心音表:


Table 2: Central note list (表 2: 中心音表)

| C | C#/Db | D | Eb/D# | E | F | F#/Gb | G | Ab/G# | A | Bb/A# | B |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |

The note part has melodies and chords, which consists of different kinds of notes:

乐谱域由不同种类的音符组成:


Table 3: Input formats of notes (表 3: 音符的输入格式)

| Effect 音效 | Format 格式 | Remark 符号 |
| :------------ | :-------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------- |
| Rest 休止符 | *{l}* | *l* is duration (为时值); |
| Tone 音符 | *{n, l}* | *n* is note value (为音高); |
| Chord 和弦 | *{{n1, n2, ...}, l}* | *nk* are chord note values (为和弦上各音符音高); |
| Staccato 跳音 | *{n, {l1, l2}}* | *l1* is real duration (为时值), *l2* is duration ratio (为缩短后时值占真实时值比率); |
| Vibrato 颤音 | *{{n1, n2}, l1, tn}* | *tn* is trill number (为抖动次数); |
| Arpeggio 波音 | *{{n1, n2, ...}, l1, l2}* | *l2* is duration ratio (为琶音变化时值占真总时值比); |
| Tenuto 延音 | *{bottom note, top notes}* | Bottom note can be a tone or a chord, top notes consist of any above type. 背景音可以是一个音符或一个和弦, 主题旋律可以由上述任何类型组成 |

With these rules, we can get a concise format of notes.

根据以上规则,给出以下音效示例:


Table 4: Sound effect demos (表 4: 音效示例)


For notes in the note part, 12-note scheme is unfriendly to us, it can be transferred into 7-note scheme once the tonality is fixed:

对于乐谱域的音符,12音模式使用起来并不方便,一旦调性固定,可将其转为7音模式:


Table 5: The 12-note scheme(left) & 7-note scheme(right) 表 5: (左)12音模式 与 (右)7音模式


Please refer to the demo code _`Demo_BWV-1079.nb`_ or visit our [song library](https://mathemusica.pages.dev) for more details; Before compiling songs, please run the macro package first.

可参考示例代码 _`Demo_BWV-1079.nb`_ 或浏览 我的Mathematica音乐库 来弄清具体用法; 生成乐谱之前请先运行 _`mathematica_music_pack.nb`_

Besides, the _`e-piano.nb`_ is a piano keyboard UI, you can play it as a virtual piano on Mathematica.

另外,_`e-piano.nb`_ 是一个编写于 Mathematica 上的钢琴键盘,可作为虚拟钢琴来弹奏。