Difference between revisions of "Combining pattern structure"

From TidalCycles userbase
Jump to: navigation, search
(Marked this version for translation)
Line 1: Line 1:
 
<translate>
 
<translate>
 +
<!--T:1-->
 
'''This does not describe current behaviour - this is upcoming in version 1.0.0.'''
 
'''This does not describe current behaviour - this is upcoming in version 1.0.0.'''
  
 +
<!--T:2-->
 
A core feature of Tidal is the ease in which two patterns can be combined. This is changing a lot in the upcoming 1.0.0 version of Tidal. For example, these are two patterns being combined by adding together their elements:
 
A core feature of Tidal is the ease in which two patterns can be combined. This is changing a lot in the upcoming 1.0.0 version of Tidal. For example, these are two patterns being combined by adding together their elements:
  
 +
<!--T:3-->
 
<syntaxhighlight lang = "Haskell">
 
<syntaxhighlight lang = "Haskell">
 
"2 3" + "4 5 6"
 
"2 3" + "4 5 6"
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 +
<!--T:4-->
 
The two patterns line up over time like this:
 
The two patterns line up over time like this:
  
 +
<!--T:5-->
 
<pre>
 
<pre>
 
   |  2  |  3  |
 
   |  2  |  3  |
Line 15: Line 20:
 
</pre>
 
</pre>
  
 +
<!--T:6-->
 
Unlike in previous versions of Tidal, by default the structure now comes from _both sides_. This means you end up with _four_ events, because the 5 lines up both with the <syntaxhighlight lang="Haskell" inline>2</syntaxhighlight> and the <syntaxhighlight lang="Haskell" inline>3</syntaxhighlight>. So the result is equivalent to <syntaxhighlight lang="Haskell" inline>"6 [7 8] 9"</syntaxhighlight>:
 
Unlike in previous versions of Tidal, by default the structure now comes from _both sides_. This means you end up with _four_ events, because the 5 lines up both with the <syntaxhighlight lang="Haskell" inline>2</syntaxhighlight> and the <syntaxhighlight lang="Haskell" inline>3</syntaxhighlight>. So the result is equivalent to <syntaxhighlight lang="Haskell" inline>"6 [7 8] 9"</syntaxhighlight>:
  
 +
<!--T:7-->
 
<pre>
 
<pre>
 
   |  2  |  3  |
 
   |  2  |  3  |
Line 23: Line 30:
 
</pre>
 
</pre>
  
 +
<!--T:8-->
 
You can see that the event with the value of <syntaxhighlight lang="Haskell" inline>4</syntaxhighlight> fits in the event
 
You can see that the event with the value of <syntaxhighlight lang="Haskell" inline>4</syntaxhighlight> fits in the event
 
with value of <syntaxhighlight lang="Haskell" inline>2</syntaxhighlight>, so you get a new event equalling their sum <syntaxhighlight lang="Haskell" inline>6</syntaxhighlight>. You
 
with value of <syntaxhighlight lang="Haskell" inline>2</syntaxhighlight>, so you get a new event equalling their sum <syntaxhighlight lang="Haskell" inline>6</syntaxhighlight>. You
Line 29: Line 37:
 
value <syntaxhighlight lang="Haskell" inline>4</syntaxhighlight>.
 
value <syntaxhighlight lang="Haskell" inline>4</syntaxhighlight>.
  
 +
<!--T:9-->
 
Also see that the event with value <syntaxhighlight lang="Haskell" inline>5</syntaxhighlight> is cut in half, to create two,
 
Also see that the event with value <syntaxhighlight lang="Haskell" inline>5</syntaxhighlight> is cut in half, to create two,
 
shorter events. Half matches with the <syntaxhighlight lang="Haskell" inline>2</syntaxhighlight> event and the other half
 
shorter events. Half matches with the <syntaxhighlight lang="Haskell" inline>2</syntaxhighlight> event and the other half
Line 34: Line 43:
 
events comes from the intersections.
 
events comes from the intersections.
  
 +
<!--T:10-->
 
The fourth and final event comes from the intersection of <syntaxhighlight lang="Haskell" inline>3</syntaxhighlight> and <syntaxhighlight lang="Haskell" inline>6</syntaxhighlight>,
 
The fourth and final event comes from the intersection of <syntaxhighlight lang="Haskell" inline>3</syntaxhighlight> and <syntaxhighlight lang="Haskell" inline>6</syntaxhighlight>,
 
giving a value of <syntaxhighlight lang="Haskell" inline>9</syntaxhighlight>.
 
giving a value of <syntaxhighlight lang="Haskell" inline>9</syntaxhighlight>.
  
== Structure from the left ==
+
== Structure from the left == <!--T:11-->
  
 +
<!--T:12-->
 
The old behaviour was to take the structure from the left. You can
 
The old behaviour was to take the structure from the left. You can
 
still do this, but in this case using <syntaxhighlight lang="Haskell" inline>|+`.  
 
still do this, but in this case using <syntaxhighlight lang="Haskell" inline>|+`.  
  
 +
<!--T:13-->
 
For example:
 
For example:
  
 +
<!--T:14-->
 
<syntaxhighlight lang="Haskell">
 
<syntaxhighlight lang="Haskell">
 
"2 3" |+ "4 5 6"
 
"2 3" |+ "4 5 6"
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 +
<!--T:15-->
 
In the above example, you end up with structure from the first, leftmost pattern, like this:
 
In the above example, you end up with structure from the first, leftmost pattern, like this:
  
  
 +
<!--T:16-->
 
<pre>
 
<pre>
 
   |  2  |  3  |
 
   |  2  |  3  |
Line 57: Line 72:
 
</pre>
 
</pre>
  
 +
<!--T:17-->
 
You can see the structure comes from the <syntaxhighlight lang="Haskell" inline>2</syntaxhighlight> and <syntaxhighlight lang="Haskell" inline>3</syntaxhighlight>. <syntaxhighlight lang="Haskell" inline>2</syntaxhighlight> lines up
 
You can see the structure comes from the <syntaxhighlight lang="Haskell" inline>2</syntaxhighlight> and <syntaxhighlight lang="Haskell" inline>3</syntaxhighlight>. <syntaxhighlight lang="Haskell" inline>2</syntaxhighlight> lines up
 
with <syntaxhighlight lang="Haskell" inline>4</syntaxhighlight>, and the start of <syntaxhighlight lang="Haskell" inline>3</syntaxhighlight> is in <syntaxhighlight lang="Haskell" inline>5</syntaxhighlight>, so you end up with <syntaxhighlight lang="Haskell" inline>2+4=6</syntaxhighlight>
 
with <syntaxhighlight lang="Haskell" inline>4</syntaxhighlight>, and the start of <syntaxhighlight lang="Haskell" inline>3</syntaxhighlight> is in <syntaxhighlight lang="Haskell" inline>5</syntaxhighlight>, so you end up with <syntaxhighlight lang="Haskell" inline>2+4=6</syntaxhighlight>
 
and <syntaxhighlight lang="Haskell" inline>3+5=8</syntaxhighlight>.
 
and <syntaxhighlight lang="Haskell" inline>3+5=8</syntaxhighlight>.
  
== Structure from the right ==
+
== Structure from the right == <!--T:18-->
  
 +
<!--T:19-->
 
Likewise, you can take the structure from the right, with <syntaxhighlight lang="Haskell" inline>+|</syntaxhighlight>. So <syntaxhighlight lang="Haskell" inline>"2
 
Likewise, you can take the structure from the right, with <syntaxhighlight lang="Haskell" inline>+|</syntaxhighlight>. So <syntaxhighlight lang="Haskell" inline>"2
 
3" +| "4 5 6"</syntaxhighlight> looks like:
 
3" +| "4 5 6"</syntaxhighlight> looks like:
  
 +
<!--T:20-->
 
<pre>
 
<pre>
 
   |  2  |  3  |
 
   |  2  |  3  |
Line 72: Line 90:
 
</pre>
 
</pre>
  
== All the operators ==
+
== All the operators == <!--T:21-->
  
 +
<!--T:22-->
 
Note that <syntaxhighlight lang="Haskell" inline>+</syntaxhighlight> is actually an alias for <syntaxhighlight lang="Haskell" inline>|+|</syntaxhighlight>. So <syntaxhighlight lang="Haskell" inline>|+</syntaxhighlight> is to take the
 
Note that <syntaxhighlight lang="Haskell" inline>+</syntaxhighlight> is actually an alias for <syntaxhighlight lang="Haskell" inline>|+|</syntaxhighlight>. So <syntaxhighlight lang="Haskell" inline>|+</syntaxhighlight> is to take the
 
structure from the left, <syntaxhighlight lang="Haskell" inline>+|</syntaxhighlight> from the right, and <syntaxhighlight lang="Haskell" inline>|+|</syntaxhighlight> or <syntaxhighlight lang="Haskell" inline>+</syntaxhighlight> for
 
structure from the left, <syntaxhighlight lang="Haskell" inline>+|</syntaxhighlight> from the right, and <syntaxhighlight lang="Haskell" inline>|+|</syntaxhighlight> or <syntaxhighlight lang="Haskell" inline>+</syntaxhighlight> for
Line 79: Line 98:
 
structure:
 
structure:
  
 +
<!--T:23-->
 
{| class="wikitable"
 
{| class="wikitable"
 
! Function
 
! Function
Line 121: Line 141:
 
|}
 
|}
  
 +
<!--T:24-->
 
The last two are interesting, they let you only take values from one
 
The last two are interesting, they let you only take values from one
 
side. So for example you could take structure from the left, but
 
side. So for example you could take structure from the left, but
 
values from the right with <syntaxhighlight lang="Haskell" inline>|></syntaxhighlight>, for example:
 
values from the right with <syntaxhighlight lang="Haskell" inline>|></syntaxhighlight>, for example:
  
 +
<!--T:25-->
 
<pre>
 
<pre>
 
   |  2  |  3  |
 
   |  2  |  3  |
Line 131: Line 153:
 
</pre>
 
</pre>
  
 +
<!--T:26-->
 
This is very similar to how <syntaxhighlight lang="Haskell" inline>|+|</syntaxhighlight> used to work in the versions of tidal prior to 1.0.0 - it took structure from the left, but values from the right. Accordingly and <syntaxhighlight lang="Haskell" inline>#</syntaxhighlight> maintains this behaviour in the new tidal.
 
This is very similar to how <syntaxhighlight lang="Haskell" inline>|+|</syntaxhighlight> used to work in the versions of tidal prior to 1.0.0 - it took structure from the left, but values from the right. Accordingly and <syntaxhighlight lang="Haskell" inline>#</syntaxhighlight> maintains this behaviour in the new tidal.
 
</translate>
 
</translate>

Revision as of 14:40, 7 November 2018

This does not describe current behaviour - this is upcoming in version 1.0.0.

A core feature of Tidal is the ease in which two patterns can be combined. This is changing a lot in the upcoming 1.0.0 version of Tidal. For example, these are two patterns being combined by adding together their elements:

"2 3" + "4 5 6"

The two patterns line up over time like this:

  |  2  |  3  |
+ | 4 | 5 | 6 |

Unlike in previous versions of Tidal, by default the structure now comes from _both sides_. This means you end up with _four_ events, because the 5 lines up both with the 2 and the 3. So the result is equivalent to "6 [7 8] 9":

  |  2  |  3  |
+ | 4 | 5 | 6 |
= | 6 |7|8| 9 |

You can see that the event with the value of 4 fits in the event with value of 2, so you get a new event equalling their sum 6. You can see that the onset and duration is the interection, which in this case is just the onset and duration of the original event with the value 4.

Also see that the event with value 5 is cut in half, to create two, shorter events. Half matches with the 2 event and the other half matches with the 3 event. Again, the onset and duration of both events comes from the intersections.

The fourth and final event comes from the intersection of 3 and 6, giving a value of 9.

Structure from the left

The old behaviour was to take the structure from the left. You can still do this, but in this case using |+`. For example: <syntaxhighlight lang="Haskell"> "2 3" |+ "4 5 6"

In the above example, you end up with structure from the first, leftmost pattern, like this:


   |  2  |  3  |
|+ | 4 | 5 | 6 |
 = |  6  |  8  |

You can see the structure comes from the 2 and 3. 2 lines up with 4, and the start of 3 is in 5, so you end up with 2+4=6 and 3+5=8.

Structure from the right

Likewise, you can take the structure from the right, with +|. So "2 3" +| "4 5 6" looks like:

   |  2  |  3  |
+| | 4 | 5 | 6 |
 = | 6 | 7 | 9 |

All the operators

Note that + is actually an alias for |+|. So |+ is to take the structure from the left, +| from the right, and |+| or + for both. Here are all the basic operators you can use to combine structure:

Function Both Left Right
Add |+| (or +) |+ +|
Subtract |-| (or -) |- -|
Multiply |*| (or *) |* *|
Divide |/| (or /) |/ /|
Modulo |%| |% %|
Left values |<| |< <|
Right values |>| |> >|

The last two are interesting, they let you only take values from one side. So for example you could take structure from the left, but values from the right with |>, for example:

   |  2  |  3  |
|> | 4 | 5 | 6 |
 = |  4  |  5  |

This is very similar to how |+| used to work in the versions of tidal prior to 1.0.0 - it took structure from the left, but values from the right. Accordingly and # maintains this behaviour in the new tidal.