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
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)
class Test(TestCase): def setUp(self) -> None: self.score = TreeScoreTimewise() def make_t(self, *args): sf = SimpleFormat(quarter_durations=[1, 1, 1, 1]) for i in range(3): sf.chords[i].is_adjoinable = args[i] sf.chords[0].add_tie('start') sf.chords[1].add_tie('stop') sf.chords[1].add_tie('start') sf.chords[2].add_tie('stop') sf.chords[2].add_tie('start') sf.chords[3].add_tie('stop') v = sf.to_stream_voice(1) v.add_to_score(self.score) self.score.add_subtitle( str([chord.is_adjoinable for chord in sf.chords])) def test_1(self): self.make_t(False, False, False) result_path = path + '_test_1' self.score.write(path=result_path) TestScore().assert_template(result_path=result_path) def test_2(self): self.make_t(False, False, True) result_path = path + '_test_2' self.score.write(path=result_path) TestScore().assert_template(result_path=result_path) def test_3(self): self.make_t(False, True, False) result_path = path + '_test_3' self.score.write(path=result_path) TestScore().assert_template(result_path=result_path) def test_4(self): self.make_t(False, True, True) result_path = path + '_test_4' self.score.write(path=result_path) TestScore().assert_template(result_path=result_path) def test_5(self): self.make_t(True, False, False) result_path = path + '_test_5' self.score.write(path=result_path) TestScore().assert_template(result_path=result_path) def test_6(self): self.make_t(True, False, True) result_path = path + '_test_6' self.score.write(path=result_path) TestScore().assert_template(result_path=result_path) def test_7(self): self.make_t(True, True, False) result_path = path + '_test_7' self.score.write(path=result_path) TestScore().assert_template(result_path=result_path) def test_8(self): self.make_t(True, True, True) result_path = path + '_test_8' self.score.write(path=result_path) TestScore().assert_template(result_path=result_path)
class Test(TestCase): def setUp(self) -> None: self.score = TreeScoreTimewise() def make_t(self, *args): sf = SimpleFormat(quarter_durations=[1, 1, 1, 1], midis=[0, 0, 0, 0]) for i in range(3): sf.chords[i].is_adjoinable = args[i] v = sf.to_stream_voice(1) v.add_to_score(self.score) self.score.add_subtitle( str([chord.is_adjoinable for chord in sf.chords])) def test_1(self): self.make_t(False, False, False) result_path = path + '_test_1' self.score.write(path=result_path) TestScore().assert_template(result_path=result_path) def test_2(self): self.make_t(False, False, True) result_path = path + '_test_2' self.score.write(path=result_path) TestScore().assert_template(result_path=result_path) def test_3(self): self.make_t(False, True, False) result_path = path + '_test_3' self.score.write(path=result_path) TestScore().assert_template(result_path=result_path) def test_4(self): self.make_t(False, True, True) result_path = path + '_test_4' self.score.write(path=result_path) TestScore().assert_template(result_path=result_path) def test_5(self): self.make_t(True, False, False) result_path = path + '_test_5' self.score.write(path=result_path) TestScore().assert_template(result_path=result_path) def test_6(self): self.make_t(True, False, True) result_path = path + '_test_6' self.score.write(path=result_path) TestScore().assert_template(result_path=result_path) def test_7(self): self.make_t(True, True, False) result_path = path + '_test_7' self.score.write(path=result_path) TestScore().assert_template(result_path=result_path) def test_8(self): self.make_t(True, True, True) result_path = path + '_test_8' self.score.write(path=result_path) TestScore().assert_template(result_path=result_path) def test_9(self): sf = SimpleFormat(quarter_durations=[0.2, 0.8, 1, 1], midis=[0, 0, 0, 60]) sf.to_stream_voice().add_to_score(self.score) result_path = path + '_test_9' self.score.write(path=result_path) # TestScore().assert_template(result_path=result_path) def test_10(self): sf = SimpleFormat(quarter_durations=[0.5, 2.5], midis=[60, 0]) self.score.set_time_signatures(quarter_durations=[3]) sf.to_stream_voice().add_to_score(self.score) result_path = path + '_test_10' 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)