Difference between revisions of "sometimes"

From TidalCycles userbase
Jump to: navigation, search
m (Yaxu moved page Sometimes to Xometimes without leaving a redirect)
(Marked this version for translation)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
<languages/>
 +
<translate>
 +
<!--T:1-->
 
{{DISPLAYTITLE:sometimes}}  
 
{{DISPLAYTITLE:sometimes}}  
 
''See also: [[someCycles]]''
 
''See also: [[someCycles]]''
  
 +
<!--T:2-->
 
[[Type signature|Type]]: <syntaxhighlight lang="haskell" inline>sometimes :: (Pattern a -> Pattern a) -> Pattern a -> Pattern a</syntaxhighlight>
 
[[Type signature|Type]]: <syntaxhighlight lang="haskell" inline>sometimes :: (Pattern a -> Pattern a) -> Pattern a -> Pattern a</syntaxhighlight>
  
 +
<!--T:3-->
 
'''sometimes''' is function, that applies another function to a pattern, around 50% of the time, at random. It takes two inputs, the function to be applied, and the pattern you are applying it to.  
 
'''sometimes''' is function, that applies another function to a pattern, around 50% of the time, at random. It takes two inputs, the function to be applied, and the pattern you are applying it to.  
  
 +
<!--T:4-->
 
For example to distort half the events in a pattern:
 
For example to distort half the events in a pattern:
  
 +
<!--T:5-->
 
<syntaxhighlight lang="haskell">
 
<syntaxhighlight lang="haskell">
 
d1 $ sometimes (# crush 2) $ n "0 1 [~ 2] 3" # sound "arpy"
 
d1 $ sometimes (# crush 2) $ n "0 1 [~ 2] 3" # sound "arpy"
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 +
<!--T:6-->
 
sometimes has a number of variants, which apply the function with different likelihood.
 
sometimes has a number of variants, which apply the function with different likelihood.
  
 +
<!--T:7-->
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
Line 33: Line 42:
 
|}
 
|}
  
= sometimesBy =
+
= sometimesBy = <!--T:8-->
  
 +
<!--T:9-->
 
If you want to be specific, you can use <syntaxhighlight lang="haskell" inline>sometimesBy</syntaxHighlight> and a number, for example <syntaxhighlight lang="haskell">sometimesBy 0.93 (# speed 2)</syntaxhighlight> to apply the <syntaxhighlight lang="haskell" inline>speed</syntaxhighlight> control on average 93 times out of a hundred.
 
If you want to be specific, you can use <syntaxhighlight lang="haskell" inline>sometimesBy</syntaxHighlight> and a number, for example <syntaxhighlight lang="haskell">sometimesBy 0.93 (# speed 2)</syntaxhighlight> to apply the <syntaxhighlight lang="haskell" inline>speed</syntaxhighlight> control on average 93 times out of a hundred.
  
  
 +
<!--T:10-->
 
[[Category:Functions]] [[Category:Higher-order functions]] [[Category:Randomness and chance]] [[Category:Conditional Transformers]]
 
[[Category:Functions]] [[Category:Higher-order functions]] [[Category:Randomness and chance]] [[Category:Conditional Transformers]]
 +
</translate>

Latest revision as of 23:02, 17 December 2019

Other languages:
English • ‎français

See also: someCycles

Type: sometimes :: (Pattern a -> Pattern a) -> Pattern a -> Pattern a

sometimes is function, that applies another function to a pattern, around 50% of the time, at random. It takes two inputs, the function to be applied, and the pattern you are applying it to.

For example to distort half the events in a pattern:

d1 $ sometimes (# crush 2) $ n "0 1 [~ 2] 3" # sound "arpy"

sometimes has a number of variants, which apply the function with different likelihood.

function likelihood
always 100%
almostAlways 90%
often 75%
sometimes 50%
rarely 25%
almostNever 10%
never 0%

sometimesBy

If you want to be specific, you can use sometimesBy and a number, for example

sometimesBy 0.93 (# speed 2)

to apply the speed control on average 93 times out of a hundred.