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

Class Composition

mingus/containers/composition.py:24–116  ·  view source on GitHub ↗

A composition object. The Composition class is a datastructure for working with Tracks. Composition can be stored together in Suites.

Source from the content-addressed store, hash-verified

22
23
24class Composition(object):
25
26 """A composition object.
27
28 The Composition class is a datastructure for working with Tracks.
29
30 Composition can be stored together in Suites.
31 """
32
33 title = "Untitled"
34 subtitle = ""
35 author = ""
36 email = ""
37 description = ""
38 tracks = []
39 selected_tracks = []
40
41 def __init__(self):
42 self.empty()
43
44 def empty(self):
45 """Remove all the tracks from this class."""
46 self.tracks = []
47
48 def reset(self):
49 """Reset the information in this class.
50
51 Remove the track and composer information.
52 """
53 self.empty()
54 self.set_title()
55 self.set_author()
56
57 def add_track(self, track):
58 """Add a track to the composition.
59
60 Raise an UnexpectedObjectError if the argument is not a
61 mingus.containers.Track object.
62 """
63 if not hasattr(track, "bars"):
64 raise UnexpectedObjectError(
65 "Unexpected object '%s', "
66 "expecting a mingus.containers.Track object" % track
67 )
68 self.tracks.append(track)
69 self.selected_tracks = [len(self.tracks) - 1]
70
71 def add_note(self, note):
72 """Add a note to the selected tracks.
73
74 Everything container.Track supports in __add__ is accepted.
75 """
76 for n in self.selected_tracks:
77 self.tracks[n] + note
78
79 def set_title(self, title="Untitled", subtitle=""):
80 """Set the title and subtitle of the piece."""
81 self.title = title

Callers 6

from_NoteFunction · 0.90
from_BarFunction · 0.90
from_TrackFunction · 0.90
MIDI_to_CompositionMethod · 0.90
setUpMethod · 0.90
test_compositionMethod · 0.85

Calls

no outgoing calls

Tested by 2

setUpMethod · 0.72
test_compositionMethod · 0.68