ValueError: Couldn't understand quantization scheme

While running the simple_polytempo.py example I get the following error:

from scamp import *

s = Session()

trumpet = s.new_part("trumpet")
trombone = s.new_part("trombone")


def trumpet_part(clock: Clock):
    while s.beat() < 3:
        trumpet.play_note(67, 1, 0.5)
    clock.set_rate_target(0.5, 6, duration_units="time")
    while s.beat() < 12:
        trumpet.play_note(67, 1, 0.5)


s.set_tempo_target(100, 9)
trumpet_clock = s.fork(trumpet_part)
trombone_based_performance = s.start_transcribing()
trumpet_based_performance = s.start_transcribing(clock=trumpet_clock)

while s.beat() < 12:
    trombone.play_note(60, 1, 1)

s.stop_transcribing(trombone_based_performance)
s.stop_transcribing(trumpet_based_performance)

trombone_based_performance.to_score("3/4", title="Trombone Clock").show_xml()
trumpet_based_performance.to_score("3/4", title="Trumpet Clock").show_xml()
Using preset Trumpet for trumpet
Using preset Trombone for trombone
Traceback (most recent call last):
  File "d:\MusicGeneration\scamp_source\scamp\examples\AssortedHaphazard\OldTutorialExamples\simple_polytempo.py", line 44, in <module>
    trombone_based_performance.to_score("3/4", title="Trombone Clock").show_xml()
  File ...\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\scamp\performance.py", line 1294, in to_score
    return Score.from_performance(
  File ...\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\scamp\score.py", line 872, in from_performance
    performance if quantization_scheme is None else performance.quantized(quantization_scheme),
  File ...\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\scamp\performance.py", line 1191, in quantized
    return Performance([part.quantized(quantization_scheme, onset_weighting=onset_weighting,
  File ...\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\scamp\performance.py", line 1191, in <listcomp>
    return Performance([part.quantized(quantization_scheme, onset_weighting=onset_weighting,
  File ....\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\scamp\performance.py", line 845, in quantized
    quantize_performance_part(copy, quantization_scheme, onset_weighting=onset_weighting,
  File .....\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\scamp\quantization.py", line 733, in quantize_performance_part
    raise ValueError("Couldn't understand quantization scheme.")
ValueError: Couldn't understand quantization scheme.

That’s an old version of the example (where did you get it?).

I’ve since changed it so that the first argument to to_score is a QuantizationScheme, and to set a time signature, you use the keyword argument time_signature:

trombone_based_performance.to_score(time_signature="3/4", title="Trombone Clock")

Hi Marc,

Thank you for your reply. I found the example here:

And also here in a few examples:

http://marcevanstein.com/Writings/Evanstein_MAT_Thesis_SCAMP.pdf
for example

# ---- setup code omitted for brevity ----
s.start_transcribing()
for _ in range(2): # loop twice
for pitch in [60, 64, 67, 72]:
dur = random.uniform(0.5, 1.5)
violin.play_note(pitch, 1, dur)
performance = s.stop_transcribing()
performance.to_score("3/4").show()

Thanks! I’m planning to turn that thesis into a journal article, so it’s good to know that it’s got out of date stuff in it.