setScoreStruct

maelzel.core.workspace.setScoreStruct(score=None, timesig=None, tempo=None)[source]

Sets the current score structure

If given a ScoreStruct, it sets it as the active score structure. As an alternative a score structure as string can be given, or simply a time signature and/or tempo, in which case it will create the ScoreStruct and set it as active

Parameters:
  • score (Union[str, ScoreStruct, None]) – the scorestruct as a ScoreStruct or a string score (see ScoreStruct for more information about the format). If None, a simple ScoreStruct using the given time-signature and/or tempo will be created

  • timesig (Union[tuple[int, int], str, None]) – only used if no score is given.

  • tempo (Optional[int]) – the quarter-note tempo. Only used if no score is given

Return type:

None

See also

  • getScoreStruct()

  • setTempo() (modifies the tempo of the active scorestruct)

  • ScoreStruct

  • getWorkspace()

Example

>>> from maelzel.core import *
>>> setScoreStruct(ScoreStruct(tempo=72))
>>> setScoreStruct(r'''
... 4/4, 72
... 3/8
... 5/4
... .         # Same time-signature and tempo
... , 112     # Same time-signature, faster tempo
... 20, 3/4, 60   # At measure index 20, set the time-signature to 3/4 and tempo to 60
... ...       # Endless score
... ''')