Difference between revisions of "fix"

From TidalCycles userbase
Jump to: navigation, search
 
Line 2: Line 2:
 
[[Type signature|Type]]: <source inline>fix :: (ControlPattern -> ControlPattern) -> ControlPattern -> ControlPattern -> ControlPattern</source>
 
[[Type signature|Type]]: <source inline>fix :: (ControlPattern -> ControlPattern) -> ControlPattern -> ControlPattern -> ControlPattern</source>
  
The '''fix''' function applies another function to matching events in a pattern of controls. <source inline>fix</source> is [[contrast]] where the false-branching function is set to the identity function <source inline>id</source>.
+
The '''fix''' function applies another function to matching events in a pattern of controls. <source inline>fix</source> is [[contrast]] where the false-branching function is set to the identity <source inline>id</source>.
  
 
For example:
 
For example:
Line 14: Line 14:
 
You can be quite specific, for example <source inline>fix (hurry 2) (s "drum" # n "1")</source> to apply the function <source inline>hurry 2</source> to sample <source inline>1</source> of the <source inline>drum</source> sampleset, and leave the rest as they are.
 
You can be quite specific, for example <source inline>fix (hurry 2) (s "drum" # n "1")</source> to apply the function <source inline>hurry 2</source> to sample <source inline>1</source> of the <source inline>drum</source> sampleset, and leave the rest as they are.
  
'''See also: [[contrast]],[[unfix]]'''
+
= unfix =
 +
<source inline>unfix</source> is <source inline>fix</source> but only applies when the testing pattern is ''not'' a match.
 +
 
 +
'''See also: [[contrast]]'''
  
 
[[Category:Functions]]
 
[[Category:Functions]]
 
[[Category:Higher-order functions]]
 
[[Category:Higher-order functions]]
 
[[Category:Conditional Transformers]]
 
[[Category:Conditional Transformers]]

Latest revision as of 23:27, 24 December 2020

Type: fix :: (ControlPattern -> ControlPattern) -> ControlPattern -> ControlPattern -> ControlPattern

The fix function applies another function to matching events in a pattern of controls. fix is contrast where the false-branching function is set to the identity id.

For example:

d1 $ slow 2 $ fix (# crush 3) (n "[1,4]") $ n "0 1 2 3 4 5 6" # sound "arpy"

The above only adds the crush control when the n control is set to either 1 or 4.

You can be quite specific, for example fix (hurry 2) (s "drum" # n "1") to apply the function hurry 2 to sample 1 of the drum sampleset, and leave the rest as they are.

unfix

unfix is fix but only applies when the testing pattern is not a match.

See also: contrast