scamp.score.Measure
- class scamp.score.Measure(voices: Sequence[Voice], time_signature: TimeSignature, show_time_signature: bool = True, clef: Optional[str] = None)[source]
Bases:
ScoreComponent
,ScoreContainer
Representation of a single measure within in a Staff
- Parameters:
voices – list of voices in this measure, in numbered order
time_signature – the time signature for this measure
show_time_signature – whether or not to show the time signature. By default, when scamp is turning a quantized Performance into a Score, this will be set to true when the time signature changes and False otherwise.
clef – Which clef to use for the measure. If none, clef is left unspecified.
- Variables:
time_signature – the time signature for this measure
show_time_signature – Whether or not to display the time signature
clef – Which clef to use for the measure. If none, clef is left unspecified.
Methods
empty_measure
(time_signature[, ...])Constructs an empty measure (one voice with a bar rest)
from_list_of_performance_voices
(voices_list, ...)Constructs a Measure for a specially formatted list of voices
get_appropriate_clef
(clef_choices)Length of the part of this measure that has something in it.
to_music_xml
([source_id_dict])Convert this score component to its corresponding pymusicxml component
Inherited Methods
append
(item)Add a child ScoreComponent of the appropriate type
export_lilypond
(file_path[, non_score_blocks])Convert and wrap as a LilyPond (.ly) file, and save to the given path.
export_music_xml
(file_path[, pretty_print])Convert and wrap as a MusicXML score, and save to the given path.
export_pdf
(file_path[, non_score_blocks])Exports score as a PDF file and saves it to the given file_path
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.
print_lilypond
([wrap_as_file, non_score_blocks])Convert and print LilyPond code, via the abjad library.
print_music_xml
([pretty_print])Convert and wrap as a MusicXML score, and print the resulting XML.
remove
(item)Remove the given child ScoreComponent.
show
([non_score_blocks])Using the abjad.show command, generates and opens a PDF of the music represented by this component
show_xml
()Convert and wrap as a MusicXML score, and open it up in notation software.
to_abjad
([wrap_as_file, non_score_blocks])Convert this score component to its corresponding abjad component
to_lilypond
([wrap_as_file, non_score_blocks])Convert to LilyPond code, via the abjad library.
Attributes
Length of this measure in quarter notes
List of Voices within this measure, in numbered order
- property length: float
Length of this measure in quarter notes
- non_empty_length() float [source]
Length of the part of this measure that has something in it. (i.e. the length not counting trailing rests that aren’t part of a tuplet)
- classmethod empty_measure(time_signature: TimeSignature, show_time_signature: bool = True) Measure [source]
Constructs an empty measure (one voice with a bar rest)
- Parameters:
time_signature – the time signature for this measure
show_time_signature – Whether or not to display the time signature
- classmethod from_list_of_performance_voices(voices_list, time_signature: TimeSignature, show_time_signature: bool = True) Measure [source]
Constructs a Measure for a specially formatted list of voices
- Parameters:
voices_list – list consisting of elements each of which is either: - a (list of PerformanceNotes, measure quantization record) tuple for an active voice - None, for an empty voice
time_signature – the time signature for this measure
show_time_signature – Whether or not to display the time signature
- to_music_xml(source_id_dict=None) Measure [source]
Convert this score component to its corresponding pymusicxml component
- append(item: ScoreComponent) None
Add a child ScoreComponent of the appropriate type
- export_lilypond(file_path: str, non_score_blocks: Optional[Sequence] = None, **lilypond_file_args) None
Convert and wrap as a LilyPond (.ly) file, and save to the given path.
- Parameters:
file_path – file path to save to
non_score_blocks – a list of
abjad.Block
objects (or strings containing the LilyPond code for such a block, which are then parsed by abjad); typical blocks might be a header block, a layout block, or a paper block. If no header block is specified, one will be created with the score’s title and composer. If a header is specified, title and composer will be added if not present.lilypond_file_args – any additional keyword arguments will be passed along to the constructor of
abjad.LilyPondFile
(assuming wrap_as_file is True). This allows for setting staff size and various other customizations.
- export_music_xml(file_path: str, pretty_print: bool = True) None
Convert and wrap as a MusicXML score, and save to the given path.
- Parameters:
file_path – file path to save to
pretty_print – whether or not to take the extra space and format the file with indentations, etc.
- export_pdf(file_path: str, non_score_blocks: Optional[Sequence] = None, **lilypond_file_args) None
Exports score as a PDF file and saves it to the given file_path
- Parameters:
file_path – where to save the PDF
non_score_blocks – a list of
abjad.Block
objects (or strings containing the LilyPond code for such a block, which are then parsed by abjad); typical blocks might be a header block, a layout block, or a paper block. If no header block is specified, one will be created with the score’s title and composer. If a header is specified, title and composer will be added if not present.lilypond_file_args – any additional keyword arguments will be passed along to the constructor of
abjad.LilyPondFile
(assuming wrap_as_file is True). This allows for setting staff size and various other customizations.
- extend(items) None
Add several child ScoreComponents of the appropriate type
- index(item) int
Get the index of the given child ScoreComponent
- insert(index, item) None
Insert a child ScoreComponent at the given index.
- pop(i=-1) ScoreComponent
Pop and return the child ScoreComponent at the given index.
- print_lilypond(wrap_as_file: bool = False, non_score_blocks: Optional[Sequence] = None, **lilypond_file_args) None
Convert and print LilyPond code, via the abjad library.
- Parameters:
wrap_as_file – if True, wraps this as an
abjad.LilypondFile
non_score_blocks – (Only applicable if wrap_as_file is set to True). A list of
abjad.Block
objects (or strings containing the LilyPond code for such a block, which are then parsed by abjad). Typical blocks might be a header block, a layout block, or a paper block. If no header block is specified, one will be created with the score’s title and composer. If a header is specified, title and composer will be added if not present.lilypond_file_args – any additional keyword arguments will be passed along to the constructor of
abjad.LilyPondFile
(assuming wrap_as_file is True). This allows for setting staff size and various other customizations.
- print_music_xml(pretty_print: bool = True) None
Convert and wrap as a MusicXML score, and print the resulting XML.
- Parameters:
pretty_print – whether or not to take the extra space and format the file with indentations, etc.
- remove(item) None
Remove the given child ScoreComponent.
- show(non_score_blocks: Optional[Sequence] = None, **lilypond_file_args) None
Using the abjad.show command, generates and opens a PDF of the music represented by this component
- Parameters:
non_score_blocks – a list of
abjad.Block
objects (or strings containing the LilyPond code for such a block, which are then parsed by abjad); typical blocks might be a header block, a layout block, or a paper block. If no header block is specified, one will be created with the score’s title and composer. If a header is specified, title and composer will be added if not present.lilypond_file_args – any additional keyword arguments will be passed along to the constructor of
abjad.LilyPondFile
(assuming wrap_as_file is True). This allows for setting staff size and various other customizations.
- show_xml() None
Convert and wrap as a MusicXML score, and open it up in notation software. (The software to use is defined in engraving_settings.show_music_xml_command_line.)
- to_abjad(wrap_as_file: bool = False, non_score_blocks: Optional[Sequence] = None, **lilypond_file_args) Component
Convert this score component to its corresponding abjad component
- Parameters:
wrap_as_file – if True, wraps this as an
abjad.LilypondFile
non_score_blocks – (Only applicable if wrap_as_file is set to True). A list of
abjad.Block
objects (or strings containing the LilyPond code for such a block, which are then parsed by abjad). Typical blocks might be a header block, a layout block, or a paper block. If no header block is specified, one will be created with the score’s title and composer. If a header is specified, title and composer will be added if not present.lilypond_file_args – any additional keyword arguments will be passed along to the constructor of
abjad.LilyPondFile
(assuming wrap_as_file is True). This allows for setting staff size and various other customizations.
- to_lilypond(wrap_as_file: bool = False, non_score_blocks: Optional[Sequence] = None, **lilypond_file_args) str
Convert to LilyPond code, via the abjad library.
- Parameters:
wrap_as_file – if True, wraps this as an
abjad.LilypondFile
non_score_blocks – (Only applicable if wrap_as_file is set to True). A list of
abjad.Block
objects (or strings containing the LilyPond code for such a block, which are then parsed by abjad). Typical blocks might be a header block, a layout block, or a paper block. If no header block is specified, one will be created with the score’s title and composer. If a header is specified, title and composer will be added if not present.lilypond_file_args – any additional keyword arguments will be passed along to the constructor of
abjad.LilyPondFile
(assuming wrap_as_file is True). This allows for setting staff size and various other customizations.
- Returns:
a string containing the LilyPond code