Skip to content

Commit

Permalink
Rewrite of examples, new option (length) and bugfixes
Browse files Browse the repository at this point in the history
- added compact option to switch the note length without a note/chord/rest
- bugfix: shift didn't work for compact syntax with options
- bugfix: added instrument definition check for compact commands
- rewrite of example songs using compact syntax
- #71
  • Loading branch information
truj committed May 5, 2022
1 parent 068690e commit f08b015
Show file tree
Hide file tree
Showing 19 changed files with 962 additions and 362 deletions.
125 changes: 50 additions & 75 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,31 +135,21 @@ In this Readme we just show some short examples to get an impression of the lang

## Example 1

This example only uses simple channel commands and lyrics:
This example uses only one channel and lyrics:

// use Piano in channel 0
INSTRUMENTS
0 ACOUSTIC_GRAND_PIANO Piano
END

0 c /8. v=95, l=Hap // v = velocity, 95 = forte
0 c /16 l=py_ // l = lyrics (syllable)
// Every line beginning with "0:" defines events in channel 0
0: (v=95) // (...=...) set an option to a value; v = velocity; 95 = forte
0: (l=Hap) c:8. // (l=...) defines a syllable. "c:8." = dotted eighth middle C
0: (l=py_) c:16 // _ = space; c:16 = sixteenth middle C

0 d /4 l=birth
0 c /4 l=day_ // '_' = space
0 f /4 l=to_

0 e /2 l=you\c\r // \c = comma, \r = new line
0 c /8. l=hap
0 c /16 l=py_

0 d /4 l=birth
0 c /4 l=day_
0 g /4 l=to_

0 f /2 l=you.\n // \n = new paragraph
0 c /8. l=Hap
0 c /16 l=py...
// More special characters in syllables: \c = comma, \r = new line, \n = new paragraph
0: (l=birth) d:4 (l=day_) c (l=to_) f (l=you\c\r) e:2 (l=Hap) c:8. (l=py_) c:16
0: (l=birth) d:4 (l=day_) c (l=to_) g (l=you.\n) f:2 (l=Hap) c:8. (l=py...) c:16

This results in a MIDI sequence like this:

Expand All @@ -181,30 +171,32 @@ This example uses nestable blocks and global commands:

{ q=2 // outer block to be repeated twice
{ q=3 // inner block to be repeated 3 times
1 d- /8 v=70 // channel 1: play D3 as an 8th note, using mezzo piano
0 d /8 v=70 // channel 0: play D4 and switch to mezzo piano
0 - /8 // play a rest
0 d /8
0 eb /8
0 d /8
0 eb /8
* // synchronize: bring all channels to the same time
// in channel 1: switch to mezzo piano (v=70) and play D3 as an 8th note
1: (v=70) d-:8
// in channel 0: switch to mezzo piano and play some notes and rests ("-" = rest)
0: (v=70) d:8 - d eb d eb
// synchronize: bring all channels to the same time
*
}
1 d- /4
1 f- /4
1 c- /4
0 d /8
0 - /8
0 d /8
0 eb /8
0 f /8
0 eb /8
1: d-:4 f- c-
0: d:8 - d eb f eb
}

This results in a MIDI sequence like this:

<img src="img/example-score.svg" title="Example Score">

Instead of the nested blocks we could have written this equivalent code:

0: (v=70) d:8 - d eb d eb d - d eb d eb d - d eb d eb d - d eb f eb
0: d:8 - d eb d eb d - d eb d eb d - d eb d eb d - d eb f eb
1: (v=70) d-:4 -:/2 d-:4 -:/2 d-:4 -:/2 d-:4 f- c-
1: d-:4 -:/2 d-:4 -:/2 d-:4 -:/2 d-:4 f- c-

## Example 3

This example uses a guitar picking pattern with several chords. It produces the beginning of "Dust in the wind":
Expand All @@ -222,15 +214,10 @@ This example uses a guitar picking pattern with several chords. It produces the
CHORD asus4 a-2 e- a- d
CHORD amin a-2 e- a- c

// define the picking pattern (Travis picking)
// Define the picking pattern (Travis picking)
// The numbers inside the pattern aren't channel numbers but note indices
PATTERN travis
0,3 /4 // the numbers inside the pattern
1 /8 // aren't channel numbers
2 /8 // but note indices
0 /8
3 /8
1 /8
2 /8
: 0,3:4 1:8 2 0 3 1 2
END

// play the chords using this pattern
Expand All @@ -249,55 +236,43 @@ This results in the following sequence:

## Example 4

This example uses functions. It produces the first beats of "Another one bites the Dust":
This example uses functions and percussion instruments.<br>
It produces the first beats of "Another one bites the Dust":

// Use bass in channel 5
// Drums are always in channel 9 (automatically)
INSTRUMENTS
5 E_BASS_FINGER Bass
5 E_BASS_FINGER Bass
END

// anacrusis
* time 1/8
5 a-2 /16 d=30%
5 g-2 /16
5: (d=30%) a-2:16 g-2 // d=30% --> staccato

// regular
// regular bars
* time 4/4
CALL drum-and-bass(firstBar)
CALL drum-and-bass() q=2
CALL drum-and-bass(bar=1)
CALL drum-and-bass(bar=2) q=2 // q=quantity, so the function will be called twice

FUNCTION drum-and-bass
CALL bassline($[0])
CALL drums
CALL drums
CALL drums
CALL drums
CALL bassline(${bar})
CALL drums q=4 // "drums()" is called 4 times without parameters
END

FUNCTION bassline
5 e-2 /4 q=3, d=30%
5 - /8.
5 e-2 /16
5 e-2 /8 q=2
5 g-2 /8
5 e-2 /16
5 a-2 /16
{ if $[0]
5 - /4+/8
5 a-2 /16
5 g-2 /16
}
{ else
5 - /2
}
5: e-2:4 e-2 e-2 -:8. e-2:16 e-2:8 e-2 g-2 e-2:16 a-2
{ if $[0] == 1
5: -:4+8 a-2:16 g-2
}
{ else
5: -:2
}
END

// p = percussion channel (channel 9)
// p = 9 = percussion channel
// hhc = hi-hat-closed, bd1 = base-drum-1, sd1 = snare-drum-1
FUNCTION drums
p hhc,bd1 /8 v=127
p hhc /8 v=80
p hhc,bd1,sd1 /8 v=127
p hhc /8 v=80
p: (v=127) hhc,bd1:8 (v=80) hhc (v=127) hhc,bd1,sd1 (v=80) hhc
END

The resulting sequence looks like this:
Expand Down
113 changes: 113 additions & 0 deletions examples/london_bridge-lowlevel.midica
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
// This example file provides the traditional song
// "London Bridge is Falling Down".
//
// This file assumes standard program configuration:
// - Note System: International: c, d, e, ... (lower case)
// - Half Tone Symbols: # / b (c#, cb, d#, db, ...)
// - Octave Naming: +n/-n
// - Syntax: Mixed Case Syntax

META
copyright (c) Mozilla Public License, v. 2.0, author: Jan Trukenmüller
title London Bridge is Falling Down
composer traditional
lyrics traditional
END

INSTRUMENTS
0 LEAD_SAWTOOTH Vocals
1 E_GUITAR_CLEAN Guitar
END

// global settings
* tempo 150
* time 4/4
* key d/maj

// initialize channel defaults
0 - - d=75%, v=100
1 - - d=100%, v=70

// execute the verses with different lyrics
CALL verse(Lon, don_, Bridge_, is_, fal, ling_, down)
CALL verse(Build_, it_, up_, with_, wood_, and_, clay)
CALL verse(Wood_, and_, clay_, will_, wash_, a, way)
CALL verse(Build_, it_, up_, with_, bricks_, and_, mortar)
CALL verse(Bricks_, and_, mor, tar_, will_, not_, stay)
CALL verse(Build_, it_, up_, with_, iron_, and_, steel)
CALL verse(Iron_, and_, steel_, will_, bend_, and_, bow)
CALL verse(Build_, it_, up_, with_, silver_, and_, gold)
CALL verse(Silver_, and_, gold_, will_be_, stolen_, a, way)
CALL verse(Set_, a_, man_, to_, watch_, all_, night)
CALL verse(Suppose_, the_, man_, should_, fall_, a, sleep)
CALL verse(Give_him_, a_, pipe_, to_, smoke_, all_, night)

FUNCTION verse
CALL vocals($[0], $[1], $[2], $[3], $[4], $[5], $[6])
CALL guitar
END

///////////////////////////
// vocals
///////////////////////////

FUNCTION vocals
CALL vocals_m1($[0], $[1], $[2], $[3]) // London bridge is
CALL vocals_m2($[4], $[5], $[6]\c\r) // falling down,
CALL vocals_m3($[4], $[5], $[6]\c_) // falling down,
CALL vocals_m2($[4], $[5], $[6].\r) // falling down.
CALL vocals_m1($[0], $[1], $[2], $[3]) // London bridge is
CALL vocals_m2($[4], $[5], $[6].\r) // falling down,
CALL vocals_m7_8() // My fair lady.
END
FUNCTION vocals_m1
0 a /4. l=$[0] // Lon-
0 b /8 l=$[1] // don
0 a /4 l=$[2] // bridge
0 g /4 l=$[3] // is
END
FUNCTION vocals_m2
0 f# /4 l=$[0] // fal-
0 g /4 l=$[1] // ling
0 a /2 l=$[2] // down
END
FUNCTION vocals_m3
0 e /4 l=$[0] // fal-
0 f# /4 l=$[1] // ling
0 g /2 l=$[2] // down
END
FUNCTION vocals_m7_8
0 e /2 l=My_
0 a /2 l=fair_
0 f# /4 l=La
0 d /2. l=dy.\n
END

///////////////////////////
// guitar
///////////////////////////

// define some guitar chords
CHORD amaj a-, e, a, c#+
CHORD dmaj d, a, d+, f#+

// define a picking pattern for both chords
PATTERN picking_pattern
0 /8
1 /8
2 /8
1 /8
3 /8
1 /8
2 /8
3 /8
END

FUNCTION guitar
// use the same pattern with both chords
1 dmaj picking_pattern q=2
1 amaj picking_pattern
1 dmaj picking_pattern q=3
1 amaj picking_pattern
1 dmaj picking_pattern
END
37 changes: 12 additions & 25 deletions examples/london_bridge.midica
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ END
* key d/maj

// initialize channel defaults
0 - - d=75%, v=100
1 - - d=100%, v=70
0: (d=75%) (v=100)
1: (d=100%) (v=70)

// execute the verses with different animals and sounds
// execute the verses with different lyrics
CALL verse(Lon, don_, Bridge_, is_, fal, ling_, down)
CALL verse(Build_, it_, up_, with_, wood_, and_, clay)
CALL verse(Wood_, and_, clay_, will_, wash_, a, way)
Expand Down Expand Up @@ -61,26 +61,20 @@ FUNCTION vocals
CALL vocals_m7_8() // My fair lady.
END
FUNCTION vocals_m1
0 a /4. l=$[0] // Lon-
0 b /8 l=$[1] // don
0 a /4 l=$[2] // bridge
0 g /4 l=$[3] // is
// Lon- don bridge is
0: (l=$[0]) a:4. (l=$[1]) b:8 (l=$[2]) a:4 (l=$[3]) g
END
FUNCTION vocals_m2
0 f# /4 l=$[0] // fal-
0 g /4 l=$[1] // ling
0 a /2 l=$[2] // down
// fal- ling down
0: (l=$[0]) f#:4 (l=$[1]) g (l=$[2]) a:2
END
FUNCTION vocals_m3
0 e /4 l=$[0] // fal-
0 f# /4 l=$[1] // ling
0 g /2 l=$[2] // down
// fal- ling down
0: (l=$[0]) e:4 (l=$[1]) f# (l=$[2]) g:2
END
FUNCTION vocals_m7_8
0 e /2 l=My_
0 a /2 l=fair_
0 f# /4 l=La
0 d /2. l=dy.\n
// My fair Lady
0: (l=My_) e:2 (l=fair_) a (l=La) f#:4 (l=dy.\n) d:2.
END

///////////////////////////
Expand All @@ -93,14 +87,7 @@ CHORD dmaj d, a, d+, f#+

// define a picking pattern for both chords
PATTERN picking_pattern
0 /8
1 /8
2 /8
1 /8
3 /8
1 /8
2 /8
3 /8
: 0:8 1 2 1 3 1 2 3
END

FUNCTION guitar
Expand Down
Loading

0 comments on commit f08b015

Please sign in to comment.