midi and partition files generation
This commit is contained in:
parent
557ed4fe01
commit
d66b29b400
|
@ -4,7 +4,6 @@ Q: "English Waltz " 87
|
|||
C: Traditional
|
||||
M: 3/4 % time signature
|
||||
L: 1/4 % default length
|
||||
%%staves {RH LH}
|
||||
V: 1 clef=treble
|
||||
%%MIDI channel 4
|
||||
%%MIDI program 1 4
|
||||
|
|
41
Music/Makefile
Normal file
41
Music/Makefile
Normal file
|
@ -0,0 +1,41 @@
|
|||
dirs:= BeginnerCourse BoosterMusic
|
||||
output:= PianoBoosterMusic
|
||||
ABCs:=$(foreach dir, $(dirs), $(wildcard $(dir)/*.abc))
|
||||
MMAs:=$(filter-out $(foreach dir, $(dirs), $(wildcard $(dir)/*Lib.mma)),$(foreach dir, $(dirs), $(wildcard $(dir)/*.mma)))
|
||||
MIDs:=$(foreach mma, $(MMAs:.mma=.mid), $(output)/$(mma))
|
||||
SOLs:=$(foreach abc, $(ABCs:.abc=.solo.mid), $(abc))
|
||||
SVGs:=$(foreach abc, $(ABCs:.abc=001.svg), $(output)/$(abc))
|
||||
MDs=:$(ABCs:.abc=_en.md)
|
||||
|
||||
all: $(output)/README.html
|
||||
|
||||
%.html: %.md
|
||||
markdown $< > $@
|
||||
|
||||
$(output)/README.md: $(SVGs) $(MIDs)
|
||||
cat music.md.start > $@
|
||||
sh -c '$(foreach mma, $(MMAs), \
|
||||
echo "## $(basename $(notdir $(mma)))"; \
|
||||
echo "![score]($(basename $(mma))001.svg)"; \
|
||||
echo ""; \
|
||||
[ -f "$(basename $(mma))_en.md" ] && cat "$(basename $(mma))_en.md" || true ; \
|
||||
echo "[midi file]($(basename $(mma)).mid)" ; \
|
||||
)' >> "$@"
|
||||
cat music.md.end >> $@
|
||||
|
||||
$(output)/%001.svg: %.abc
|
||||
$(foreach dir, $(dirs), mkdir -p $(output)/$(dir))
|
||||
abcm2ps -g -s 0.9 -c "$<" -O "$(output)/$(basename $<).svg"
|
||||
|
||||
%.solo.mid: %.abc
|
||||
abc2midi "$<" -o "$@" -RS
|
||||
|
||||
$(output)/%.mid: %.mma $(SOLs)
|
||||
$(foreach dir, $(dirs), mkdir -p $(output)/$(dir))
|
||||
sh -c 'cd $(dir $<); mma "$(notdir $<)" -o -f "../$@"'
|
||||
|
||||
clean:
|
||||
rm -f $(SOLs) $(wildcard $(output)/*/*.svg)
|
||||
|
||||
cleanall: clean
|
||||
rm -fr $(output)
|
|
@ -1,15 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
SONGS="
|
||||
SkipToMyLoo
|
||||
Greensleeves
|
||||
ScarboroughFair
|
||||
FrereJacques
|
||||
AmazingGrace
|
||||
"
|
||||
|
||||
# bash for loop
|
||||
for s in $SONGS; do
|
||||
./makemusic2 $s
|
||||
#./makescore $s
|
||||
done
|
232
Music/makemusic
232
Music/makemusic
|
@ -1,232 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
#mmaExec = "/home/louis/active/src/mma/mma-current/mma.py"
|
||||
mmaExec = "/home/louis/active/src/mma-bin-1.5d/mma.py"
|
||||
midiInfo = "InfoPages"
|
||||
|
||||
class songDetails:
|
||||
|
||||
def copyTranslations(self, outputDir):
|
||||
infoSrcDir = self.directory + "/" + midiInfo ;
|
||||
infoOutputDir = outputDir + '/' + self.directory + '/' + midiInfo
|
||||
|
||||
|
||||
if os.path.isdir(infoSrcDir):
|
||||
files = os.listdir(infoSrcDir)
|
||||
for f in files:
|
||||
|
||||
if (f.find(self.name)==0):
|
||||
if not os.path.isdir(infoOutputDir):
|
||||
os.mkdir(infoOutputDir)
|
||||
os.system("cp \"{0}/{1}\" \"{2}/{3:02}-{1}\"".format(infoSrcDir, f, infoOutputDir, self.index))
|
||||
|
||||
def getOutputName(self):
|
||||
return "/%02d-%s"%(self.index, self.name)
|
||||
|
||||
|
||||
def createMusic(self, outputDir, webDir, tempDir): # create music
|
||||
|
||||
if not os.path.isdir(outputDir + '/' + self.directory):
|
||||
os.mkdir(outputDir + '/' + self.directory)
|
||||
if not os.path.isdir(webDir + '/' + self.directory):
|
||||
os.mkdir(webDir + '/' + self.directory)
|
||||
if not os.path.isdir(tempDir + '/' + self.directory):
|
||||
os.mkdir(tempDir + '/' + self.directory)
|
||||
|
||||
outputName = outputDir + '/' + self.directory + self.getOutputName()
|
||||
webName = webDir + '/' + self.directory + "/" + self.name
|
||||
tempName = tempDir + '/' + self.directory + self.getOutputName()
|
||||
|
||||
srcName = self.directory + "/" + self.name
|
||||
|
||||
abcMidiName = srcName
|
||||
if os.path.isfile(abcMidiName + "Mid.abc"):
|
||||
abcMidiName += "Mid"
|
||||
print "abcName " + srcName
|
||||
|
||||
# http://moinejf.free.fr/ (abcplus.sourceforge.net)
|
||||
cmd = "abc2midi \"{0}.abc\" -o \"{1}.solo.mid\" -RS".format(abcMidiName, abcMidiName)
|
||||
print cmd
|
||||
if os.system(cmd) != 0:
|
||||
return False
|
||||
|
||||
# http://mellowood.ca/mma/
|
||||
cmd = "cd \"{0}\";{1} \"{2}.mma\" -f \"../{3}.mid\"".format( self.directory, mmaExec, self.name, outputName )
|
||||
print cmd
|
||||
if os.system(cmd) != 0:
|
||||
return False
|
||||
|
||||
psName = srcName
|
||||
|
||||
if os.path.isfile(psName + "Ps.abc"):
|
||||
psName += "Ps"
|
||||
print "psName " + psName
|
||||
|
||||
# http://abc.sourceforge.net/ (abcplus.sourceforge.net)
|
||||
cmd = "abcm2ps -s 0.8 -c \"{0}.abc\" -O \"{1}.ps\"" .format( psName, tempName )
|
||||
print cmd
|
||||
if os.system(cmd) != 0:
|
||||
return False
|
||||
|
||||
# http://www.ghostscript.com/ - ps2pdf is part of ghostscript
|
||||
cmd = "ps2pdf \"{0}.ps\" \"{1}.pdf\"".format( tempName, outputName )
|
||||
print cmd
|
||||
if os.system(cmd) != 0:
|
||||
return False
|
||||
os.remove("{0}.ps".format(tempName))
|
||||
|
||||
|
||||
cmd = "abcm2ps -E -s 1.0 -c \"{0}.abc\" -O \"{1}.ps\"".format( psName, tempName)
|
||||
print cmd
|
||||
if os.system(cmd) != 0:
|
||||
return False
|
||||
|
||||
|
||||
|
||||
|
||||
# from imagemagick
|
||||
cmd = "convert -density 90x90 -alpha off \"{0}001.eps\" \"{1}.png\"" .format(tempName, webName)
|
||||
print cmd
|
||||
if os.system(cmd) != 0:
|
||||
return False
|
||||
|
||||
self.copyTranslations(outputDir)
|
||||
|
||||
os.remove("{0}001.eps".format(tempName ))
|
||||
|
||||
os.system("cp \"{0}.abc\" \"{1}.abc\"".format(abcMidiName, webName))
|
||||
os.system("cp \"{0}.mma\" \"{1}.mma\"".format(srcName, webName))
|
||||
os.system("cp \"{0}.pdf\" \"{1}.pdf\"".format(outputName, webName))
|
||||
os.system("cp \"{0}.mid\" \"{1}.mid\"".format(outputName, webName))
|
||||
pbCfg = self.directory + "/" + "pb.cfg"
|
||||
|
||||
if os.path.isfile(pbCfg):
|
||||
os.remove(pbCfg)
|
||||
|
||||
|
||||
|
||||
f = open( webDir + "/" + self.directory + ".html", 'a')
|
||||
if f == 0:
|
||||
return False
|
||||
webName = self.directory + "/" + self.name
|
||||
|
||||
str = """
|
||||
<p></p>
|
||||
<p class="image">
|
||||
<img hspace="10" src="{1}.png" alt="Piano Music - {0}">
|
||||
Piano Music - {0} <br><br>
|
||||
Download the MIDI file <a href="{1}.mid"> {0}.mid </a>
|
||||
and the pdf <a href="{1}.pdf">{0}.pdf </a> <br>
|
||||
(This music was generated from the <a href="{1}.abc">{0}.abc </a>
|
||||
and the MMA file <a href="{1}.mma">{0}.mma </a> ) <br>
|
||||
</p>
|
||||
""".format(self.name, webName)
|
||||
|
||||
f.write(str)
|
||||
f.close()
|
||||
|
||||
|
||||
return True
|
||||
|
||||
def addSong(songs, directory, index, name):
|
||||
details = songDetails()
|
||||
details.directory = directory
|
||||
details.index = index
|
||||
details.name = name
|
||||
songs.append(details)
|
||||
|
||||
|
||||
def runMain(argv):
|
||||
|
||||
if len(argv) > 3:
|
||||
print "usage: makescore args"
|
||||
return
|
||||
|
||||
doSingleSong = ""
|
||||
doSingleNumber = -1
|
||||
|
||||
if len(argv) == 2:
|
||||
#doSingleSong = argv[1]
|
||||
doSingleNumber = int(argv[1]) - 1
|
||||
#doSingleNumber = 7
|
||||
|
||||
outputRootDir = "Output"
|
||||
zipFileName = "BoosterMusicBooks"
|
||||
MUSIC_RELEASE = "1"
|
||||
outputDir = outputRootDir + '/' + zipFileName + MUSIC_RELEASE
|
||||
webDir = outputRootDir + '/' + "MusicWeb"
|
||||
tempDir = outputRootDir + '/' + "Temp"
|
||||
|
||||
if not os.path.isdir("Output"):
|
||||
os.mkdir("Output")
|
||||
if not os.path.isdir(outputDir):
|
||||
os.mkdir(outputDir)
|
||||
if not os.path.isdir(webDir):
|
||||
os.mkdir(webDir)
|
||||
if not os.path.isdir(tempDir):
|
||||
os.mkdir(tempDir)
|
||||
|
||||
musicHtmlPage = webDir + "/music.html"
|
||||
#musicHtmlPage = "music.html"
|
||||
if os.path.isfile(musicHtmlPage):
|
||||
os.remove(musicHtmlPage)
|
||||
os.system("cp music.html.start \"{0}\"".format(webDir + "/" + "Beginner Course" + ".html"))
|
||||
os.system("cp music.html.start \"{0}\"".format(webDir + "/" + "Booster Music" + ".html"))
|
||||
|
||||
|
||||
songs=[]
|
||||
|
||||
addSong(songs, "Beginner Course", 1, "StartWithMiddleC")
|
||||
addSong(songs, "Beginner Course", 2, "ChordOfCMajor")
|
||||
addSong(songs, "Beginner Course", 3, "UpAndDown")
|
||||
addSong(songs, "Beginner Course", 4, "ClairDeLaLune")
|
||||
addSong(songs, "Beginner Course", 5, "ChordOfFMajor")
|
||||
addSong(songs, "Beginner Course", 6, "DownAndUp")
|
||||
addSong(songs, "Booster Music", 1, "ClairDeLaLune")
|
||||
addSong(songs, "Booster Music", 2, "LavendersBlue")
|
||||
addSong(songs, "Booster Music", 3, "SkipToMyLoo")
|
||||
addSong(songs, "Booster Music", 4, "FrereJacques")
|
||||
addSong(songs, "Booster Music", 5, "ScarboroughFair")
|
||||
addSong(songs, "Booster Music", 6, "Greensleeves")
|
||||
addSong(songs, "Booster Music", 7, "AmazingGrace")
|
||||
|
||||
result = False
|
||||
found = False
|
||||
for n,song in enumerate(songs):
|
||||
if len(doSingleSong) > 0:
|
||||
if doSingleSong != song.name:
|
||||
continue
|
||||
if doSingleNumber != -1 and doSingleNumber != n:
|
||||
continue
|
||||
|
||||
found = True
|
||||
result = song.createMusic(outputDir, webDir, tempDir)
|
||||
if not result:
|
||||
break
|
||||
|
||||
if found == False:
|
||||
for n,song in enumerate(songs):
|
||||
print "{0} {1}".format(n, song.name)
|
||||
return
|
||||
|
||||
|
||||
if result and len(doSingleSong) == 0 and doSingleNumber == -1:
|
||||
os.system("cat music.html.end >>\"{0}\"".format(webDir + "/" + "Beginner Course" + ".html"))
|
||||
os.system("cat music.html.end >>\"{0}\"".format(webDir + "/" + "Booster Music" + ".html"))
|
||||
|
||||
if os.path.isfile("{0}/{1}.zip".format(outputRootDir, zipFileName )):
|
||||
os.remove("{0}/{1}.zip".format(outputRootDir, zipFileName ))
|
||||
|
||||
#cmd = "gzip \"{0}\" >\"{1}.zip\"" .format(outputDir, outputDir )
|
||||
cmd = "cd {0};zip -r {1}.zip \"{2}\" " .format(outputRootDir, zipFileName, zipFileName + MUSIC_RELEASE )
|
||||
print cmd
|
||||
if os.system(cmd) != 0:
|
||||
return False
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
runMain(sys.argv)
|
|
@ -1,12 +0,0 @@
|
|||
#!/bin/bash
|
||||
#rename to makemusic.bat to run on windows
|
||||
|
||||
# create the output dir if does not exist
|
||||
[ -a PianoBoosterMusic ] || mkdir "PianoBoosterMusic"
|
||||
|
||||
# from abc plus
|
||||
abcm2ps -s 0.9 -c $1.abc -O PianoBoosterMusic/$1.ps
|
||||
|
||||
# from imagemagick
|
||||
convert -density 120x120 PianoBoosterMusic/$1.ps PianoBoosterMusic/$1.png
|
||||
|
Loading…
Reference in New Issue
Block a user