def test_5(self): sf = SimpleFormat(quarter_durations=[2]) chords = sf.chords[0].split(1, 1) sf._chords = [] for ch in chords: sf.add_chord(ch) sf.chords[0].remove_tie('start') sf.chords[0].add_slur(type='start', line_type='dashed') sf.chords[1].remove_tie('stop') sf.chords[1].add_slur(type='stop') sf.to_stream_voice().add_to_score(self.score) xml_path = path + '_test_5.xml' self.score.write(xml_path)
def test_4(self): sf = SimpleFormat() for notehead in TypeNoteheadValue._PERMITTED: sf.add_chord(TreeChord(quarter_duration=1)) sf.chords[-1].midis[0].notehead = Notehead(notehead) sf.chords[-1].add_words(notehead) sf.add_chord(TreeChord(quarter_duration=2)) sf.chords[-1].midis[0].notehead = Notehead(notehead) self.score.set_time_signatures(times={1: (3, 4)}) sf.to_stream_voice().add_to_score(self.score) xml_path = path + '_test_4.xml' self.score.write(xml_path) TestScore().assert_template(xml_path)
def test_1(self): sf = SimpleFormat() sf.add_chord(TreeChord()) sf.add_chord(TreeChord(quarter_duration=0)) v = sf.to_stream_voice(1) v.add_to_score(self.score) chord = self.score.get_measure(1).get_part(1).get_staff(1).get_voice(1).chords[1] self.score.fill_with_rest() self.score.preliminary_adjoin_rests() self.score.add_beats() chord.remove_from_score() xml_path = path + '_test_1.xml' self.score.write(path=xml_path) self.assertCompareFiles(xml_path)
def test_2(self): sf = SimpleFormat(quarter_durations=[5], midis=[(60, 65, 69)]) chords = sf.chords[0].split(1, 1, 1, 1, 1) for ch in chords: ch.is_adjoinable = False sf._chords = [] for ch in chords: sf.add_chord(ch) sf.chords[2].remove_tie('start') sf.chords[3].remove_tie('stop') sf.to_stream_voice().add_to_score(self.score) xml_path = path + '_test_2.xml' self.score.write(xml_path) TestScore().assert_template(xml_path)
def test_4(self): sf = SimpleFormat(quarter_durations=[5], midis=[(60, 65, 69)]) chords = sf.chords[0].split(1, 1, 1, 1, 1) sf._chords = [] for ch in chords: sf.add_chord(ch) sf.chords[2].remove_tie('start') sf.chords[2].add_slur(type='start', line_type='dashed') sf.chords[3].remove_tie('stop') sf.chords[3].add_slur(type='stop') sf.to_stream_voice().add_to_score(self.score) xml_path = path + '_test_4.xml' self.score.write(xml_path) TestScore().assert_template(xml_path)
def test_1(self): sf = SimpleFormat() for clef in ALL_CLEFS: if clef not in [SUPER_HIGH_TREBLE_CLEF, SUPER_LOW_BASS_CLEF]: for midi in clef.optimal_range: if not midi: if clef.optimal_range.index(midi) == 0: midi = G(0) else: midi = C(8) sf.add_chord(TreeChord(quarter_duration=2, midis=[midi])) sf.chords[-2].add_clef(clef) xml = path + '_test_1.xml' sf.to_stream_voice().add_to_score(self.score) self.score.finish() self.score.to_partwise() self.score.write(xml)
def get_simple_format(self, layer=None): if layer is None: layer = self.get_farthest_leaf().get_distance() self.get_layer(layer=layer) simple_format = SimpleFormat() for node in basic_functions.flatten(self.get_layer(layer)): if node.chord is not None: if node.chord_field is not None: raise ChordFieldConflict() if node._simple_format is not None: raise SimpleFormatConflict() copied_chord = node.chord.__deepcopy__() simple_format.add_chord(copied_chord) elif node.chord_field is not None: if node._simple_format is not None: raise SimpleFormatConflict() for chord in node.chord_field.chords: copied_chord = chord.__deepcopy__() simple_format.add_chord(copied_chord) elif node._simple_format is not None: for chord in node._simple_format.chords: copied_chord = chord.__deepcopy__() simple_format.add_chord(copied_chord) else: raise NoneChordException() return simple_format
def test_1(self): xml_path = path + '_test_1.xml' harmonics = SimpleFormat() for i in range(1, 17): partial_midi = Midi(round(self.horn.get_partial_midi_value(i) * 2) / 2) if i % 7 == 0: partial_midi.accidental.mode = 'flat' if i % 11 == 0: partial_midi.accidental.mode = 'sharp' if i % 13 == 0: partial_midi.accidental.mode = 'flat' chord = TreeChord(midis=partial_midi) chord.add_words(i) harmonics.add_chord(chord) harmonics.to_stream_voice().add_to_score(self.score, part_number=2) harmonics.transpose(self.horn.transposition) harmonics.to_stream_voice().add_to_score(self.score, part_number=1) self.score.accidental_mode = 'modern' self.score.write(xml_path) TestScore().assert_template(xml_path)
def test_1(self): xml_path = path + '_test_1.xml' durations = [2, 2] sf = SimpleFormat(quarter_durations=durations) chords = sf.chords chords[0].add_tie('start') chords[1].add_tie('stop') chords[1].is_adjoinable = False # sf.to_stream_voice().add_to_score(self.score, part_number=1) sf._chords = [] new_chords = chords[0].split(1, 1) new_chords.append(chords[1]) for ch in new_chords: # ch.is_adjoinable = False sf.add_chord(ch) v = sf.to_stream_voice() # print([ch.quarter_duration for ch in v.chords]) # print([ch.is_tied_to_next for ch in v.chords]) # print([ch.is_adjoinable for ch in v.chords]) sf.to_stream_voice().add_to_score(self.score, part_number=1) self.score.write(xml_path)
def simple_format(self): sf = SimpleFormat() if self.chords: for chord in self.chords: sf.add_chord(chord) return sf
def test_2(self): xml_path = path + '_test_2.xml' durations = [5] sf = SimpleFormat(quarter_durations=durations) chords = sf.chords sf._chords = [] new_chords = chords[0].split(4, 1) new_chords[0].is_adjoinable = False for ch in new_chords: sf.add_chord(ch) chords = sf.chords sf._chords = [] new_chords = chords[0].split(1, 3) new_chords[0].is_adjoinable = False new_chords.append(chords[-1]) for ch in new_chords: sf.add_chord(ch) chords = sf.chords sf._chords = [] sf.add_chord(chords[0]) new_chords = chords[1].split(1, 2) new_chords[0].is_adjoinable = False new_chords.append(chords[-1]) for ch in new_chords: sf.add_chord(ch) chords = sf.chords sf._chords = [] sf.add_chord(chords[0]) sf.add_chord(chords[1]) new_chords = chords[2].split(1, 1) new_chords[0].is_adjoinable = False new_chords.append(chords[-1]) for ch in new_chords: sf.add_chord(ch) sf.to_stream_voice().add_to_score(self.score, part_number=1) self.score.write(xml_path)