Difference between revisions of "Combining pattern structure"

From TidalCycles userbase
Jump to: navigation, search
Line 5: Line 5:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 +
In 'old' Tidal, when combining two patterns, "structure always comes from the left". In the new tidal, you can choose where the structure comes from.
  
In old Tidal, when combining two patterns, "structure always comes
+
For example:
from the left". In the new tidal, you can choose where the structure comes from.
 
  
For example:
+
<syntaxhighlight lang = "Haskell">
```
 
 
"2 3" + "4 5 6"
 
"2 3" + "4 5 6"
```
+
</syntaxhighlight>
  
 
These two patterns line up like this:
 
These two patterns line up like this:

Revision as of 11:24, 7 November 2018

    • This does not describe current behaviour - this is upcoming in version 1.0.0.**
d1 $ sound "bd sn"

In 'old' Tidal, when combining two patterns, "structure always comes from the left". In the new tidal, you can choose where the structure comes from.

For example:

"2 3" + "4 5 6"

These two patterns line up like this:

``` | 2 | 3 | | 4 | 5 | 6 | ```

Now by default, the structure comes from _both sides_, so you end up with _four_ events. I've shown the four events below:

```

 |  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`.

    1. 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:

``` "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`.

    1. 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 |

```

    1. 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 `|+|`/`+` `|+` `+|` Multiply `|*|`/`*` `|*` `*|` Subtract `|-|`/`-` `|-` `-|` Divide `|/|`/`/` `|/` `/|` 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 |

= |  2  |  9  |

```

This is actually how `#` works in the current tidal.