Scripts generating lilypond files added
This commit is contained in:
parent
0586677015
commit
8d50d6efca
5 changed files with 100 additions and 57 deletions
|
@ -1,15 +1,17 @@
|
|||
#!/usr/bin/env python3
|
||||
import os
|
||||
|
||||
def generate_set(title=None, scores=None, copy=False, root=None):
|
||||
def generate_ly(title=None, scores=None, copy=False, root=None):
|
||||
"""Generate a new lilypond file containing all entries from scores, if copy is False, they will be 'linked'"""
|
||||
|
||||
# Find title
|
||||
if title is not None:
|
||||
title = "\\header {\n\ttitle = \""+ title + "\"\n}\n"
|
||||
else:
|
||||
title = ""
|
||||
|
||||
|
||||
# Content of scores
|
||||
scorestext = ""
|
||||
for item in scores:
|
||||
if item.startswith('std'):
|
||||
|
@ -57,9 +59,9 @@ if __name__ == "__main__":
|
|||
from argparse import ArgumentParser
|
||||
parser = ArgumentParser(__file__)
|
||||
parser.add_argument('-c', dest='copy', action='store_true', default=False, help="Copy files instead of just linkingi")
|
||||
parser.add_argument('-t',dest='title',help="Title for the set",default=None)
|
||||
parser.add_argument('-t', dest='title', default=None, help="Title for the set")
|
||||
parser.add_argument('scores', nargs='+')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
print(generate_set(args.title, args.scores, args.copy))
|
||||
print(generate_ly(args.title, args.scores, args.copy))
|
26
sets2tex.py
26
sets2tex.py
|
@ -1,26 +0,0 @@
|
|||
#! /usr/bin/env python3
|
||||
|
||||
from tunes_db.tune import Tune
|
||||
from tunes_db.sets import sets
|
||||
from gen_set import generate_set
|
||||
|
||||
|
||||
music_root = "/home/ericteunis/projects/pipeband-scoring/music/"
|
||||
|
||||
for tuneset in sets:
|
||||
############################################
|
||||
# Generate a pdf for each instrument from instrument array
|
||||
############################################
|
||||
title = "Set " + tuneset.setid + ": " + tuneset.name
|
||||
print(title)
|
||||
for instrument, scores in tuneset.instruments.items():
|
||||
instrset = generate_set(title, scores, root=music_root)
|
||||
|
||||
############################################
|
||||
# Save it into the texfile linking all scores
|
||||
############################################
|
||||
|
||||
|
||||
############################################
|
||||
# Generate Table of Contents entry for setlist
|
||||
############################################
|
26
tunes2tex.py
26
tunes2tex.py
|
@ -1,26 +0,0 @@
|
|||
#! /usr/bin/env python3
|
||||
|
||||
from tunes_db.tune import Tune
|
||||
from tunes_db.tunes import tunes
|
||||
from gen_set import generate_set
|
||||
|
||||
|
||||
music_root = "/home/ericteunis/projects/pipeband-scoring/music/"
|
||||
|
||||
for tune in tunes:
|
||||
############################################
|
||||
# Generate a pdf for each instrument from instrument array
|
||||
############################################
|
||||
print(tune.name)
|
||||
for instrument, scores in tune.instruments.items():
|
||||
instrset = generate_set(tune.name, scores, root=music_root)
|
||||
|
||||
############################################
|
||||
# Save it into the texfile linking all scores
|
||||
############################################
|
||||
|
||||
|
||||
############################################
|
||||
# Generate Table of Contents entry for setlist
|
||||
############################################
|
||||
|
45
update_sets.ly.py
Executable file
45
update_sets.ly.py
Executable file
|
@ -0,0 +1,45 @@
|
|||
#! /usr/bin/env python3
|
||||
|
||||
from tunes_db.tune import Tune
|
||||
from tunes_db.sets import sets
|
||||
from generate_ly import generate_ly
|
||||
|
||||
import os
|
||||
############################################
|
||||
# Generate a pdf for each instrument from instrument array
|
||||
############################################
|
||||
#TODO: execute lilypond
|
||||
#TODO: generate full/drums/mid scores
|
||||
|
||||
|
||||
music_root = "/home/ericteunis/projects/pipeband-scoring/music/"
|
||||
ly_dir = "./ly/sets/"
|
||||
|
||||
gen_files = []
|
||||
for tuneset in sets:
|
||||
title = "Set " + tuneset.setid + ": " + tuneset.name
|
||||
print(title, end=None)
|
||||
set_dir = os.path.join(ly_dir, "set"+tuneset.setid)
|
||||
|
||||
instrument_files = {}# holds all successfully generated set *.ly files
|
||||
for instrument, scores in tuneset.instruments.items():
|
||||
instrset = generate_ly(title, scores, root=music_root)
|
||||
|
||||
if instrset is not False:
|
||||
if not os.path.isdir(set_dir):
|
||||
os.makedirs(set_dir)
|
||||
|
||||
instrument_files[instrument] = os.path.join(set_dir, instrument+".ly")
|
||||
|
||||
# save to file
|
||||
with open(instrument_files[instrument], 'w') as f:
|
||||
f.write(instrset)
|
||||
|
||||
# execute lilypond
|
||||
|
||||
# save the list of generated files
|
||||
for k,v in instrument_files.items():
|
||||
gen_files.append(v)
|
||||
|
||||
# output a list of all generated files
|
||||
print(gen_files)
|
48
update_tunes.ly.py
Executable file
48
update_tunes.ly.py
Executable file
|
@ -0,0 +1,48 @@
|
|||
#! /usr/bin/env python3
|
||||
|
||||
from tunes_db.tune import Tune
|
||||
from tunes_db.tunes import tunes
|
||||
from generate_ly import generate_ly
|
||||
|
||||
import os
|
||||
############################################
|
||||
# Generate a pdf for each instrument from instrument array
|
||||
############################################
|
||||
#TODO: execute lilypond
|
||||
#TODO: generate full/drums/mid scores
|
||||
|
||||
music_root = "/home/ericteunis/projects/pipeband-scoring/music/"
|
||||
ly_dir = "./ly/tunes/"
|
||||
|
||||
gen_files = []
|
||||
|
||||
for tune in tunes:
|
||||
print(tune.name, end=None)
|
||||
|
||||
tune_dir = "".join(c for c in tune.name if c.isalnum()).rstrip().lower()
|
||||
tune_dir = os.path.join(ly_dir, tune_dir)
|
||||
|
||||
|
||||
instrument_files = {}# holds all successfully generated set *.ly files
|
||||
for instrument, scores in tune.instruments.items():
|
||||
instrtune = generate_ly(tune.name, scores, root=music_root)
|
||||
|
||||
if instrtune is not False:
|
||||
if not os.path.isdir(tune_dir):
|
||||
os.makedirs(tune_dir)
|
||||
|
||||
instrument_files[instrument] = os.path.join(tune_dir, instrument+".ly")
|
||||
|
||||
# save to file
|
||||
with open(instrument_files[instrument], 'w') as f:
|
||||
f.write(instrtune)
|
||||
|
||||
|
||||
# execute lilypond
|
||||
|
||||
# save the list of generated files
|
||||
for k,v in instrument_files.items():
|
||||
gen_files.append(v)
|
||||
|
||||
# output a list of all generated files
|
||||
print(gen_files)
|
Loading…
Reference in a new issue