MCPcopy Create free account
hub / github.com/bspaans/python-mingus / from_Track

Function from_Track

mingus/extra/tablature.py:322–346  ·  view source on GitHub ↗

Convert a mingus.containers.Track object to an ASCII tablature string. 'tuning' should be set to a StringTuning object or to None to use the Track's tuning (or alternatively the default if the Track hasn't got its own tuning). 'string' and 'fret' attributes on Notes are taken into

(track, maxwidth=80, tuning=None)

Source from the content-addressed store, hash-verified

320
321
322def from_Track(track, maxwidth=80, tuning=None):
323 """Convert a mingus.containers.Track object to an ASCII tablature string.
324
325 'tuning' should be set to a StringTuning object or to None to use the
326 Track's tuning (or alternatively the default if the Track hasn't got its
327 own tuning).
328
329 'string' and 'fret' attributes on Notes are taken into account.
330 """
331 result = []
332 width = _get_width(maxwidth)
333 if not tuning:
334 tuning = track.get_tuning()
335 lastlen = 0
336 for bar in track:
337 r = from_Bar(bar, width, tuning, collapse=False)
338 barstart = r[1].find("||") + 2
339 if (len(r[0]) + lastlen) - barstart < maxwidth and result != []:
340 for i in range(1, len(r) + 1):
341 item = r[len(r) - i]
342 result[-i] += item[barstart:]
343 else:
344 result += ["", ""] + r
345 lastlen = len(result[-1])
346 return os.linesep.join(result)
347
348
349def from_Composition(composition, width=80):

Callers

nothing calls this directly

Calls 3

_get_widthFunction · 0.85
get_tuningMethod · 0.80
from_BarFunction · 0.70

Tested by

no test coverage detected