def test_3(self): # fields: both with midi_generators, one duration_generator # group: duration_generator with __next__ (Random) cfg = ChordField( duration_generator=ValueGenerator(Random(pool=[0.2, 0.4, 0.8, 1.6], seed=10)) ) cf_1 = ChordField(quarter_duration=3, midi_generator=ValueGenerator(cycle([60, 61, 64, 66])), duration_generator=ValueGenerator(cycle([1])) ) cf_2 = ChordField(quarter_duration=6, midi_generator=ValueGenerator(cycle([72, 73, 74, 73, 72])), long_ending_mode='cut' ) cfg.add_child(cf_1) cfg.add_child(cf_2) sf_1 = cf_1.simple_format sf_2 = cf_2.simple_format sf = SimpleFormat() sf.extend(sf_1) sf.extend(sf_2) xml_path = path + 'test_3.xml' # cfg.simple_format.to_stream_voice().add_to_score(self.score) sf.to_stream_voice().add_to_score(self.score) self.score.write(xml_path) self.assertCompareFiles(xml_path)
def test_1(self): proportions = (1, 3, 1, 5, 1) breakpoints = (1, Fraction(1, 7), 1) quarter_durations = [8, 12] breathe = Breathe(proportions=proportions, breakpoints=breakpoints, quarter_duration=sum(quarter_durations), quantize=1) breathe.midi_generator = ValueGenerator(cycle([71])) test_chord_field = ChordField(duration_generator=breathe.duration_generator.__deepcopy__()) for i in range(len(quarter_durations)): quarter_duration = quarter_durations[i] midi = 60 + i test_chord_field.add_child( ChordField(midi_generator=ValueGenerator(cycle([midi])), long_ending_mode='self_extend', short_ending_mode='self_shrink', quarter_duration=quarter_duration)) test_chord_field_2 = ChordField(duration_generator=breathe.duration_generator.__deepcopy__()) for i in range(len(quarter_durations)): quarter_duration = quarter_durations[i] midi = 72 + i test_chord_field_2.add_child( ChordField(midi_generator=ValueGenerator(cycle([midi])), long_ending_mode='cut', short_ending_mode='add_rest', quarter_duration=quarter_duration)) breathe.simple_format.to_stream_voice().add_to_score(score=self.score, part_number=1) test_chord_field.simple_format.to_stream_voice().add_to_score(score=self.score, part_number=2) simple_format = SimpleFormat() for child in test_chord_field_2.children: simple_format.extend(child.simple_format) simple_format.to_stream_voice().add_to_score(score=self.score, part_number=3) xml_path = path + '_test_1.xml' self.score.write(xml_path) self.assertCompareFiles(xml_path)
def test_8(self): # fields: midi_generators # group: duration_generator with __call__ RandomInterpolation # output of fields not group cfg = ChordField( duration_generator=ValueGenerator( RandomInterpolation(start=[0.25, 0.25, 0.5], end=[0.5, 0.75, 1], seed=20))) cf_1 = ChordField( quarter_duration=3, midi_generator=ValueGenerator(cycle([60, 61, 64, 66]))) cf_2 = ChordField( quarter_duration=6, midi_generator=ValueGenerator(cycle([72, 73, 74, 73, 72])), long_ending_mode='self_extend') cfg.add_child(cf_1) cfg.add_child(cf_2) xml_path = path + 'test_8.xml' simple_format = SimpleFormat() simple_format.extend(cf_1.simple_format) simple_format.extend(cf_2.simple_format) simple_format.to_stream_voice().add_to_score(self.score) self.score.write(xml_path) self.assertCompareFiles(xml_path)
def test_4(self): cf_1 = ChordField( quarter_duration=10, midi_generator=ValueGenerator(cycle([60, 61, 64, 66])), long_ending_mode='self_extend', short_ending_mode='self_shrink' ) cf_2 = ChordField( quarter_duration=3, midi_generator=ValueGenerator(cycle([72, 73, 74, 73, 72])), long_ending_mode='self_extend', short_ending_mode='self_shrink' ) breathe_unit = Fraction(1, 5) breathe_breakpoints = (5 * breathe_unit, breathe_unit, 5 * breathe_unit) breathe_proportions = [2, 4, 1, 7, 2] breathe = Breathe(proportions=breathe_proportions, quarter_duration=13, breakpoints=breathe_breakpoints) cfg = ChordField(duration_generator=breathe.duration_generator) cfg.add_child(cf_1) cfg.add_child(cf_2) simple_format = SimpleFormat() simple_format.extend(cf_1.simple_format) simple_format.extend(cf_2.simple_format) self.score.set_time_signatures(ceil(simple_format.quarter_duration)) simple_format.to_stream_voice().add_to_score(self.score) xml_path = path + 'test_4.xml' self.score.write(xml_path) self.assertCompareFiles(xml_path)
def test_10(self): midi_generator = ValueGenerator() midi_generator.add_child( ValueGenerator(RandomInterpolation(start=[60, 62, 66, 68], end=[67, 69, 73, 75], seed=10), duration=10) ) midi_generator.add_child( ValueGenerator(RandomInterpolation(start=[67, 69, 73, 75], end=[60, 62, 66, 68], seed=11), duration=10) ) cfg = ChordField( ) cf_1 = ChordField( quarter_duration=3, duration_generator=ValueGenerator(ArithmeticProgression(a1=0.5, an=1, correct_s=True)) ) cf_2 = ChordField( quarter_duration=6, duration_generator=ValueGenerator(ArithmeticProgression(a1=1, an=1, correct_s=True)) ) cfg.add_child(cf_1) cfg.add_child(cf_2) cfg.midi_generator = midi_generator cfg.__next__()
def test_4(self): # fields: midi_generators, first one with ending_mode 'post' # group: duration_generator with __next__ (Arithmetic Progression) cfg = ChordField( duration_generator=ValueGenerator(ArithmeticProgression(a1=0.3, an=1.5, correct_s=True)) ) cf_1 = ChordField(quarter_duration=3, midi_generator=ValueGenerator(cycle([60, 61, 64, 66])), long_ending_mode='self_extend' ) cf_2 = ChordField(quarter_duration=6, midi_generator=ValueGenerator(cycle([72, 73, 74, 73, 72])), short_ending_mode='add_rest', ) cfg.add_child(cf_1) cfg.add_child(cf_2) sf = SimpleFormat() sf.extend(cf_1.simple_format) sf.extend(cf_2.simple_format) xml_path = path + 'test_4.xml' sf.to_stream_voice().add_to_score(self.score) self.score.write(xml_path) self.assertCompareFiles(xml_path)
def add_chord_field(child): child.chord_field = ChordField(duration_generator=ValueGenerator(ArithmeticProgression(a1=0.2, an=2)), midi_generator=ValueGenerator( Interpolation(start=child.midi_generator.midi_range[0], end=child.midi_generator.midi_range[1], duration=None, key=lambda midi: round(midi * 2) / 2)), short_ending_mode='stretch')
def test_12(self): field = ChordField(quarter_duration=10, duration_generator=ValueGenerator(cycle([1])), midi_generator=ValueGenerator(cycle([71]))) sf = field.simple_format self.score.set_time_signatures( quarter_durations=field.quarter_duration) sf.to_stream_voice().add_to_score(self.score) xml_path = path + '_test_12.xml' self.score.write(xml_path) self.assertCompareFiles(xml_path)
def test_15(self): field = ChordField() child_1 = field.add_child(ChordField( midi_generator=ValueGenerator(cycle([71])), duration_generator=ValueGenerator(cycle([1])), quarter_duration=1)) child_2 = field.add_child(ChordField( midi_generator=ValueGenerator(cycle([71])), duration_generator=ValueGenerator(cycle([1])), quarter_duration=1)) actual = field.chords expected = child_1.chords + child_2.chords self.assertEqual(expected, actual)
def test_12(self): # breathing: duration_generator automatically, midi_generator: InterpolationGroup(2 x RandomInterpolations) breathing_proportions = [3, 7, 3, 10, 3] breathing_break_points = [1.5, 0.2, 1.5] breathing = Breathe(quarter_duration=sum(breathing_proportions), proportions=breathing_proportions, breakpoints=breathing_break_points) midi_generator = ValueGenerator() midi_generator.add_child( ValueGenerator(RandomInterpolation(start=[60, 62, 66, 68], end=[67, 69, 73, 75], seed=10), duration=10) ) midi_generator.add_child( ValueGenerator(RandomInterpolation(start=[67, 69, 73, 75], end=[60, 62, 66, 68], seed=11), duration=10) ) breathing.midi_generator = midi_generator copied = breathing.__deepcopy__() xml_path = path + 'test_12.xml' self.score.set_time_signatures(quarter_durations=breathing_proportions) copied.simple_format.to_stream_voice().add_to_score(self.score) self.score.max_division = 5 self.score.write(xml_path) self.assertCompareFiles(xml_path)
def test_14(self): field = ChordField(quarter_duration=10, duration_generator=ValueGenerator( duration_generator(first_duration=1, delta=0.2)), midi_generator=ValueGenerator(cycle([71])), long_ending_mode='omit_and_add_rest') sf = field.simple_format self.score.set_time_signatures( quarter_durations=ceil(field.quarter_duration)) sf.to_stream_voice().add_to_score(self.score) xml_path = path + '_test_14.xml' self.score.write(xml_path) self.assertCompareFiles(xml_path)
def test_13(self): field = ChordField(quarter_duration=10, duration_generator=ValueGenerator( Random(pool=[0.2, 0.4, 0.8, 1.2, 1.6, 2], periodicity=3, seed=20)), midi_generator=ValueGenerator(cycle([71])), long_ending_mode='self_extend') sf = field.simple_format self.score.set_time_signatures( quarter_durations=ceil(field.quarter_duration)) sf.to_stream_voice().add_to_score(self.score) xml_path = path + '_test_13.xml' self.score.write(xml_path) self.assertCompareFiles(xml_path)
def test_8(self): # chord_generator with too short quarter_duration: mode : None field = ChordField( quarter_duration=10, chord_generator=ValueGenerator( iter(SimpleFormat(quarter_durations=[3, 2]).chords))) with self.assertRaises(ShortEndingError): list(field)
def test_1(self): fm = FractalMusic(quarter_duration=20, tempo=80) fm.midi_generator.midi_range = [60, 84] fm.add_layer() sorted_children = sorted(fm.get_children(), key=lambda child: child.fractal_order) chord_field = ChordField( quarter_duration=10, duration_generator=ValueGenerator(ArithmeticProgression(a1=0.2, an=2)), midi_generator=ValueGenerator(Interpolation(start=84, end=60, key=lambda midi: round(midi * 2) / 2)), short_ending_mode='add_rest' ) sorted_children[-1].chord_field = chord_field score = fm.get_score(show_fractal_orders=True) xml_path = path + '_test_1.xml' score.write(xml_path) self.assertCompareFiles(xml_path)
def test_1(self): # fields: midi_generators # group: no generators cfg = ChordField() cf_1 = ChordField(quarter_duration=3, midi_generator=ValueGenerator(cycle([60, 61, 64, 66])), duration_generator=ValueGenerator(cycle([1])) ) cf_2 = ChordField(quarter_duration=6, midi_generator=ValueGenerator(cycle([72, 73, 74, 73, 72])), duration_generator=ValueGenerator(cycle([1])) ) cfg.add_child(cf_1) cfg.add_child(cf_2) xml_path = path + 'test_1.xml' cfg.simple_format.to_stream_voice().add_to_score(self.score) self.score.write(xml_path) self.assertCompareFiles(xml_path)
def test_2(self): # chord_generator with too long quarter_duration: mode : None field = ChordField( quarter_duration=10, chord_generator=ValueGenerator( iter( SimpleFormat( quarter_durations=[3, 2, 1, 2, 3, 4, 5]).chords))) with self.assertRaises(LongEndingError): list(field)
def test_11(self): cfg = ChordField( duration_generator=ValueGenerator( RandomInterpolation(start=[0.25, 0.25, 0.5], end=[0.5, 0.75, 1], seed=20))) cf_1 = ChordField( quarter_duration=3, midi_generator=ValueGenerator(cycle([60, 61, 64, 66]))) cf_2 = ChordField( quarter_duration=6, midi_generator=ValueGenerator(cycle([72, 73, 74, 73, 72])), long_ending_mode='self_extend') cfg.add_child(cf_1) cfg.add_child(cf_2) xml_path = path + 'test_11.xml' copied = cfg.__deepcopy__() copied.simple_format.to_stream_voice().add_to_score(self.score) self.score.write(xml_path) self.assertCompareFiles(xml_path)
def test_16(self): field = ChordField(quarter_duration=10, duration_generator=ValueGenerator( ArithmeticProgression(a1=0.2, an=2, correct_s=True)), midi_generator=ValueGenerator( Interpolation( start=84, end=60, key=lambda midi: round(midi * 2) / 2)), short_ending_mode=None) sf = field.simple_format self.score.set_time_signatures( quarter_durations=ceil(field.quarter_duration)) sf.to_stream_voice().add_to_score(self.score) xml_path = path + '_test_16.xml' self.score.write(xml_path) self.assertCompareFiles(xml_path)
def test_17(self): parent_field = ChordField() child_field_1 = ChordField(quarter_duration=5, duration_generator=ValueGenerator(cycle( [1])), midi_generator=ValueGenerator(cycle([60]))) child_field_2 = ChordField(quarter_duration=10, duration_generator=ValueGenerator(cycle( [2])), midi_generator=ValueGenerator(cycle([61]))) parent_field.add_child(child_field_1) parent_field.add_child(child_field_2) sf = parent_field.simple_format self.score.set_time_signatures( quarter_durations=ceil(parent_field.quarter_duration)) sf.to_stream_voice().add_to_score(self.score) xml_path = path + '_test_17.xml' self.score.write(xml_path) self.assertCompareFiles(xml_path)
def test_3(self): # node.chord_fields are part of a group cfg = ChordField( duration_generator=ValueGenerator(RandomInterpolation(start=[0.25, 0.25], end=[0.75, 1], seed=20))) cf_1 = ChordField( midi_generator=ValueGenerator(cycle([60]))) cf_2 = ChordField( midi_generator=ValueGenerator(cycle([72])), long_ending_mode='cut') cfg.add_child(cf_1) cfg.add_child(cf_2) fm = FractalMusic(quarter_duration=20, tempo=80) fm.add_layer() fm.get_children()[0].chord_field = cf_1 fm.get_children()[1].chord_field = cf_2 score = fm.get_score(show_fractal_orders=True) xml_path = path + 'test_3.xml' score.write(xml_path) self.assertCompareFiles(xml_path)
def test_5(self): # breathing manually times = [3, 7, 3, 10, 3] cf_1 = ChordField(quarter_duration=times[0], midi_generator=ValueGenerator(cycle([72, 73, 74, 73, 72]))) cf_2 = ChordField(quarter_duration=times[1], midi_generator=ValueGenerator(cycle([72, 73, 74, 73, 72]))) cf_3 = ChordField(quarter_duration=times[2], midi_generator=ValueGenerator(cycle([72, 73, 74, 73, 72]))) cf_4 = ChordField(quarter_duration=times[3], midi_generator=ValueGenerator(cycle([72, 73, 74, 73, 72]))) cf_5 = ChordField(quarter_duration=times[4], midi_generator=ValueGenerator(cycle([72, 73, 74, 73, 72]))) points = [1.5, 0.2, 1.5] cf_1.duration_generator = ValueGenerator(ArithmeticProgression(a1=points[0], an=points[0], correct_s=True)) cf_2.duration_generator = ValueGenerator(ArithmeticProgression(a1=points[0], an=points[1], correct_s=True)) cf_3.duration_generator = ValueGenerator(ArithmeticProgression(a1=points[1], an=points[1], correct_s=True)) cf_4.duration_generator = ValueGenerator(ArithmeticProgression(a1=points[1], an=points[0], correct_s=True)) cf_5.duration_generator = ValueGenerator(ArithmeticProgression(a1=points[0], an=points[0], correct_s=True)) cfg = ChordField() cfg.add_child(cf_1) cfg.add_child(cf_2) cfg.add_child(cf_3) cfg.add_child(cf_4) cfg.add_child(cf_5) # # for fractal_tree in cfg.children: # print(fractal_tree.duration_generator.generator.parameters_dict) # values = [float(chord.quarter_duration) for chord in list(fractal_tree)] # print(values) # print(sum(values)) xml_path = path + 'test_5.xml' self.score.set_time_signatures(quarter_durations=times) cfg.simple_format.to_stream_voice().add_to_score(self.score, part_number=1) self.score.max_division = 5 self.score.write(xml_path) self.assertCompareFiles(xml_path)
def test_9(self): # fields: duration_generators # group: midi_generator cfg = ChordField( ) cf_1 = ChordField( quarter_duration=3, duration_generator=ValueGenerator(ArithmeticProgression(a1=0.5, an=1, correct_s=True)) ) cf_2 = ChordField( quarter_duration=6, duration_generator=ValueGenerator(ArithmeticProgression(a1=1, an=1, correct_s=True)) ) cfg.add_child(cf_1) cfg.add_child(cf_2) cfg.midi_generator = ValueGenerator(cycle([60])) simple_format = cfg.simple_format self.score.set_time_signatures(quarter_durations=ceil(cfg.quarter_duration)) xml_path = path + 'test_9.xml' simple_format.to_stream_voice().add_to_score(self.score) self.score.write(xml_path) self.assertCompareFiles(xml_path)
def test_2(self): # fields: midi_generators # group: duration_generator with __next__ cfg = ChordField( duration_generator=ValueGenerator(Random(pool=[0.2, 0.4, 0.8, 1.6], seed=10)) ) cf_1 = ChordField(quarter_duration=3, midi_generator=ValueGenerator(cycle([60, 61, 64, 66])), long_ending_mode='self_extend' ) cf_2 = ChordField(quarter_duration=6, midi_generator=ValueGenerator(cycle([72, 73, 74, 73, 72])), long_ending_mode='self_extend') # cfg = ChordFieldGroup(duration_generator=Random(pool=[0.2, 0.4, 0.8, 1.6], seed=10)) cfg.add_child(cf_1) cfg.add_child(cf_2) simple_format = cfg.simple_format self.score.set_time_signatures(quarter_durations=ceil(cfg.quarter_duration)) xml_path = path + 'test_2.xml' simple_format.to_stream_voice().add_to_score(self.score) self.score.write(xml_path) self.assertCompareFiles(xml_path)
def test_5(self): # node.chord_fields are part of a breathe group fm = FractalMusic(quarter_duration=20, tempo=80) fm.add_layer() fm.quantize_children(grid_size=1) node_groups = slice_list(fm.get_children(), (2, 1)) cf_1 = ChordField( midi_generator=ValueGenerator(cycle([60, 61, 64, 66])), long_ending_mode='self_extend', short_ending_mode='self_shrink' ) cf_2 = ChordField( midi_generator=ValueGenerator(cycle([72, 73, 74, 73, 72])), long_ending_mode='self_extend', short_ending_mode='self_shrink' ) breathe_unit = Fraction(1, 5) breathe_breakpoints = (5 * breathe_unit, breathe_unit, 5 * breathe_unit) breathe_proportions = [2, 4, 1, 7, 2] breathe = Breathe(proportions=breathe_proportions, quarter_duration=sum([node.chord.quarter_duration for node in node_groups[0]]), breakpoints=breathe_breakpoints) cfg = ChordField(duration_generator=breathe.duration_generator) cfg.add_child(cf_1) cfg.add_child(cf_2) fm.get_children()[0].chord_field = cf_1 fm.get_children()[1].chord_field = cf_2 score = fm.get_score(show_fractal_orders=True) xml_path = path + 'test_5.xml' score.write(xml_path) self.assertCompareFiles(xml_path)
def test_4(self): # self.fm.multi = (self.fm.multi[0], self.fm.multi[1] + 1) def get_chord_stamp(): node = fm.__copy__() node.midi_generator.midi_range = fm.midi_generator.midi_range node.midi_generator.microtone = 4 node.add_layer() chord_midis = [child.midi_value for child in node.get_children()] output = [chord_midi - chord_midis[node.size // 2] for chord_midi in chord_midis] return output fm = FractalMusic(proportions=(1, 2, 3, 4, 5, 6, 7), tree_permutation_order=(2, 6, 4, 1, 3, 7, 5), quarter_duration=30, tempo=80) fm.midi_generator.midi_range = (60, 72) fm.midi_generator.microtone = 4 fm.add_layer() fm.quantize_children(grid_size=1) proportions = (1, 10, 1, 7, 1) breakpoints = (1, Fraction(1, 7), 1) selected_nodes = fm.get_children()[1:3] breath_quarter_duration = sum([node.quarter_duration for node in selected_nodes]) breathe = Breathe(proportions=proportions, breakpoints=breakpoints, quarter_duration=breath_quarter_duration, quantize=1) parent_chord_field = ChordField(duration_generator=breathe.duration_generator.__deepcopy__()) for i in range(len(selected_nodes)): node = selected_nodes[i] start_chord = [stamp + node.midi_value for stamp in get_chord_stamp()] next_node = node.next_sibling if next_node: end_chord = [stamp + node.midi_value for stamp in get_chord_stamp()] else: end_chord = start_chord chord_field = ChordField( midi_generator=ValueGenerator(RandomInterpolation(start=start_chord, end=end_chord, seed=10)), long_ending_mode='self_extend', short_ending_mode='self_shrink') parent_chord_field.add_child(chord_field) node.chord_field = chord_field score = fm.get_score(show_fractal_orders=True, layer_number=fm.number_of_layers) score.max_division = 7 score.finish() partwise = score.to_partwise() xml_path = path + '_test_4.xml' partwise.write(xml_path) self.assertCompareFiles(xml_path)
def test_1(self): # chord_generator with matching quarter_duration field = ChordField( quarter_duration=11, chord_generator=ValueGenerator( iter( SimpleFormat( quarter_durations=[3, 2, 1, 2, 3, 4, 5]).chords))) self.score.set_time_signatures( quarter_durations=field.quarter_duration) field.simple_format.to_stream_voice().add_to_score(self.score) xml_path = path + '_test_1.xml' self.score.write(xml_path) self.assertCompareFiles(xml_path)
def test_11(self): # chord_generator with too short quarter_duration: mode : rest field = ChordField( quarter_duration=10, chord_generator=ValueGenerator( iter(SimpleFormat(quarter_durations=[3, 2]).chords)), short_ending_mode='add_rest') sf = field.simple_format self.score.set_time_signatures( quarter_durations=field.quarter_duration) sf.to_stream_voice().add_to_score(self.score) xml_path = path + '_test_11.xml' self.score.write(xml_path) self.assertCompareFiles(xml_path)
def _calculate_quarter_durations(self): if self.proportions: quarter_durations = [ (Fraction(Fraction(p), Fraction(sum(self.proportions)))) * Fraction(self.quarter_duration) for p in self.proportions] if self.duration_units: quarter_durations = find_best_quantized_values(values=quarter_durations, units=self.duration_units, check_sum=True) if self.direction == 'down': quarter_durations = quarter_durations[::-1] self._quarter_durations = quarter_durations if self.quarter_durations: self._duration_generator = ValueGenerator(iter(self.quarter_durations), duration=self.quarter_duration, value_mode='duration') else: self._duration_generator = None
def test_3(self): # chord_generator with too long quarter_duration: mode : self_extend field = ChordField( quarter_duration=10, chord_generator=ValueGenerator( iter( SimpleFormat( quarter_durations=[3, 2, 1, 2, 3, 4, 5]).chords)), long_ending_mode='self_extend') sf = field.simple_format self.score.set_time_signatures( quarter_durations=field.quarter_duration) sf.to_stream_voice().add_to_score(self.score) xml_path = path + '_test_3.xml' self.score.write(xml_path) self.assertCompareFiles(xml_path)
def test_5(self): def get_chord(node): output = fm.get_multi_chord_midis_with_range_factor(range_factor=1, microtone=4) transposition = node.midi_value - output[3] output = [midi + transposition for midi in output] return output fm = FractalMusic(proportions=(1, 2, 3, 4, 5, 6, 7), tree_permutation_order=(2, 6, 4, 1, 3, 7, 5), quarter_duration=30, tempo=72) # fm.multi = (self.fm.multi[0], self.fm.multi[1] + 1) fm.midi_generator.midi_range = (62, 62 + 11) fm.midi_generator.microtone = 4 fm.add_layer() fm.quantize_children(grid_size=1) selected_nodes = fm.get_children()[2:5] proportions = (1, 10, 1, 7, 1) breakpoints = (1, Fraction(1, 7), 1) breath_quarter_duration = sum([node.quarter_duration for node in selected_nodes]) breathe = Breathe(proportions=proportions, breakpoints=breakpoints, quarter_duration=breath_quarter_duration, quantize=1) parent_chord_field = ChordField(duration_generator=breathe.duration_generator.__deepcopy__()) for i in range(len(selected_nodes)): node = selected_nodes[i] start_chord = get_chord(node) next_node = node.next_sibling if next_node: end_chord = get_chord(next_node) else: end_chord = start_chord chord_field = ChordField( midi_generator=ValueGenerator(RandomInterpolation(start=start_chord, end=end_chord, seed=10)), long_ending_mode='self_extend', short_ending_mode='self_shrink') parent_chord_field.add_child(chord_field) node.chord_field = chord_field score = fm.get_score(show_fractal_orders=True, layer_number=fm.number_of_layers) score.max_division = 7 score.finish() partwise = score.to_partwise() xml_path = path + '_test_5.xml' partwise.write(xml_path) self.assertCompareFiles(xml_path)