# Dynamic manipulation of pattern length (and start/end points)

**URL:** <https://uzu.lurk.org/t/dynamic-manipulation-of-pattern-length-and-start-end-points/4040>\
**Category:** Uncategorized\
**Created:** [1 May 2022 20:20 UTC](https://uzu.lurk.org/t/dynamic-manipulation-of-pattern-length-and-start-end-points/4040 "2022-05-01T20:20:31Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![lannzach](https://uzu.lurk.org/user_avatar/uzu.lurk.org/lannzach/32/3519_2.png) [@lannzach](https://uzu.lurk.org/u/lannzach)\
**Post date:** [20 May 2022 23:52 UTC](https://uzu.lurk.org/t/dynamic-manipulation-of-pattern-length-and-start-end-points/4040/21 "2022-05-20T23:52:44Z")

</div>

I'm thinking there might need to be two fixes. First, add `abs` to the definition of lingerIn as follows:  
`lingerIn :: (Pattern Time, Pattern Time) -> Pattern a -> Pattern a`  
`lingerIn a@(t1,t2) p = slow (abs (t2 - t1)) $ zoom' a p`

However, there also will likely need to be a function that adjusts the Arc to prevent "negative" spans, so to speak...for example, lingerIn (0.75,0) n "c5" takes place in the arc between 0.75 and 0, which would be a reversed Arc. I don't know the helper functions for this kind of thing, but I imagine they exist.

Edit: Just realized this doesn't address what you mention @ndr_brt, but I wonder if it is due to a similar issue.

---

<div class="post-metadata">

**Author:** ![yaxu](https://uzu.lurk.org/user_avatar/uzu.lurk.org/yaxu/32/2_2.png) [@yaxu](https://uzu.lurk.org/u/yaxu)\
**Post date:** [21 May 2022 19:39 UTC](https://uzu.lurk.org/t/dynamic-manipulation-of-pattern-length-and-start-end-points/4040/22 "2022-05-21T19:39:40Z")

</div>

Strudel has an interesting approach to this called `reset`:

The original pattern is 'reset' at the start of each event in the pattern on the right.

It would be good to backport this to tidal!

---

<div class="post-metadata">

**Author:** ![polymorphic.engine](https://uzu.lurk.org/user_avatar/uzu.lurk.org/polymorphic.engine/32/30_2.png) [@polymorphic.engine](https://uzu.lurk.org/u/polymorphic.engine)\
**Post date:** [23 May 2022 14:57 UTC](https://uzu.lurk.org/t/dynamic-manipulation-of-pattern-length-and-start-end-points/4040/23 "2022-05-23T14:57:04Z")

</div>

I tried some things and came up with this:

```haskell
let
eventStart = withEvent (\e -> e {value = 1 - wholeStart e})
rotL' = tParam rotL
reset b p = (rotL' $ eventStart b) p

d1 $ (reset ("t*4" :: Pattern Bool)) (n "0 1 2 3" # s "arpy")

```

which seems to work at least for some basic examples that i've tried..  
the type signature should probably be fixed to `Pattern Bool -> Pattern a -> Pattern a`, so one doesn't have to be verbose with the types

I wanted to ask you @yaxu why `rotL` isn't lifted to the pattern level yet (as i did above). Are there any cases where that would break things / result in unexpected behaviour? I tested it a little bit and although it has a very complex behaviour when patterned it seems to do what it should

---

<div class="post-metadata">

**Author:** ![yaxu](https://uzu.lurk.org/user_avatar/uzu.lurk.org/yaxu/32/2_2.png) [@yaxu](https://uzu.lurk.org/u/yaxu)\
**Post date:** [23 May 2022 15:32 UTC](https://uzu.lurk.org/t/dynamic-manipulation-of-pattern-length-and-start-end-points/4040/24 "2022-05-23T15:32:44Z")

</div>

> [@polymorphic.engine](#):
>
> I wanted to ask you @yaxu why `rotL` isn't lifted to the pattern level yet (as i did above). Are there any cases where that would break things / result in unexpected behaviour? I tested it a little bit and although it has a very complex behaviour when patterned it seems to do what it should

I think the operators `<~` `~>` are patterned, and `rotL` and `rotR` are kind of internal functions, that aren't patterned out of efficiency. But I have also found that they're useful as plain functions too.. Due to the heavy use of $ in Tidal, `<~` and `~>` often need some brackets to get them to work.

Javascript doesn't allow custom or overloaded operators at all, so everything is a function or method there. These functions are called `early` and `late` which I think is a bit friendlier than `rotL` and `rotR`, maybe we should backport these names too?

---

<div class="post-metadata">

**Author:** ![polymorphic.engine](https://uzu.lurk.org/user_avatar/uzu.lurk.org/polymorphic.engine/32/30_2.png) [@polymorphic.engine](https://uzu.lurk.org/u/polymorphic.engine)\
**Post date:** [23 May 2022 15:55 UTC](https://uzu.lurk.org/t/dynamic-manipulation-of-pattern-length-and-start-end-points/4040/25 "2022-05-23T15:55:16Z")

</div>

ahh!

> [@yaxu](#):
>
> maybe we should backport these names too?

yes, I think that would be nice, I think I prefer those names over `rotL` and `rotR`

so maybe keep `rotL` and `rotR` for internal things and add `early` and `late` as prefix versions of `~>` and `<~` ?

---

<div class="post-metadata">

**Author:** ![yaxu](https://uzu.lurk.org/user_avatar/uzu.lurk.org/yaxu/32/2_2.png) [@yaxu](https://uzu.lurk.org/u/yaxu)\
**Post date:** [23 May 2022 20:55 UTC](https://uzu.lurk.org/t/dynamic-manipulation-of-pattern-length-and-start-end-points/4040/26 "2022-05-23T20:55:45Z")

</div>

Sounds good!

[Previous page](https://uzu.lurk.org/t/dynamic-manipulation-of-pattern-length-and-start-end-points/4040.md?page=1)
