scamp.score.ScoreContainer
- class scamp.score.ScoreContainer(contents: Sequence[ScoreComponent], contents_argument_name: str, allowable_child_types: Union[Type, tuple[Type, ...]], extra_field_names=())[source]
Bases:
ABC
Abstract class representing a ScoreComponent that contains other components. (e.g. A Measure contains Voices)
- Parameters:
contents – the ScoreComponents contained within this container
contents_argument_name – name of the property that fetches the contents. E.g. a score should have “parts”, and a Staff should have “measures”. The class should define that property and point it to self._contents. This is basically just used in __repr__ so that we don’t have to implement it separately for each subclass.
allowable_child_types – Type or list of types that should be allowed as child components. For instance, a Score can have Staff and StaffGroup children; a Measure can only have Voices.
extra_field_names – again this is basically just used in __repr__ so that we don’t have to implement it separately for each subclass.
Methods
append
(item)Add a child ScoreComponent of the appropriate type
extend
(items)Add several child ScoreComponents of the appropriate type
index
(item)Get the index of the given child ScoreComponent
insert
(index, item)Insert a child ScoreComponent at the given index.
pop
([i])Pop and return the child ScoreComponent at the given index.
remove
(item)Remove the given child ScoreComponent.
- append(item: ScoreComponent) None [source]
Add a child ScoreComponent of the appropriate type
- pop(i=-1) ScoreComponent [source]
Pop and return the child ScoreComponent at the given index.