Translate

When getting and setting information into the Time State, it's possible to use more complex keys than basic symbols such as `:foo` and `:bar`. You can also use URL style strings called paths such as `"/foo/bar/baz"`. Once we start working with paths, we can then start taking advantage of Sonic Pi's sophisticated pattern matching system to `get` and `sync` with 'similar' rather than 'identical' paths. Let's take a look.
SourceTranslationState
1036
In the example above we set `:foo` to `1` which we did nothing with. We can actually get this value from the thread calling `sync`:
W przykładzie powyżej nadajemy `:foo` wartość `1` i nic z nią nie robimy. Możemy właściwie pobrać tę wartość wewnątrz wątku korzystając z `sync`:
1037
in_thread do
amp = sync :foo
sample :ambi_lunar_land, amp: amp
end
sleep 2
set :foo, 0.5
in_thread do
amp = sync :foo
sample :ambi_lunar_land, amp: amp
end
sleep 2
set :foo, 0.5
1038
Note that values that are passed through `set` and `cue` must be thread safe - i.e. immutable rings, numbers, symbols or frozen strings. Sonic Pi will throw an error if the value you are attempting to store in the Time State is not valid.
1039
10.3 Pattern Matching
1040
Pattern Matching
1041
When getting and setting information into the Time State, it's possible to use more complex keys than basic symbols such as `:foo` and `:bar`. You can also use URL style strings called paths such as `"/foo/bar/baz"`. Once we start working with paths, we can then start taking advantage of Sonic Pi's sophisticated pattern matching system to `get` and `sync` with 'similar' rather than 'identical' paths. Let's take a look.
When getting and setting information into the Time State, it's possible to use more complex keys than basic symbols such as `:foo` and `:bar`. You can also use URL style strings called paths such as `"/foo/bar/baz"`. Once we start working with paths, we can then start taking advantage of Sonic Pi's sophisticated pattern matching system to `get` and `sync` with 'similar' rather than 'identical' paths. Let's take a look.
1042
Match any path segment
1043
Let's assume we want to wait for the next event that has three path segments:
1044
sync "/*/*/*"
1045
This will match any Time State event with exactly three path segments, regardless of their names. For example:
1046
`cue "/foo/bar/baz"`
`cue "/foo/bar/baz"`

Loading…

Loading…

Glossary

Source Translation
Sonic Pi Sonic Pi
Sonic Pi Sonic Pi
Sonic Pi Sonic Pi
Sonic Pi - Info Sonic Pi - Info

Source information

Source string location
10.3-Pattern-Matching.md:5
Source string age
a year ago
Translation file
etc/doc/lang/sonic-pi-tutorial-pl.po, string 1041
String priority
Medium