class TestScoreDefaults(XMLTestCase): def setUp(self) -> None: self.score = TreeScoreTimewise() def test_word_font(self): sf = SimpleFormat(quarter_durations=[1, 1]) sf.chords[0].add_words('some very nice words') sf.to_stream_voice(1).add_to_score(self.score) xml_path = path.parent.joinpath(path.stem + '_word_font.xml') self.score.defaults.add_child(WordFont(font_family='Open Sans')) self.score.add_title('test title') self.score.add_subtitle('test subtitle') self.score.write(path=xml_path) self.assertCompareFiles(xml_path) def test_lyric_font(self): sf = SimpleFormat(quarter_durations=[1, 1]) sf.chords[0].add_lyric('some very nice words') sf.to_stream_voice(1).add_to_score(self.score) xml_path = path.parent.joinpath(path.stem + '_lyric_font.xml') self.score.defaults.add_child(LyricFont(font_family='Open Sans')) self.score.add_title('test title') self.score.add_subtitle('test subtitle') self.score.write(path=xml_path) self.assertCompareFiles(xml_path)
class Test(XMLTestCase): def setUp(self) -> None: self.score = TreeScoreTimewise() # # def test_(self): # # c = self.score.add_child(Credit(page=1)) # c.add_child(CreditType('title')) # c.add_child(CreditWords('TEST', default_x=598, default_y=1600, font_size=24, justify='center', valign='top')) # # c = self.score.add_child(Credit(page=1)) # c.add_child(CreditType('composer')) # c.add_child(CreditWords('me', default_x=1089, default_y=1550, font_size=12, justify='right', valign='top')) # # c = self.score.add_child(Credit(page=1)) # c.add_child(CreditType('arranger')) # c.add_child(CreditWords('TEST', default_x=1089, default_y=1500, font_size=12, justify='right', valign='top')) # # c = self.score.add_child(Credit(page=1)) # c.add_child(CreditType('subtitle')) # c.add_child(CreditWords('BLA', default_x=598, default_y=1550, font_size=18, justify='center', valign='top')) # # result_path = path + '_test_1' # # self.score.write(path=result_path) # TestScore().assert_template(result_path=result_path) def test_title_subtitle_composer(self): self.score.add_measure() self.score.add_part() xml_path = path.parent.joinpath(path.stem + '_title_subtitle_composer.xml') self.score.add_title("TITLE") self.score.add_subtitle("SUBTITLE") self.score.add_composer("blablabla 2019") self.score.write(path=xml_path) self.assertCompareFiles(xml_path) def test_page_number(self): sf = SimpleFormat(quarter_durations=[1000]) sf.to_stream_voice().add_to_score(self.score) xml_path = path.parent.joinpath(path.stem + '_page_number.xml') self.score.add_page_number(2) self.score.add_page_number(3) self.score.write(path=xml_path) self.assertCompareFiles(xml_path)
def get_score_template(self): score = TreeScoreTimewise() score.tuplet_line_width = 2.4 score.page_style.orientation = 'landscape' score.page_style.system_distance = 180 score.page_style.staff_distance = 150 score.page_style.top_system_distance = 150 score.page_style.bottom_margin = 100 score.add_title('module: {}'.format(self.name)) rounded_duration = round(float(self.duration), 1) if rounded_duration == int(rounded_duration): rounded_duration = int(rounded_duration) clock = Timing.get_clock(rounded_duration, mode='msreduced') score.add_subtitle('duration: {}'.format(clock)) score.accidental_mode = 'modern' return score
def test_17(self): self.fm_7.quarter_duration = 10 score = TreeScoreTimewise() score.add_title('reduce sieve') score.page_style.orientation = 'portrait' score.set_time_signatures(barline_style='light-light', quarter_durations=self.fm_7.quarter_duration) for i in range(1, 8): fm = self.fm_7.__deepcopy__() fm.generate_children(number_of_children=i, mode='reduce_sieve') for leaf in fm.traverse_leaves(): leaf.chord.add_lyric(leaf.fractal_order) sf = fm.get_simple_format(layer=fm.number_of_layers) sf.to_stream_voice().add_to_score(score, part_number=i) xml_path = path + '_test_17.xml' score.write(xml_path) self.assertCompareFiles(xml_path)
class Test(TestCase): def setUp(self) -> None: self.score = TreeScoreTimewise() sf = SimpleFormat(quarter_durations=[1, 1]) v = sf.to_stream_voice(1) v.add_to_score(self.score) def test_1(self): self.score.add_title('test title', font_family='DejaVu Sans') self.score.add_subtitle('test subtitle', font_family='DejaVu Sans') result_path = path + '_test_1' self.score.write(path=result_path) TestScore().assert_template(result_path=result_path) def test_2(self): self.score.page_style.format = 'landscape' self.score.add_title('test title', font_family='DejaVu Sans') self.score.add_subtitle('test subtitle', font_family='DejaVu Sans') result_path = path + '_test_2' self.score.write(path=result_path)
import os from musicscore.musicstream.streamvoice import SimpleFormat from musicscore.musictree.treescoretimewise import TreeScoreTimewise path = str(os.path.abspath(__file__).split('.')[0]) score = TreeScoreTimewise() score.page_style.orientation = 'landscape' score.add_title('BIG IMPORTANT TITLE') score.add_subtitle('unimportant subtitle') score.add_composer('me') score.add_text('some text') simple_format = SimpleFormat(quarter_durations=4) simple_format.to_stream_voice().add_to_score(score=score) score.page_style.orientation = 'portrait' # conversion of default_x and default_y in CreditWords (child of Credit) xml_path = path + '_1.xml' score.write(xml_path)