scamp.score.Tuplet

class scamp.score.Tuplet(tuplet_divisions: int, normal_divisions: int, division_length: float, contents: Sequence[NoteLike] = None)[source]

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

Representation of a Tuplet object within a single voice of music. Reads as: tuplet_divisions in the space of normal_divisions of division_length e.g. 7, 4, and 0.25 would mean ‘7 in the space of 4 sixteenth notes’

Parameters
  • tuplet_divisions – The new number that the tuplet is divided into

  • normal_divisions – the normal number of divisions of division_length that would fill the time

  • division_length – length in quarter notes of the tuplet note type

  • contents – List of NoteLike objects (notes and rests) contained in this tuplet

Variables
  • tuplet_divisions – The new number that the tuplet is divided into

  • normal_divisions – the normal number of divisions of division_length that would fill the time

  • division_length – length in quarter notes of the tuplet note type

Methods

dilation_factor()

Factor by which the amount of “room” in the tuplet is expanded.

from_length_and_divisor(length, divisor)

Constructs and returns the appropriate tuplet from the length and the divisor.

length()

The actual length, in quarter notes, of the tuplet from the outside.

length_within_tuplet()

The length, in quarter notes, of the tuplet from the inside.

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)

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

contents

List of NoteLike objects (notes and rests) contained in this tuplet

classmethod from_length_and_divisor(length: float, divisor: int) → Optional[scamp.score.Tuplet][source]

Constructs and returns the appropriate tuplet from the length and the divisor. Returns None if no tuplet needed.

Parameters
  • length – length of the beat in quarters

  • divisor – divisor for the beat

Returns

a Tuplet, or None

property contents

List of NoteLike objects (notes and rests) contained in this tuplet

dilation_factor() → float[source]

Factor by which the amount of “room” in the tuplet is expanded. E.g. in a tripet, this factor is 3/2, since you can fit 3/2 as much stuff in there.

length() → float[source]

The actual length, in quarter notes, of the tuplet from the outside.

length_within_tuplet() → float[source]

The length, in quarter notes, of the tuplet from the inside.

to_music_xml(source_id_dict=None)pymusicxml.music_xml_objects.Tuplet[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