Code Monkey home page Code Monkey logo

sakuramml-rust's Introduction

sakuramml-rust

"sakruamml" is a MML/ABC to MIDI compier.

This compiler that converts the text of "cde" into MIDI files. It is a tool that allows you to easily create music. It is made with Rust and works on multiple platforms (macOS/Windows/Linux/WebAssembly).

Repository

Web Version (WASM)

Install

Binary - command line

Compile

Please install Rust compier.

$ git clone https://github.com/kujirahand/sakuramml-rust.git
$ cd sakuramml-rust
$ cargo build --release

target/release/sakuramml is compiler.

Sakura MML

Please make text file "test.mml".  Execute the following command to generate a MIDI file.

$ sakuramml test.mml

Basic

o4 cdefgab>c<bagfedc
TR=1 CH=1 l1 ceg^

Harmony

l4 `ceg` `dfa`8 `egb`8 `ceg`

Set TIME Pointer

// top
TIME(1:1:0) cdef
TIME(1:1:0) efga

// 2mes
TIME(2:1:0) cdef

SUB{...} command let time pointer back.

SUB{ cdef  c }
SUB{ efga  e }
     rrrr  g

Rhythm macro

In the rhythm macro, one character is treated as one instruction regardless of uppercase or lowercase letters. Rhythm macro definitions are described as "$(char){definition}".

// define macro
$b{n36,}
$h{n42,}
$o{n46,}
// new macro
$S{n37,}
CH(10)
// sample
Rhythm{
 [4 l8
   brSr bbsr r-1
   hoho hoho
 ]
}

How to specify tuplets

The tuplets are written as "Div{...}", but "Div" can be omitted and written as "{ceg}".

l4 Div{cde} f Div{gab} >c<
l4 {cde} f {gab} >c<
l4 {cde}c {gfe}d {c^d} e {d^e} f

The tuplets can nest.

l1 { c d {efe} d } c

Velocity

"(" decreases the velocity by 8, and ")" increases the velocity by 8.

v127 c ( c ( c (( c )) c ) c ) c  

Harmony

`ceg` `dfa` `egb` `ceg`

Reservation notation

  • v.onTime(low, high, len, ...) / 省略形 v.T(low,high,len,...)
  • v.onNote(v1, v2, v3, ...) / 省略形 v.N(v1,v2,v3,...)
  • t.onNote(v1, v2, v3, ...) / 省略形 t.N(v1,v2,v3,...)
  • (ControllChange または PB または p).onTime(low, high, len, ...)
v.onTime(0,127,!1)l8cccccccc
BR(2) PB.onTime(-8192,0,!4) l4c PB(0) efg^

Macro

It can define Macro.

// define Macro
STR P1 = {cdefg}
#P1 = {cdefg}
// expand Macro
P1
#P1

The macro can replace with arguments. It replaces #?1 #?2 #?3 ...

// define macro
#Unison = { Key=#?2 Sub{ #?1 } Key=0 #?1 }
// expand macro with arguments 
#Unison{cde},7

Script

It can use IF/FOR/WHILE/FUNCTION script.

// IF 
INT A = 3
INT B = 5
IF (A == B) { PRINT({A == B}) } ELSE { PRINT({A != B}) }

// FOR
FOR (INT N=1; N < 5; N++) {
  PRINT(N)
}

memo

sakuramml-rust's People

Contributors

kujirahand avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sakuramml-rust's Issues

Rhythmマクロで(Sub)の扱いがおかしい

以下のようなコードで、Subの扱いがおかしくなっている。要調査。

Rythm{
  l8
  v80 (Sub){ [4 hrhr  rrhr ] }
  v110(Sub){ [4 rhrh  hhrh ] }
  v90 (Sub){ [4 rrrr  srrr ] }
  v110       [4 brbr :brbr ] brbb
}

gs.hの内容がない GS_RHYTHMがコンパイルエラー

/** リズムパートに関する命令
** GS_RHYTHM(val)
◇リズムパートの変更をします。
	val =
		00:楽器          01:ドラムパート1      02:ドラムパート2
*/
Function GS_RHYTHM(_D) {
 Int _TCH = Channel; //private
 Int _CH; //private
 If(_TCH==10) {
  _CH = $00;
 } Else {
  If(_TCH<10) { _CH = _TCH; } Else { _CH = _TCH -1; }
 }
 _CH = $10 + _CH;
 SysEx=$F0,$41,(DeviceNumber),$42,$12,{$40,(_CH),$15,(_D)},$F7;
}

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.