If I understand correctly, you’re trying to get it to play the notes sequentially (as a melody) after every user input? As you’ve discovered, the system of clocks does not expect to be paused unexpectedly for input, which is why it clips notes afterward, since it checks the time and thinks it’s way behind schedule.
The correct approach is to use run_as_server()
, but then also to wrap the melody in a function and fork
it. That way it has its own time stream, and the notes can block as expected:
session = Session().run_as_server()
...
answer = None
while answer != "quit":
answer = None
...
def play_melody():
for note in notes:
piano.play_note(note, 1.0, 1.0)
session.fork(play_melody)
answer = input("Interval: ").lower()