forked from zhanrnl/PyMusAnim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpymusanim.sh
executable file
·34 lines (31 loc) · 1.14 KB
/
pymusanim.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
#!/bin/bash
# given the same parameters as PyMusAnimLauncher, runs the whole process of creating a video
function checktime() { now=`date +%s`;}
function printtime(){
checktime
timeelapsed=$(($now-$allStart))
echo "Total time: $(($timeelapsed/60)) minutes ($timeelapsed seconds)"
}
function animate(){
echo python3 MusAnimLauncher.py $* #TODO
python3 MusAnimLauncher.py $* #first try
mkdir $2
cp $1 $2
if ! [ -e "$2/frame00000.png" ]; then
if ! [ $musescore ]; then exit 1; fi #first try failed
echo "Converting MIDI..."
converted="$2/musescore.mid"
mscore "$1" -o $converted #convert mid->mid 2> /dev/null
echo python3 MusAnimLauncher.py $converted $2 $3 #TODO
python3 MusAnimLauncher.py $converted $2 $3 #second try
if ! [ -e "$2/frame00000.png" ]; then exit 1; fi #second try failed
fi
}
if [ $# == 0 ]; then echo "Usage: ./pymusanim.sh file.mid outputdirectory/ [--dynamic]"; exit 2; fi
if [ -e $2 ]; then echo 'Output folder already exists...'; exit 3; fi
type mscore 2&>/dev/null;musescore=$?
checktime;allStart=$now
animate $*
printtime
./render.sh $2
printtime