Difference between revisions of "within"

From TidalCycles userbase
Jump to: navigation, search
(Marked this version for translation)
 
Line 1: Line 1:
 
<translate>
 
<translate>
 +
<!--T:1-->
 
{{DISPLAYTITLE:within}}
 
{{DISPLAYTITLE:within}}
 
{{Type|<source inline>within :: Arc -> (Pattern a -> Pattern a) -> Pattern a -> Pattern a</source>}}
 
{{Type|<source inline>within :: Arc -> (Pattern a -> Pattern a) -> Pattern a -> Pattern a</source>}}
  
 +
<!--T:2-->
 
Use '''within''' to apply a function to only a part of a pattern. '''within''' takes two arguments: a start time and an end time, specified as floats between 0 and 1, which are applied to the relevant pattern. Note that the second argument must be greater than the first for the function to have any effect.
 
Use '''within''' to apply a function to only a part of a pattern. '''within''' takes two arguments: a start time and an end time, specified as floats between 0 and 1, which are applied to the relevant pattern. Note that the second argument must be greater than the first for the function to have any effect.
  
 +
<!--T:3-->
 
For example, to apply <source inline>fast 2</source> to only the first half of a pattern:
 
For example, to apply <source inline>fast 2</source> to only the first half of a pattern:
  
 +
<!--T:4-->
 
<source>
 
<source>
 
d1 $ within (0, 0.5) (fast 2) $ sound "bd*2 sn lt mt hh hh hh hh"
 
d1 $ within (0, 0.5) (fast 2) $ sound "bd*2 sn lt mt hh hh hh hh"
 
</source>
 
</source>
  
 +
<!--T:5-->
 
Or, to apply <source inline>(# speed "0.5")</source> to only the last quarter of a pattern:
 
Or, to apply <source inline>(# speed "0.5")</source> to only the last quarter of a pattern:
  
 +
<!--T:6-->
 
<source>
 
<source>
 
d1 $ within (0.75, 1) (# speed "0.5") $ sound "bd*2 sn lt mt hh hh hh hh"
 
d1 $ within (0.75, 1) (# speed "0.5") $ sound "bd*2 sn lt mt hh hh hh hh"
 
</source>
 
</source>
  
 +
<!--T:7-->
 
[[Category:Functions]]
 
[[Category:Functions]]
 
[[Category:Higher-order functions]]
 
[[Category:Higher-order functions]]
  
 
</translate>
 
</translate>

Latest revision as of 01:49, 19 November 2019

Type: within :: Arc -> (Pattern a -> Pattern a) -> Pattern a -> Pattern a

Use within to apply a function to only a part of a pattern. within takes two arguments: a start time and an end time, specified as floats between 0 and 1, which are applied to the relevant pattern. Note that the second argument must be greater than the first for the function to have any effect.

For example, to apply fast 2 to only the first half of a pattern:

d1 $ within (0, 0.5) (fast 2) $ sound "bd*2 sn lt mt hh hh hh hh"

Or, to apply (# speed "0.5") to only the last quarter of a pattern:

d1 $ within (0.75, 1) (# speed "0.5") $ sound "bd*2 sn lt mt hh hh hh hh"