Time Signatures

Example script (scamp): examples/Tutorial/07_time_signature.py

Download: 07_time_signature.py

Plays a simple C Major arpeggio, and generates notation for it in three different ways: - with a 3/8 time signature - with a 3/8 time signature for the first measure followed by 2/4 - with alternating 3/8 and 2/4 time signatures - with a list of bar lengths determining time signatures

Topics: Notation & engraving › Basics

Specify one time signature throughout
score
Specify a list of time signatures by measure
score
Alternate time signatures
score
Specify barline locations
score
from scamp import *

s = Session()
violin = s.new_part("Violin")

# begin recording (defaults to transcribing
# all instruments within the session)
s.start_transcribing()
for _ in range(4):
    for pitch in [60, 64, 67, 72]:
        violin.play_note(pitch, 1, 0.5)
        # stop the recording and save the recorded
        # note events as a performance

performance = s.stop_transcribing()
# quantize and convert the performance to a Score object and open it as a PDF,
# this time imposing a time signature of 3/8
performance.to_score(time_signature="3/8",
                     title="Specify one time signature throughout").show()

# a list is interpreted as a (non-repeating) sequence of time signatures
performance.to_score(time_signature=["3/8", "2/4"],
                     title="Specify a list of time signatures by measure").show()

# if a repeating sequence of time signatures is desires, end the list with "loop"
performance.to_score(time_signature=["3/8", "2/4", "loop"],
                     title="Alternate time signatures").show()

# Alternatively, bar line locations can be given and sensible time signatures will be selected
performance.to_score(bar_line_locations=[1.5, 3.5, 8],
                     title="Specify barline locations").show()