In this assignment I was supposed to produce a melody using a context free grammar. Based in the grammar and using a generator of random numbers( to choose the rules), I did this directly derivations :
Note : The number before the string is the rule number.
Melody => (1) bar bar bar bar bar bar bar bar
=> (2)
bar1 bar bar bar bar bar bar bar
=>
(6) (1 p1 d1) bar bar bar bar bar bar bar
=>
(10) (1 pitch d1) bar bar bar bar bar bar bar
=>
(23) (1 c d1) bar bar bar bar bar bar bar
=>
(14) (1 c w) bar bar bar bar bar bar bar
=>
(3) (1 c w) bar2 bar bar bar bar bar bar
=>
(7) (1 c w) (2 p2 d2) bar bar bar bar bar bar
=>
(11) (1 c w) (2 pitch pitch d2) bar bar bar bar bar bar
=>
(24) (1 c w) (2 d pitch d2) bar bar bar bar bar bar
=>
(23) (1 c w) (2 d d d2) bar bar bar bar bar bar
=>
(15) (1 c w) (2 d d h h) bar bar bar bar bar bar
=> (4) (1 c w) (2 d d h h) bar3
bar bar bar bar
=> (8) (1 c w) (2 d d h h) (3
p3 d3) bar bar bar bar
=> (12) (1 c w) (2 d d
h h) (3 pitch pitch pitch d3 ) bar bar bar bar
=> (26) (1 c w) (2 d d h h) (3 f
pitch pitch d3) bar bar bar bar
=> (25) (1 c w) (2 d d h h)
(3 f e pitch d3) bar bar bar bar
=> (28) (1 c w) (2 d d h h) (
3 f e a d3) bar bar bar bar
=> (16) (1 c w) (2 d d h h) (
3 f e a h q q) bar bar bar bar
=> (3) (1 c w) (2 d d h h) ( 3 f e a h q q) bar2 bar bar bar
=> (7) (1 c w) (2 d d h h) ( 3 f e a h q q) (2 p2 d2) bar bar bar
=> (11) (1 c w) (2 d d h h) ( 3 f e a h q q) (2 pitch pitch d2) bar bar bar
=> (29) (1 c w) (2 d d h h) ( 3 f e a h q q) (2 b pitch d2) bar bar bar
=> (28) (1 c w) (2 d d h h) ( 3 f e a h q q) (2 b a d2) bar bar bar
=> (15) (1 c w) (2 d d h h) (
3 f e a a h q q) (2 b a h h) bar bar bar
=> (3) (1 c w) (2 d d h h) (
3 f e a a h q q) (2 b a h h) bar2 bar
bar
=> (7) (1 c w) (2 d d h h) (
3 f e a a h q q) (2 b a h h) (2 p2 d2 )
bar bar
=> (11) (1 c w) (2 d d h h) (
3 f e a a h q q) (2 b a h h) (2 pitch
pitch d2 )bar bar
=> (23) (1 c w) (2 d d h h) (
3 f e a a h q q) (2 b a h h) (2 c pitch
d2 )bar bar
=> (27) (1 c w) (2 d d h h) (
3 f e a a h q q) (2 b a h h) (2 c g d2 )bar
bar
=> (15) (1 c w) (2 d d h h) (
3 f e a a h q q) (2 b a h h) (2 c g h h )bar bar
=> (2) (1 c w) (2 d d h h) (
3 f e a a h q q) (2 b a h h) (2 c g h h )bar1 bar
=> (6) (1 c w) (2 d d h h) (
3 f e a a h q q) (2 b a h h) (2 c g h h ) (1 p1 d1) bar
=> (10) (1 c w) (2 d d h h) (
3 f e a a h q q) (2 b a h h) (2 c g h h ) (1 pitch d1) bar bar
=> (25) (1 c w) (2 d d h h) (
3 f e a a h q q) (2 b a h h) (2 c g h h ) (1 e d1) bar
=> (14) (1 c w) (2 d d h h) (
3 f e a a h q q) (2 b a h h) (2 c g h h ) (1 e w) bar
=> (3) (1 c w) (2 d d h h) (
3 f e a a h q q) (2 b a h h) (2 c g h h ) (1 e w) bar2
=> (7) (1 c w) (2 d d h h) (
3 f e a a h q q) (2 b a h h) (2 c g h h ) (1 e w) (2 p2 d2)
=> (11) (1 c w) (2 d d h h) (
3 f e a a h q q) (2 b a h h) (2 c g h h ) (1 e w)(2 pitch pitch d2)
=> (24) (1 c w) (2 d d h h) (
3 f e a a h q q) (2 b a h h) (2 c g h h ) (1 e w) (2 d pitch d2)
=> (28) (1 c w) (2 d d h h) (
3 f e a a h q q) (2 b a h h) (2 c g h h ) (1 e w) (2 d a d2)
=> (15) (1 c w) (2 d d h h) (
3 f e a a h q q) (2 b a h h) (2 c g h h ) (1 e w) (2 d a h h)
After that, I transformed the last string to a JFugue string :
Last String: (1 c w) (2 d d h h) ( 3 f e a a h q q) (2 b a h h) (2 c g h h ) (1 e w) (2 d a h h)
Result of the combination: cw
dh dh fh eq aq bh ah ch gh ew dh ah
Finally, putting this string in the SimplePlayer it produced this song file: