def to_string(self, multiply_duration=1): durations= split_durations(self.duration, multiply_duration) figures= [self.note.copy() for d in durations] for f, d in zip(figures, durations): f.duration= d if self.note.is_silence: figures_str= map(get_silence_str, figures) else: figures_str= map(get_note_str, figures) return '~ '.join(figures_str)
def to_string(self, multiply_duration=1): chord_duration= min(self.notes, key=lambda x:x.duration).duration chord_notes= [n.copy() for n in self.notes] for n in chord_notes: n.duration= chord_duration durations= split_durations(chord_duration, multiply_duration) res= [] notes_str= ' '.join((get_pitch_str(n) for n in chord_notes)) for duration in durations: chord_str= '<%s>%s' % (notes_str, get_duration_str(duration)) res.append(chord_str) res= ' ~'.join(res) if self.duration > chord_duration: #import ipdb;ipdb.set_trace() chord_notes= [n.copy() for n in self.notes if n.duration > chord_duration] for n in chord_notes: n.duration-= chord_duration res= '%s ~ %s' % (res, ChordGroup(chord_notes).to_string()) return res