diff --git a/Examples/CompleteHir3.bmb b/Examples/CompleteHir3.bmb new file mode 100644 index 0000000..7acd904 --- /dev/null +++ b/Examples/CompleteHir3.bmb @@ -0,0 +1,23 @@ +{Sets some context information.} +set_scale 2 1 4 1 4 +set_root 60 +set_tempo 128 +set_sounds 108 107 + +{Defines 3 2-multi-patterns.} +multi_pattern mpat_1 1 1 0 0 2 2 1 1 ; -5 * * * 0 * * * +multi_pattern mpat_2 -1 * 0 * 1 * ; * 0 * * 0 * +multi_pattern mpat_3 0 * ; * 0 + +{Defines 4 colored 2-multi-patterns from the previous 2-multi-patterns.} +colorize cpat_1 mpat_1 c1 c2 c1 +colorize cpat_2 mpat_1 c1 c1 c2 +colorize cpat_3 mpat_2 c1 c1 c2 +colorize cpat_4 mpat_3 c1 c1 + +{Creates a new 2-multi-pattern mpat_4 obtained by using the partial random generation + algorithm with k := 32, c1 as initial color, and cpat_1, cpat_2, cpat_3, and cpat_4 as + rules.} +generate mpat_4 partial 32 c1 cpat_1 cpat_2 cpat_3 cpat_4 +play mpat_4 + diff --git a/Examples/Sounds.bmb b/Examples/Sounds.bmb index 112b749..b741cb7 100644 --- a/Examples/Sounds.bmb +++ b/Examples/Sounds.bmb @@ -1,4 +1,4 @@ -{ By default, the MIDI sound of all voices is the "Acoustic Grand Piano" of code 0.} +{By default, the MIDI sound of all voices is the "Acoustic Grand Piano" of code 0.} multi_pattern p1 1 -1 0 * * 7 ; 3 * 2 * 0 0 play p1 diff --git a/Sources/Program.ml b/Sources/Program.ml index 5fe9e4c..a63966a 100644 --- a/Sources/Program.ml +++ b/Sources/Program.ml @@ -255,6 +255,8 @@ let execute_instruction instr st = |MultiPattern (name, mpat) -> begin if not (is_name name) then raise (ExecutionError "Bad multi-pattern name."); + if not (MultiPattern.is_multi_pattern mpat) then + raise (ExecutionError "Bad multi-pattern."); let st' = add_multi_pattern st name mpat in Printf.printf "%s Multi-pattern added." output_mark; print_newline ();