Scheduling Instruments to play in the future

Sorry for the newbie question. I’m currently an undergrad learning FoxDot.

I’m writing a script in Python that emulates the structure of a song (verse, bridge etc). I want to schedule an instrument to play after a certain amount of beats but can’t figure it out. I have tried:

`Clock.schedule(myfunction, Clock.now() + 2)’

but it just plays from beat number 1. Is there a way to schedule an instrument that starts to play at a specific time in code? Thanks in advance.

Can you share the script, or at least the contents of myfunction? If you run

print(Clock.now())
Clock.schedule(lambda: print(Clock.now()), Clock.now() + 4)

Does it print the current beat, then 4 beats later print that beat plus 4?

There is a utility method for scheduling things in the future relative to the current time if you are interested, called Clock.future - the first argument is the number of beats to schedule in the future, then the callable and any arguments:

Clock.future(4, lambda: print(Clock.now()))

1 Like

Thanks for this, Ryan. It’s hugely appreciated.