Store information in the Time State

set  time_state_key (default), value (anything)

Store information in the Time State for the current time for either the current or any other thread. If called multiple times without an intervening call to sleep, sync, set or cue, the last value set will prevail. The value will remain in the Time State until overwritten by another call to set, or until Sonic Pi quits.

May be used within a time_warp to set past/future events. Does not affect time.

Introduced in v3.0

Examples

# Example 1

set :foo, 1



#=> Stores the value 1 with key :foo



# Example 2

set :foo, 3 
get[:foo]



# Set :foo to 3
#=> returns 3



# Example 3

in_thread do
  set :foo, 3 
end
in_thread do
  puts get[:foo] 
end



 
# Set :foo to 3
 
 
#=> always returns 3 (no race conditions here!)