Free a sample on the synth server
sample_free path (string)
Frees the memory and resources consumed by loading the sample on the server. Subsequent calls to sample
and friends will re-load the sample on the server.
You may also specify the same set of source and filter pre-args available to sample
itself. sample_free
will then free all matching samples. See sample
’s docs for more information.
Introduced in v2.9
Examples
# Example 1 |
sample :loop_amen
sleep 2
sample :loop_amen
sleep 2
sample_free :loop_amen
sample :loop_amen
|
# The Amen break is now loaded into memory and played
# The Amen break is not loaded but played from memory
# The Amen break is freed from memory
# the Amen break is re-loaded and played
|
# Example 2 |
puts sample_info(:loop_amen).to_i
puts sample_info(:loop_amen).to_i
sample_free :loop_amen
puts sample_info(:loop_amen).to_i
|
# This returns the buffer id of the sample i.e. 1
# The buffer id remains constant whilst the sample
# is loaded in memory
# The Amen break is re-loaded and gets a *new* id.
|
# Example 3 |
sample :loop_amen
sample :ambi_lunar_land
sleep 2
sample_free :loop_amen, :ambi_lunar_land
sample :loop_amen
sample :ambi_lunar_land
|
# re-loads and plays amen
# re-loads and plays lunar land
|
# Example 4 |
dir = "/path/to/sample/dir"
sample_free dir
sample_free dir, 1
sample_free dir, :foo
sample_free dir, /[Bb]ar/
|
# Using source and filter pre-args
# frees any loaded samples in "/path/to/sample/dir"
# frees sample with index 1 in "/path/to/sample/dir"
# frees sample with name "foo" in "/path/to/sample/dir"
# frees sample which matches regex /[Bb]ar/ in "/path/to/sample/dir"
|