1
0
Fork 0
[Defunct] Attempt at organising a book from a music repository.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

45 lines
1.3 KiB

#! /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)