def setUp(self) -> None: self.score = TreeScoreTimewise() sf = SimpleFormat(quarter_durations=[4]) sf.to_stream_voice().add_to_score(self.score)
def test_1(self): sf = SimpleFormat(quarter_durations=[1.5, 1.5]) sf.to_stream_voice().add_to_score(self.score) xml_path = path + '_test_1.xml' self.score.write(xml_path) TestScore().assert_template(xml_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)
from musurgia.arithmeticprogression import ArithmeticProgression from musurgia.chordfield.chordfield import ChordField from musurgia.chordfield.valuegenerator import ValueGenerator path = str(os.path.abspath(__file__).split('.')[0]) score = TreeScoreTimewise() parent_chord_field = ChordField(duration_generator=ValueGenerator( ArithmeticProgression(n=5, a1=0.5, correct_s=True))) # parent_chord_field = ChordField(duration_generator=ValueGenerator(iter([0.5, 1, 1.5]))) quarter_durations = [3, 2, 3] for i in range(len(quarter_durations)): quarter_duration = quarter_durations[i] midi = 60 + i parent_chord_field.add_child( ChordField(midi_generator=ValueGenerator(cycle([midi])), long_ending_mode='self_extend', short_ending_mode='self_shrink', quarter_duration=quarter_duration)) ### print(list(parent_chord_field.duration_generator.__deepcopy__())) simple_format = SimpleFormat() for child in parent_chord_field.children: simple_format.extend(child.simple_format) simple_format.to_stream_voice().add_to_score(score=score, part_number=3) print(simple_format.quarter_duration) print(float(simple_format.quarter_duration)) ### xml_path = path + '_test_2.xml' score.write(xml_path)
def setUp(self) -> None: random.seed(1) durations = [random.random() + random.random() for i in range(10)] self.sf = SimpleFormat(quarter_durations=durations) self.score = TreeScoreTimewise()
from pathlib import Path from musicscore.musicstream.streamvoice import SimpleFormat from musicscore.musictree.treescoretimewise import TreeScoreTimewise self_path = Path(__file__) viola_sf = SimpleFormat( midis=[60, 66, 64, 71], quarter_durations=[1, 2, 1.5, 3.5] ) sf.chords[0].add_dynamics('ff') sf.chords[0].add_articulation('staccato') sf.chords[1].add_dynamics('pp') sf.chords[1].add_slur('start') sf.chords[-1].add_slur('stop') score = TreeScoreTimewise() sf.to_stream_voice().add_to_score(score) xml_path = self_path.with_suffix('.xml') score.write(path=xml_path)
def test_2(self): sf_1 = SimpleFormat(quarter_durations=[1, 0.25, 2.25]) sf_2 = SimpleFormat(quarter_durations=[0.25, 2.25, 1]) sf_3 = SimpleFormat(quarter_durations=[2.25, 1, 0.25]) sf_1.to_stream_voice().add_to_score(self.score, part_number=1, staff_number=1) sf_2.to_stream_voice().add_to_score(self.score, part_number=1, staff_number=2) sf_3.to_stream_voice().add_to_score(self.score, part_number=1, staff_number=3) xml_path = path + '_test_2.xml' self.score.write(xml_path) chord_offsets = {} for measure in self.score.get_children_by_type(TreeMeasure): for part in measure.get_children_by_type(TreePart): for key in part.tree_part_staves.keys(): staff = part.tree_part_staves[key] chord_offsets[key] = [tree_chord.offset for tree_chord in staff.chords] expected = {1: [0, Fraction(1, 1), Fraction(5, 4), Fraction(2, 1), Fraction(7, 2)], 2: [0, Fraction(1, 4), Fraction(1, 1), Fraction(5, 2), Fraction(7, 2)], 3: [0, Fraction(2, 1), Fraction(9, 4), Fraction(3, 1), Fraction(13, 4), Fraction(7, 2)]} actual = chord_offsets self.assertEqual(expected, actual)