I edited this post, because I asked why the notes didn’t turn off, but then I realize it was because you can’t have blocking=False in the last line.
But how would/could you do this?
In other words, at the end of my composition, I wanted to have a cello play a note for 1.0 counts, and at the same time have a piano play four 16th notes (0.25 x 4).
In order for the cello to play while the piano notes play, you need to have a blocking=False
statement for the cello.
But, as you also found out, the cello note never turns off.
Can anyone explain:
(1) Why isn’t the note turning off (we gave it a set duration of 1.0 sec)? Why is using blocking=False
at the end any different than somewhere else in the script?
(2) Is there a way to tell SCAMP to turn off all sound?
Thanks!
David Collett
Seattle
Hi David,
You’re using Thonny, right? It’s actually a quirk of using Thonny that is keeps the Python interpreter alive when the script is done, which means that when the script ends abruptly notes are left hanging. When you run the script directly, SCAMP detects when the python interpreter is exiting and ends the notes that are left over.
Anyway, you can call
cello.end_all_notes()
at the end of the script, which should fix the issue.
Thanks, Marc. I’ll try that.
What do you mean, “When you run the script directly…?”
I’m using Thonny and just pressing the Run button each time.
How do we run it “directly” and what’s the difference?
Thanks!
David
Running it from a command line, like this:
> python my_script.py