I am back again with a question (after almost an year)
I am implementing a App UI for my PyCarnatic trying to mimic the UI to my Java implementation.
Is it possible to pause, resume and stop the Session while playing?
–Sundar With Regards
Hi Sundar! Sorry for replying so slowly.
At the moment, there isn’t exactly a way to do this, although I’m planning to rewrite the clocks system over the coming months, and I’ll try to make this possible.
That said, I’m wondering if your goal is to create multiple scores that each start from beat 0? If so, this can be accomplished by recording different transcriptions. For example:
import random import time from scamp import * s = Session().run_as_server() piano = s.new_part("piano") def some_music(): for _ in range(6): piano.play_note(random.randint(60, 70), 1.0, random.choice([0.5, 1.0, 1.5])) while True: # wait some random length of time time.sleep(random.uniform(1, 3)) s.fork(some_music) s.start_transcribing() time.sleep(8) performance = s.stop_transcribing() performance.to_score().show()
This uses a session that’s running as a server, and forks a function that plays some music intermittently, with random waits in between. This is trying to mimic a GUI situation in which an unknown amount of time passes between user interaction. After forking the music, we call
s.start_transcribing(), wait 8 seconds (enough for it to finish) and then call
s.stop_transcribing() and turn it into a score. The transcription measures time from the
start_transcribing call, not from the beginning of the session.
(BTW, I found a little bug here when making this example. If you call
fork, the timing gets off. I’ve fixed the bug and will push it in the next release.)
Sorry for delay in responding.
I tried wrapping my player (that calls session, fork) with threading.Thread, threading.Event().wait(), threading.Event().set(), threading.Event().clear().
It didnt work. May be because Session itself is a thread.
Sundar With Regards