Initialise or return named buffer

buffer  symbol (name), number (duration)

Initialise or return a named buffer with a specific duration (defaults to 8 beats). Useful for working with the :record FX. If the buffer is requested with a different duration, then a new buffer will be initialised and the old one recycled.

Introduced in v3.0

Examples

# Example 1

buffer(:foo)
b = buffer(:foo)
puts b.duration 



# load a 8s buffer and name it :foo
# return cached buffer and bind it to b
#=> 8.0



# Example 2

buffer(:foo, 16)



# load a 16s buffer and name it :foo



# Example 3

use_bpm 120
buffer(:foo, 16)
                
                



 
# load a 8s buffer and name it :foo
# (this isn't 16s as the BPM has been
# doubled from the default of 60)



# Example 4

buffer(:foo)    
buffer(:foo, 8) 
buffer(:foo, 10)
buffer(:foo, 10)
buffer(:foo)    
buffer(:foo)    



# init a 8s buffer and name it :foo
# return cached 8s buffer (has the same duration)
# init a new 10s buffer and name it :foo
# return cached 10s buffer
# init a 8s buffer and name it :foo
# return cached 8s buffer (has the same duration)