Get information from the Time State

get  time_state_key (default)

Retrieve information from Time State set prior to the current time from either the current or any other thread. If called multiple times will always return the same value unless a call to sleep, sync, set or cue is interleaved. Also, calls to get will always return the same value across Runs for deterministic behaviour - which means you may safely use it in your compositions for repeatable music. If no value is stored with the relevant key, will return nil.

May be used within a time_warp to retrieve past events. If in a time warp, get can not be called from a future position. Does not advance time.

Introduced in v3.0

Examples

# Example 1

get :foo



#=> returns the last value set as :foo, or nil



# Example 2

set :foo, 3
get[:foo]



 
#=> returns 3



# Example 3

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



 
 
 
 
#=> always returns 3 (no race conditions here!)