-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmdg22midRndN+svg.sh
executable file
·62 lines (58 loc) · 2.39 KB
/
mdg22midRndN+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
62
#!/bin/bash
#===================================================================================
#
# FILE: mdg22midRndN+svg.sh
#
# USAGE: mdg22midRndN+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 mdg22mid+svg.sh. ***
#
# DESCRIPTION: Used for generating <num> ABC, MIDI, and SVG files, each a Musical
# Dice Game (MDG) double counterpoint of six measures based on C.P.E. Bach's
# Counterpoint ("Einfall")
#
# AUTHOR: J.L.A. Uro (justineuro@gmail.com)
# VERSION: 1.0.5
# LICENSE: Creative Commons Attribution 4.0 International License (CC-BY)
# CREATED: 2021/02/21 17:28:40
# REVISION: 2024/07/12 08:53:47
#==================================================================================
#----------------------------------------------------------------------------------
# define the function genS() that randomly chooses an integer from 1 to 9, inclusive
#----------------------------------------------------------------------------------
genS() { # RANDOM randomly generates an integer in from 0 to 32768; rem in {0..8}
rnd=32769
until [ $rnd -lt 32769 ]
do
rnd=$[RANDOM]
if [ $rnd -lt 32769 ]; then echo $[rnd%9+1]; fi
done
}
#----------------------------------------------------------------------------------
# declare the variables "diceS" as an array
# diceS - array containing the 12 outcomes from input line
#----------------------------------------------------------------------------------
declare -a diceS
#----------------------------------------------------------------------------------
# generate the <num> random minuets
#----------------------------------------------------------------------------------
i=1
while [ $i -le $1 ]; do
#----------------------------------------------------------------------------------
# generate the random 6x2-sequence of outcomes of the 12 throws of 9-sided die
#----------------------------------------------------------------------------------
for j in {0..11}; do
diceS[$j]=`genS`
done
#----------------------------------------------------------------------------------
# generate a minuet in ABC notation and corresponding MIDI for the current diceS
# using mdg22mid+svg.sh
#----------------------------------------------------------------------------------
echo ${diceS[*]}
./mdg22mid+svg.sh ${diceS[*]}
i=`expr $i + 1`
done
#
##
###