truj / midica

A Music programming language. Translates source code into MIDI. Includes a player. Supports MIDI-Karaoke. Includes a MIDI analyzer.
https://www.midica.org/
Mozilla Public License 2.0
111 stars 13 forks source link

add compact syntax #70

Closed truj closed 1 year ago

truj commented 3 years ago

In MidicaPL, add a simplified syntax to play several different notes with different lengths in one single line. It could look something like this: 0: c:/4 d e - c+2:/8 d+ e+ -:/2+/8 what is equivalent to:

0  c   /4
0  d   /4
0  e   /4
0  -   /4
0  c+2 /8
0  d+  /8
0  e+  /8
0  -   /2+/8

If the note length is omitted, the last used length of the channel is assumed.

truj commented 2 years ago

Also adding support for inline options and patterns in compact syntax.

Options in the form (name=value) e.g.: 0: (v=127) (d=50%) c:/4 (l=text) d e - c+2:/8 d+ e+ -:/2+/8

More options can be combined like this: (name1=value1,name2=value2) E.g.: (v=127,d=50%)

Patterns can be used instead of length strings, e.g. 0: c:4 d e,f,g:pat a b cmaj:pat (If the pattern pat and the chord cmaj have been defined) Or with parameters: 0: c:4 d e,f,g:pat(a,b) a b cmaj:pat(c,d) With a, b, c, d as arbitrary parameters consumed by the pattern pat.

Consequently the next step would be to enable compact syntax in pattern definitions as well. E.g. like this:

PATTERN pat
    : (d=50%) 0:/8 1:/8 (d=20%) 2:/4
END

Which would be equivalent to:

PATTERN pat
    0  /8   d=50%
    1  /8
    2  /4   d=20%
END
truj commented 2 years ago

Two more things missing until this can be merged into master: