scamp.score.Score

class scamp.score.Score(parts: Sequence[Union[Staff, StaffGroup]] = None, title: str = None, composer: str = None, tempo_envelope: clockblocks.tempo_envelope.TempoEnvelope = None)[source]

Bases: scamp.score.ScoreComponent, scamp.score.ScoreContainer

Representation of a score in traditional western notation. Exportable as either LilyPond or MusicXML.

Parameters
  • parts – A list of parts represented by either StaffGroup or Staff objects

  • title – title to be used

  • composer – composer to be used

  • tempo_envelope – a TempoEnvelope function describing how the tempo changes over time

Variables
  • title – title to be used in the score

  • composer – composer to be written on the score

  • tempo_envelope – a TempoEnvelope function describing how the tempo changes over time

Methods

from_performance(performance[, …])

Builds a new Score from a Performance (list of note events in continuous time and pitch).

from_quantized_performance(performance[, …])

Constructs a new Score from an already quantized Performance.

length()

Length of this score in beats.

to_music_xml()

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)

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.

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])

Convert and print LilyPond code.

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()

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()

Convert this score component to its corresponding abjad component

to_abjad_lilypond_file()

Convert and wrap as a abjad.LilyPondFile object

to_lilypond([wrap_as_file])

Convert to LilyPond code.

Attributes

parts

List of parts (StaffGroup or Staff objects).

staves

List of all staves in this score, expanding out those inside of StaffGroups.

property parts

List of parts (StaffGroup or Staff objects).

property staves

List of all staves in this score, expanding out those inside of StaffGroups.

length() → float[source]

Length of this score in beats. (i.e. end beat of the last measure in any of the parts)

classmethod from_performance(performance: scamp.performance.Performance, quantization_scheme: scamp.quantization.QuantizationScheme = None, time_signature: Union[str, Sequence] = None, bar_line_locations: Sequence[float] = None, max_divisor: int = None, max_divisor_indigestibility: int = None, simplicity_preference: float = None, title: str = 'default', composer: str = 'default')scamp.score.Score[source]

Builds a new Score from a Performance (list of note events in continuous time and pitch). In the process, the music must be quantized, for which two different options are available: one can either pass a QuantizationScheme to the first argument, which is very flexible but rather verbose to create, or one can specify arguments such as time_signature and max_divisor directly.

Parameters
  • performance – The Performance object we are building the score from.

  • quantization_scheme – The quantization scheme to be used when converting this performance into a score. If this is defined, none of the other quantization-related arguments should be defined.

  • time_signature – the time signature to be used, represented as a string, e.g. “3/4”, or a tuple, e.g. (3, 2). Alternatively, a list of time signatures can be given. If this list ends in “loop”, then the pattern specified by the list will be looped. For example, [“4/4”, “2/4”, “3/4”, “loop”] will cause the fourth measure to be in “4/4”, the fifth in “2/4”, etc. If the list does not end in “loop”, all measures after the final time signature specified will continue to be in that time signature.

  • bar_line_locations – As an alternative to defining the time signatures, a list of numbers representing the bar line locations can be given. For instance, [4.5, 6.5, 8, 11] would result in bars of time signatures 9/8, 2/4, 3/8, and 3/4

  • max_divisor – The largest divisor that will be allowed to divide the beat.

  • max_divisor_indigestibility – Indigestibility, devised by composer Clarence Barlow, is a measure of the “primeness” of a beat divisor, and therefore of its complexity from the point of view of a performer. For instance, it is easier to divide a beat in 8 than in 7, even though 7 is a smaller number. See Clarence’s paper here: https://mat.ucsb.edu/Publications/Quantification_of_Harmony_and_Metre.pdf. By setting a max indigestibility, we can allow larger divisions of the beat, but only so long as they are easy ones. For instance, a max_divisor of 16 and a max_divisor_indigestibility of 8 would allow the beat to be divided in 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, and 16.

  • simplicity_preference – This defines the degree to which the quantizer will favor simple divisors. The higher the simplicity preference, the more precisely the notes have to fit for you to get a divisor like 7. Simplicity preference can range from 0 (in which case the divisor is chosen simply based on the lowest error) to infinity, with a typical value somewhere around 1.

  • title – Title of the piece to be printed on the score.

  • composer – Composer of the piece to be printed on the score.

Returns

the resulting Score object, which can then be rendered either as XML or LilyPond

classmethod from_quantized_performance(performance: scamp.performance.Performance, title: str = 'default', composer: str = 'default')scamp.score.Score[source]

Constructs a new Score from an already quantized Performance.

Parameters
  • performance – the quantized Performance to convert into a new score

  • title – title to give the score

  • composer – composer to put on the score

to_music_xml()pymusicxml.music_xml_objects.Score[source]

Convert this score component to its corresponding pymusicxml component

append(item: scamp.score.ScoreComponent) → None

Add a child ScoreComponent of the appropriate type

export_lilypond(file_path) → None

Convert and wrap as a LilyPond (.ly) file, and save to the given path.

Parameters

file_path – file path to save to

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.

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)scamp.score.ScoreComponent

Pop and return the child ScoreComponent at the given index.

print_lilypond(wrap_as_file=False) → None

Convert and print LilyPond code.

Parameters

wrap_as_file – if True, wraps this object up as a full LilyPond file, ready for compilation. If False, we just get the code for the component itself.

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() → None

Using the abjad.show command, generates and opens a PDF of the music represented by this component

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() → abjad.core.Component.Component

Convert this score component to its corresponding abjad component

to_abjad_lilypond_file() → abjad.lilypondfile.LilyPondFile.LilyPondFile

Convert and wrap as a abjad.LilyPondFile object

to_lilypond(wrap_as_file=False) → str

Convert to LilyPond code.

Parameters

wrap_as_file – if True, wraps this object up as a full LilyPond file, ready for compilation. If False, we just get the code for the component itself.

Returns

a string containing the LilyPond code