# 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:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![oli](https://uzu.lurk.org/user_avatar/uzu.lurk.org/oli/32/2051_2.png) [@oli](https://uzu.lurk.org/u/oli)\
**Post date:** [1 May 2022 20:20 UTC](https://uzu.lurk.org/t/dynamic-manipulation-of-pattern-length-and-start-end-points/4040/1 "2022-05-01T20:20:31Z")

</div>

I feel like I'm missing something really obvious in the documentation, but here goes —

I'm interested in exploring the live manipulation of pattern length, pattern start/end points, and step durations within a pattern...something akin to Mark Fell's techniques. I've lately been having fun with `linger` and `trunc`, but I haven't found a way of dynamically playing just a subset of a pattern. I'm sure there are many ways of approaching this, but I feel like there was a function I came across once that would do exactly what I have in mind, I just haven't been able to dig it up.

Mods, feel free to merge this in a pre-existing topic.

---

<div class="post-metadata">

**Author:** ![cleary](https://uzu.lurk.org/user_avatar/uzu.lurk.org/cleary/32/177_2.png) [@cleary](https://uzu.lurk.org/u/cleary)\
**Post date:** [2 May 2022 03:54 UTC](https://uzu.lurk.org/t/dynamic-manipulation-of-pattern-length-and-start-end-points/4040/2 "2022-05-02T03:54:49Z")

</div>

`bite` ?

> The `bite` function allows you to slice each cycle into a given number of equal sized bits, and then pattern those bits by number. It's similar to `slice` , but is for slicing up patterns, rather than samples. The following slices the pattern into four bits, and then plays those bits in turn.

> **[Alteration | Tidal Cycles](https://tidalcycles.org/docs/reference/alteration/#bite)**
>
> This page will present you all the functions that can be used to manipulate and alter your patterns. Each function will be presented following the same model:

also possibly, [`chew`](https://tidalcycles.org/docs/reference/sampling/#chew)

---

<div class="post-metadata">

**Author:** ![oli](https://uzu.lurk.org/user_avatar/uzu.lurk.org/oli/32/2051_2.png) [@oli](https://uzu.lurk.org/u/oli)\
**Post date:** [2 May 2022 10:35 UTC](https://uzu.lurk.org/t/dynamic-manipulation-of-pattern-length-and-start-end-points/4040/3 "2022-05-02T10:35:13Z")

</div>

That looks perfect, thanks!

---

<div class="post-metadata">

**Author:** ![kit-christopher](https://uzu.lurk.org/user_avatar/uzu.lurk.org/kit-christopher/32/686_2.png) [@kit-christopher](https://uzu.lurk.org/u/kit-christopher)\
**Post date:** [2 May 2022 21:31 UTC](https://uzu.lurk.org/t/dynamic-manipulation-of-pattern-length-and-start-end-points/4040/4 "2022-05-02T21:31:56Z")

</div>

okay interesting, i actually never thought about this. i use `bite` a lot but i'm not sure it solves the "dynamic" aspect to this problem. we need to be able to offset the start/end points of a pattern without losing the pulse.

---

<div class="post-metadata">

**Author:** ![oli](https://uzu.lurk.org/user_avatar/uzu.lurk.org/oli/32/2051_2.png) [@oli](https://uzu.lurk.org/u/oli)\
**Post date:** [3 May 2022 14:06 UTC](https://uzu.lurk.org/t/dynamic-manipulation-of-pattern-length-and-start-end-points/4040/5 "2022-05-03T14:06:46Z")

</div>

Great point, and that’s my feeling after having played around with `bite` for a while last night. Perhaps this points to a challenge with having a global cps.

I love `linger` — maybe there's a future variation where you can simply loop a portion of a pattern with two arguments: one for the start point and one for the end.

Something like

```haskell
d1
$ linger (0.25, 0.5)
$ n "1 2 3 4 5 6 7 8"
# s "midi"

```

would just loop the following as many times as possible within a single cycle.

```haskell
$ n "3 4"

```

🤔

---

<div class="post-metadata">

**Author:** ![kit-christopher](https://uzu.lurk.org/user_avatar/uzu.lurk.org/kit-christopher/32/686_2.png) [@kit-christopher](https://uzu.lurk.org/u/kit-christopher)\
**Post date:** [3 May 2022 14:34 UTC](https://uzu.lurk.org/t/dynamic-manipulation-of-pattern-length-and-start-end-points/4040/6 "2022-05-03T14:34:54Z")

</div>

okay so i am thinking [`fit'`](https://userbase.tidalcycles.org/fit.html) might get us a little closer to this. it's not perfect (meaning it doesn't do exactly what i am envisioning) but it might have potential.

the first argument is how many cycles you want to apply the fitting to. in the example below i want one cycle that's running through 8 steps of a major scale.

the second argument gets us closer to this "dynamic" end-point. in the example i am telling it to only play six notes of the total eight notes before starting the pattern up again but it's not great because you can't pattern the values.

the third/fourth arguments are tricky because it kind of just needs to be a placeholder for the total steps in your looping sequence.

`d1 $ fit' 1 6 "[0 .. 7]" "[0 .. 7]" $ n (scale "major" "[0 .. 7]") # s "superpiano"`

i tried making a little custom function to build dynamic lists but this clearly exceeds my Haskell proficiency because i get an error ☹

`let step n x p = fit' 1 x "[1 .. (n - 1)]" "[1 .. (n - 1)]" $ p`

where `n` is the number of steps you want in your sequence and `x` is the dynamic end point (has to be less than or equal to `n`).

if anyone has suggestions on doing the math to create those dynamic lists, i'd love to know how!

---

<div class="post-metadata">

**Author:** ![kit-christopher](https://uzu.lurk.org/user_avatar/uzu.lurk.org/kit-christopher/32/686_2.png) [@kit-christopher](https://uzu.lurk.org/u/kit-christopher)\
**Post date:** [3 May 2022 14:48 UTC](https://uzu.lurk.org/t/dynamic-manipulation-of-pattern-length-and-start-end-points/4040/7 "2022-05-03T14:48:53Z")

</div>

> [@oli](#):
>
> `$ linger (0.25, 0.5)`

love this! maybe it's just as simple as that. would certainly be much easier to use compared to `fit'`, as well as dynamic since you can pattern the arcs.

---

<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:** [3 May 2022 19:33 UTC](https://uzu.lurk.org/t/dynamic-manipulation-of-pattern-length-and-start-end-points/4040/8 "2022-05-03T19:33:00Z")

</div>

There are good suggestions already for getting towards this, but in the end this is a tricky one. As tidal is quite oriented around cycles as a reference point, it's difficult to work really flexibly with steps. I've been learning Konnakol recently, which has really flexible approach to time, and gives an interesting perspective on this.

In strudel there is a nice 'reset'/'restart' function that I'll backport to tidal soon, that gets further, being able to reset to the start of a cycle or pattern in a really flexible way.

Longer term though, tidal's mininotation needs to evolve into a fully flexible, step-based representation. I have a plan to work on this over the summer.

---

<div class="post-metadata">

**Author:** ![oli](https://uzu.lurk.org/user_avatar/uzu.lurk.org/oli/32/2051_2.png) [@oli](https://uzu.lurk.org/u/oli)\
**Post date:** [3 May 2022 19:51 UTC](https://uzu.lurk.org/t/dynamic-manipulation-of-pattern-length-and-start-end-points/4040/9 "2022-05-03T19:51:03Z")

</div>

Very exciting stuff! Thanks for sharing.

---

<div class="post-metadata">

**Author:** ![kit-christopher](https://uzu.lurk.org/user_avatar/uzu.lurk.org/kit-christopher/32/686_2.png) [@kit-christopher](https://uzu.lurk.org/u/kit-christopher)\
**Post date:** [3 May 2022 20:41 UTC](https://uzu.lurk.org/t/dynamic-manipulation-of-pattern-length-and-start-end-points/4040/10 "2022-05-03T20:41:12Z")

</div>

wow, cool, i second this! something to look forward to!

---

<div class="post-metadata">

**Author:** ![mashaal](https://uzu.lurk.org/user_avatar/uzu.lurk.org/mashaal/32/2100_2.png) [@mashaal](https://uzu.lurk.org/u/mashaal)\
**Post date:** [8 May 2022 01:35 UTC](https://uzu.lurk.org/t/dynamic-manipulation-of-pattern-length-and-start-end-points/4040/11 "2022-05-08T01:35:30Z")

</div>

yes please

---

<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:** [10 May 2022 12:49 UTC](https://uzu.lurk.org/t/dynamic-manipulation-of-pattern-length-and-start-end-points/4040/12 "2022-05-10T12:49:05Z")

</div>

You can do this using `zoom`  
[https://tidalcycles.org/docs/patternlib/tour/time/#zoom](https://tidalcycles.org/docs/patternlib/tour/time/#zoom)

this automatically adjusts how fast the events are occuring, so if you would want to have a function more similar to linger you could do:

```haskell
lingerAt :: (Time, Time) -> Pattern a -> Pattern a
lingerAt a@(t1,t2) p = slow (pure $ t2 - t1) $ zoom a p

```

---

<div class="post-metadata">

**Author:** ![kit-christopher](https://uzu.lurk.org/user_avatar/uzu.lurk.org/kit-christopher/32/686_2.png) [@kit-christopher](https://uzu.lurk.org/u/kit-christopher)\
**Post date:** [11 May 2022 16:17 UTC](https://uzu.lurk.org/t/dynamic-manipulation-of-pattern-length-and-start-end-points/4040/13 "2022-05-11T16:17:15Z")

</div>

> [@polymorphic.engine](#):
>
> ```haskell
> lingerAt :: (Time, Time) -> Pattern a -> Pattern a
> lingerAt a@(t1,t2) p = slow (pure $ t2 - t1) $ zoom a p
> 
> ```

this is sick.

THANK YOU 🙏

---

<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:** [13 May 2022 10:43 UTC](https://uzu.lurk.org/t/dynamic-manipulation-of-pattern-length-and-start-end-points/4040/14 "2022-05-13T10:43:16Z")

</div>

maybe `lingerIn` would be a better name when I think about it 🙂

would also cool to extend it to the signature

`lingerIn :: (Pattern Time, Pattern Time) -> Pattern a -> Pattern a`

I'll look into that

---

<div class="post-metadata">

**Author:** ![kit-christopher](https://uzu.lurk.org/user_avatar/uzu.lurk.org/kit-christopher/32/686_2.png) [@kit-christopher](https://uzu.lurk.org/u/kit-christopher)\
**Post date:** [13 May 2022 11:33 UTC](https://uzu.lurk.org/t/dynamic-manipulation-of-pattern-length-and-start-end-points/4040/15 "2022-05-13T11:33:36Z")

</div>

> [@polymorphic.engine](#):
>
> lingerIn :: (Pattern Time, Pattern Time) -\> Pattern a -\> Pattern a

yes, that would be lovely as well. if i recall, the so-called "arc" functions can be tricky to make patternable?

---

<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:** [13 May 2022 15:09 UTC](https://uzu.lurk.org/t/dynamic-manipulation-of-pattern-length-and-start-end-points/4040/16 "2022-05-13T15:09:42Z")

</div>

> [@kit-christopher](#):
>
> if i recall, the so-called "arc" functions can be tricky to make patternable?

i've never thought about it before but I came up with this:

```haskell
tParamTup :: ((a,b) -> c -> Pattern d) -> (Pattern a, Pattern b) -> c -> Pattern d
tParamTup f = uncurry $ tParam2 $ curry f
zoom' = tParamTup zoom

```

it seems to work, but I'd be grateful if you could test it aswell.

If it works, I think it should definitely be included in standard tidal and all similar functions that are not patternable yet should be made patternable 🙂

I've only more recently been realising how powerful it is to pattern **everything**

---

<div class="post-metadata">

**Author:** ![kit-christopher](https://uzu.lurk.org/user_avatar/uzu.lurk.org/kit-christopher/32/686_2.png) [@kit-christopher](https://uzu.lurk.org/u/kit-christopher)\
**Post date:** [13 May 2022 15:33 UTC](https://uzu.lurk.org/t/dynamic-manipulation-of-pattern-length-and-start-end-points/4040/17 "2022-05-13T15:33:22Z")

</div>

> [@polymorphic.engine](#):
>
> ```haskell
> tParamTup :: ((a,b) -> c -> Pattern d) -> (Pattern a, Pattern b) -> c -> Pattern d
> tParamTup f = uncurry $ tParam2 $ curry f
> zoom' = tParamTup zoom
> 
> ```

this is working great! wow, major progress -- thank you!

`d1 $ someCycles (zoom' ("<0.25 0.5>", "<0.75 1>")) $ n (scale "major" "[0 .. 7]") # s "superpiano"`

works the way i would imagine it to.

i tried modifying your original `lingerAt` function to include the new `zoom'` but am getting an error:

```haskell
lingerAt :: (Time, Time) -> Pattern a -> Pattern a
lingerAt a@(t1,t2) p = slow (pure $ t2 - t1) $ zoom' a p

```

- Couldn't match type `Ratio Integer' with `Pattern Time'  
Expected type: (Pattern Time, Pattern Time)  
Actual type: (Time, Time)
  - In the first argument of zoom', namely `a' In the second argument of `($)', namely `zoom' a p'  
In the expression: slow (pure $ t2 - t1) $ zoom' a p

---

<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:** [13 May 2022 15:55 UTC](https://uzu.lurk.org/t/dynamic-manipulation-of-pattern-length-and-start-end-points/4040/18 "2022-05-13T15:55:27Z")

</div>

> [@kit-christopher](#):
>
> i tried modifying your original `lingerAt` function to include the new `zoom'` but am getting an error:

you need to modify it a little:

```haskell
lingerIn :: (Pattern Time, Pattern Time) -> Pattern a -> Pattern a
lingerIn a@(t1,t2) p = slow (t2 - t1) $ zoom' a p

```

thanks for testing!

---

<div class="post-metadata">

**Author:** ![kit-christopher](https://uzu.lurk.org/user_avatar/uzu.lurk.org/kit-christopher/32/686_2.png) [@kit-christopher](https://uzu.lurk.org/u/kit-christopher)\
**Post date:** [13 May 2022 16:00 UTC](https://uzu.lurk.org/t/dynamic-manipulation-of-pattern-length-and-start-end-points/4040/19 "2022-05-13T16:00:08Z")

</div>

so far so good! 😍

---

<div class="post-metadata">

**Author:** ![ndr\_brt](https://uzu.lurk.org/user_avatar/uzu.lurk.org/ndr_brt/32/396_2.png) [@ndr\_brt](https://uzu.lurk.org/u/ndr_brt)\
**Post date:** [14 May 2022 05:42 UTC](https://uzu.lurk.org/t/dynamic-manipulation-of-pattern-length-and-start-end-points/4040/20 "2022-05-14T05:42:58Z")

</div>

Just great, the only issue I faced is that if the first parameter (for all the 3 functions) is not zero, it does not sound, e.g.:

this sounds

```haskell
d1 $ lingerIn ("0", (segment 8 $ slow 4 sine)) $ s "numbers"

```

this don't

```haskell
d1 $ lingerIn ("0.1", (segment 8 $ slow 4 sine)) $ s "numbers"

```

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