In [1]:
from tomato.symbolic.symbtrconverter import SymbTrConverter
import pprint
import os
In [2]:
data_folder = os.path.join('..', 'sample-data')
# score filepaths
score_folder = 'ussak--sazsemaisi--aksaksemai----neyzen_aziz_dede'
symbtr_name = 'ussak--sazsemaisi--aksaksemai----neyzen_aziz_dede'
work_mbid = 'e7924b0d-c8a0-4b4a-b253-8eec898eac1e'
# input files
txt_filename = os.path.join(data_folder, score_folder, symbtr_name + '.txt')
mu2_filename = os.path.join(data_folder, score_folder, symbtr_name + '.mu2')
# outputs
xml_filename = os.path.join(data_folder, score_folder, symbtr_name + '.xml')
ly_filename = os.path.join(data_folder, score_folder, symbtr_name + '.ly')
svg_filename_template = os.path.join(data_folder, score_folder, symbtr_name)
# parameters
render_metadata = True # Add the metadata stored in MusicXML to Lilypond
svg_paper_size = 'junior-legal' # The paper size of the svg output pages
# instantiate analyzer object
symbTrConverter = SymbTrConverter()
You can use the single line call "convert," which does all the available conversions, [txt + mu2] => MusicXML => LilyPond => svg, simultaneously
In [3]:
xml_output, ly_output, svg_output, txt_ly_mapping = symbTrConverter.convert(
txt_filename, mu2_filename, symbtr_name=symbtr_name, mbid=work_mbid,
render_metadata=render_metadata, xml_out=xml_filename, ly_out=ly_filename,
svg_out=svg_filename_template, svg_paper_size=svg_paper_size)
... or you can call all the methods individually.
In [4]:
# convert symbtr-txt file to MusicXML format. Use the metadata in the mu2 header as
# complementary information
xml_file = symbTrConverter.txt_mu2_to_musicxml(
txt_filename, mu2_filename, xml_out=xml_filename, symbtr_name=symbtr_name,
mbid=work_mbid)
# convert the MusicXML to LilyPond
ly_file, ly_txt_mapping = symbTrConverter.musicxml_to_lilypond(
xml_file, ly_out=ly_filename, render_metadata=render_metadata)
# convert the LilyPond to svg
svg_files = symbTrConverter.lilypond_to_svg(
ly_file, svg_out=svg_filename_template,
paper_size=svg_paper_size, ly_txt_mapping=ly_txt_mapping)