Process a Track object and return the LilyPond equivalent in a string.
(track)
| 171 | |
| 172 | |
| 173 | def from_Track(track): |
| 174 | """Process a Track object and return the LilyPond equivalent in a string.""" |
| 175 | # Throw exception |
| 176 | if not hasattr(track, "bars"): |
| 177 | return False |
| 178 | lastkey = Key("C") |
| 179 | lasttime = (4, 4) |
| 180 | |
| 181 | # Handle the Bars: |
| 182 | result = "" |
| 183 | for bar in track.bars: |
| 184 | if lastkey != bar.key: |
| 185 | showkey = True |
| 186 | else: |
| 187 | showkey = False |
| 188 | if lasttime != bar.meter: |
| 189 | showtime = True |
| 190 | else: |
| 191 | showtime = False |
| 192 | result += from_Bar(bar, showkey, showtime) + " " |
| 193 | lastkey = bar.key |
| 194 | lasttime = bar.meter |
| 195 | return "{ %s}" % result |
| 196 | |
| 197 | |
| 198 | def from_Composition(composition): |
no test coverage detected