# Making stut a part of a pattern

**URL:** <https://uzu.lurk.org/t/making-stut-a-part-of-a-pattern/3331>\
**Category:** Uncategorized\
**Created:** [17 July 2021 23:13 UTC](https://uzu.lurk.org/t/making-stut-a-part-of-a-pattern/3331 "2021-07-17T23:13:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Terumi](https://uzu.lurk.org/user_avatar/uzu.lurk.org/terumi/32/1589_2.png) [@Terumi](https://uzu.lurk.org/u/Terumi)\
**Post date:** [17 July 2021 23:13 UTC](https://uzu.lurk.org/t/making-stut-a-part-of-a-pattern/3331/1 "2021-07-17T23:13:58Z")

</div>

Hello people,  
I have this pattern

```haskell
d1 $ fast 1
    $ stut 4 0.5 0.1
    $ sound "bd [[bd, cp] ~ ~ <cp ~ >]"
    # gain "1"

```

And I want to have only the first part of the cycle to stat (only the kick drum).  
From what I can deduct, I need to make "stut" a part of a pattern maybe?  
How can this be achieved?

---

<div class="post-metadata">

**Author:** ![crashingbooth](https://uzu.lurk.org/user_avatar/uzu.lurk.org/crashingbooth/32/1619_2.png) [@crashingbooth](https://uzu.lurk.org/u/crashingbooth)\
**Post date:** [18 July 2021 02:33 UTC](https://uzu.lurk.org/t/making-stut-a-part-of-a-pattern/3331/2 "2021-07-18T02:33:43Z")

</div>

You can use `while` with a binary pattern to apply a function to only a part of a pattern. With the binary pattern "10", the function will apply just to the first half:

```haskell
d1 $ while "10" (stut 4 0.5 0.1)
   $ sound "bd [[bd, cp] ~ ~ <cp ~ >]"

```

---

<div class="post-metadata">

**Author:** ![Terumi](https://uzu.lurk.org/user_avatar/uzu.lurk.org/terumi/32/1589_2.png) [@Terumi](https://uzu.lurk.org/u/Terumi)\
**Post date:** [18 July 2021 10:27 UTC](https://uzu.lurk.org/t/making-stut-a-part-of-a-pattern/3331/3 "2021-07-18T10:27:56Z")

</div>

Thank you!

There is a strange thing happening though,

```haskell
d1 $ while "1 0" (stut 8 0.5 0.15)
            $ sound "bd cp"
        

```

The clap sound is getting stuted as well.  
When I use 4 stuts, it sounds ok, but when the duration of the effect overlaps with the other sounds timing, the other sounds get stuted as well.  
Do I do something wrong or is this expected behaviour?

---

<div class="post-metadata">

**Author:** ![crashingbooth](https://uzu.lurk.org/user_avatar/uzu.lurk.org/crashingbooth/32/1619_2.png) [@crashingbooth](https://uzu.lurk.org/u/crashingbooth)\
**Post date:** [18 July 2021 11:02 UTC](https://uzu.lurk.org/t/making-stut-a-part-of-a-pattern/3331/4 "2021-07-18T11:02:47Z")

</div>

Interesting - seems like unexpected behaviour to me.

---

<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:** [18 July 2021 11:47 UTC](https://uzu.lurk.org/t/making-stut-a-part-of-a-pattern/3331/5 "2021-07-18T11:47:51Z")

</div>

Try the `linger` function

---

<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:** [18 July 2021 13:50 UTC](https://uzu.lurk.org/t/making-stut-a-part-of-a-pattern/3331/6 "2021-07-18T13:50:33Z")

</div>

> [@Terumi](#):
>
> The clap sound is getting stuted as well.  
> When I use 4 stuts, it sounds ok, but when the duration of the effect overlaps with the other sounds timing, the other sounds get stuted as well.  
> Do I do something wrong or is this expected behaviour?

Yes this is expected in a way - `while` switches between the `stut`tered and the non-`stut`tered version of the pattern. So you get the tail of the stuttered clap, and miss the tail of the stuttered bd.

You can define a version of `while` that does what you want:

```haskell
while' pb f pat = overlay (f $ mask pb pat) (mask (inv pb) pat)

```

It sounds better:

```haskell
d1 $ while' "1 0" (stut 8 0.5 0.15) $ sound "bd cp"

```

Maybe there are times where you want the existing behaviour, though..

We could put both options in tidal, but I'm not sure what we should call them. One is selecting which events get the function applied, and the other is switching between the changed and original patterns.

I am tempted to change the current definition of `while` to the behaviour that's needed here, but not sure..

---

<div class="post-metadata">

**Author:** ![Terumi](https://uzu.lurk.org/user_avatar/uzu.lurk.org/terumi/32/1589_2.png) [@Terumi](https://uzu.lurk.org/u/Terumi)\
**Post date:** [18 July 2021 21:39 UTC](https://uzu.lurk.org/t/making-stut-a-part-of-a-pattern/3331/7 "2021-07-18T21:39:18Z")

</div>

I don't know if it is possible in haskel, but a fourth optional, boolean, parameter in while (called overlap maybe) would be neat. 🙂
