49 lines
1.3 KiB
Python
49 lines
1.3 KiB
Python
|
#! /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)
|