Checking current time


#1

Hi all,

I’d like to have Sonic Pi play something different based on the time of day (for example, if the time is between 12am and 1pm, play loop A, between 1pm and 2 pm, play loop B, etc). Is there a way to access the current date/time in sonic pi? Or alternatively, the time since sonic pi was launched?

Thanks for any help!!


#2

Hi there,

nice question. You can always access time with:

Time.now

You can then convert that to a number to use as a random seed with:

Time.now.to_i

Hope that this helps :slight_smile: