In response to a question you asked yesterday (not via the forum) about how to make the notation look a little better, take a look at this:
from scamp import *
import random
s = Session().run_as_server()
piano = s.new_part("piano")
answer = input("Interval: ").lower()
s.start_transcribing()
while answer != "q":
def play_melody():
start_pitch = random.randint(40, 80)
piano.play_note(start_pitch, 1.0, 1.0)
piano.play_note(start_pitch + int(answer), 1.0, 1.0)
s.fork(play_melody, schedule_at=MetricPhaseTarget(0))
answer = input("Interval: ").lower()
s.stop_transcribing().to_score().show()
Of course, this is simpler than what you’ve been creating — I just made it play whatever half-step interval the user types as an integer. But the important part is s.fork(play_melody, schedule_at=MetricPhaseTarget(0))
. The metric phase target of 0 causes it to delay until the start of the beat before playing, which makes the notation turn out nicer.
It’s not a perfect solution, of course, since it creates a little delay sometimes, but it’s workable. The better solution would be to be able to pause and restart transcribing, and I think I can add that functionality to SCAMP fairly easily when I have a moment.