-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmdg32midRndN-svg.sh
executable file
·61 lines (57 loc) · 2.35 KB
/
mdg32midRndN-svg.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
#===================================================================================
#
# FILE: mdg32midRndN-svg.sh
#
# USAGE: mdg32midRndN-svg.sh <num>
#
# where <num> is the number of random MDG minuets to be generated, e.g., 50.
# *** NOTE: This script has to be in the same directory as mdg32mid+svg.sh. ***
#
# DESCRIPTION: Used for generating <num> ABC files, each a Musical Dice Game (MDG)
# minuet based on the rules given in Joseph Haydn's "Der alleizet fertige"
#
# AUTHOR: J.L.A. Uro (justineuro@gmail.com)
# VERSION: 1.0.3
# LICENSE: Creative Commons Attribution 4.0 International License (CC-BY)
# CREATED: 2024/06/24 19:48:24
# REVISION: 2024/07/09 14:02:15
#==================================================================================
#----------------------------------------------------------------------------------
# define the function genS() that randomly chooses an integer from 1 to 6, inclusive
#----------------------------------------------------------------------------------
genS() { # RANDOM randomly generates an integer from 0 to 32767
rnd=32764
until [ $rnd -lt 32764 ]
do
rnd=$[RANDOM]
if [ $rnd -lt 32764 ]; then echo $[rnd%6+1]; fi
done
}
#----------------------------------------------------------------------------------
# declare the variables "diceS" as an array
# diceS - array containing the 16 outcomes from input line
#----------------------------------------------------------------------------------
declare -a diceS
#----------------------------------------------------------------------------------
# generate the <num> random minuets
#----------------------------------------------------------------------------------
i=1
while [ $i -le $1 ]; do
#----------------------------------------------------------------------------------
# generate the random 32-sequence of outcomes of the 32 throws of a dice for
# the minuet and trio
#----------------------------------------------------------------------------------
for j in {0..31}; do
diceS[$j]=`genS`
done
#----------------------------------------------------------------------------------
# generate a waltz in ABC notation and corresponding MIDI and svg for the current
# diceS using mdg42mid+svg.sh
#----------------------------------------------------------------------------------
./mdg32mid+svg.sh ${diceS[*]}
i=`expr $i + 1`
done
#
##
####