Add chords to the Track. The given chords should be a list of shorthand strings or list of list of shorthand strings, etc. Each sublist divides the value by 2. If a tuning is set, chords will be expanded so they have a proper fingering. Example:
(self, chords, duration=1)
| 92 | yield beat, duration, notes |
| 93 | |
| 94 | def from_chords(self, chords, duration=1): |
| 95 | """Add chords to the Track. |
| 96 | |
| 97 | The given chords should be a list of shorthand strings or list of |
| 98 | list of shorthand strings, etc. |
| 99 | |
| 100 | Each sublist divides the value by 2. |
| 101 | |
| 102 | If a tuning is set, chords will be expanded so they have a proper |
| 103 | fingering. |
| 104 | |
| 105 | Example: |
| 106 | >>> t = Track().from_chords(['C', ['Am', 'Dm'], 'G7', 'C#'], 1) |
| 107 | """ |
| 108 | tun = self.get_tuning() |
| 109 | |
| 110 | def add_chord(chord, duration): |
| 111 | if isinstance(chord, list): |
| 112 | for c in chord: |
| 113 | add_chord(c, duration * 2) |
| 114 | else: |
| 115 | chord = NoteContainer().from_chord(chord) |
| 116 | if tun: |
| 117 | chord = tun.find_chord_fingering( |
| 118 | chord, return_best_as_NoteContainer=True |
| 119 | ) |
| 120 | if not self.add_notes(chord, duration): |
| 121 | # This should be the standard behaviour of add_notes |
| 122 | dur = self.bars[-1].value_left() |
| 123 | self.add_notes(chord, dur) |
| 124 | |
| 125 | # warning should hold note |
| 126 | self.add_notes(chord, value.subtract(duration, dur)) |
| 127 | |
| 128 | for c in chords: |
| 129 | if c is not None: |
| 130 | add_chord(c, duration) |
| 131 | else: |
| 132 | self.add_notes(None, duration) |
| 133 | return self |
| 134 | |
| 135 | def get_tuning(self): |
| 136 | """Return a StringTuning object. |
nothing calls this directly
no test coverage detected