# What are the part and the whole in an Event?

**URL:** <https://uzu.lurk.org/t/what-are-the-part-and-the-whole-in-an-event/4414>\
**Category:** TidalCycles\
**Tags:** innards\
**Created:** [23 November 2022 01:55 UTC](https://uzu.lurk.org/t/what-are-the-part-and-the-whole-in-an-event/4414 "2022-11-23T01:55:21Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeff\_Brown](https://uzu.lurk.org/user_avatar/uzu.lurk.org/jeff_brown/32/2033_2.png) [@Jeff\_Brown](https://uzu.lurk.org/u/Jeff_Brown)\
**Post date:** [23 November 2022 01:55 UTC](https://uzu.lurk.org/t/what-are-the-part-and-the-whole-in-an-event/4414/1 "2022-11-23T01:55:21Z")

</div>

First I'll review a little background, then I'll ask my questions.

# Background

The `EventF` type looks like this:

```haskell
data EventF a b
  = Event { context :: Context,
            whole :: Maybe a,
            part :: a,
            value :: b}
  	-- Defined at src/Sound/Tidal/Pattern.hs:619:1

```

That's a little more abstract than we need for this discussion. Most of the `EventF`s we work with are `Event`s:

```haskell
type Event a = EventF (ArcF Time) a
  	-- Defined at src/Sound/Tidal/Pattern.hs:627:1

```

And an `ArcF Time` is just a pair of `Time`s representing an interval. Thus every `Event` carries at least two and maybe four `Time` values: WHen the `part` starts and stops, and maybe when the `whole` starts and stops. Since the `whole` is optional, I'm guessing the `part` is what determines the duration of the `Event`.

# My questions

Am I correct that the `part` is what determiens the duration of the `Event`?  
What is the meaning of the `whole`?  
Why, when, and how should I use `whole`s?  
Why can `whole` be missing sometimes?  
When do otherwise-identical `Event`s with differrent `whole`s behave differently?

---

<div class="post-metadata">

**Author:** ![archaic.tech](https://uzu.lurk.org/user_avatar/uzu.lurk.org/archaic.tech/32/2965_2.png) [@archaic.tech](https://uzu.lurk.org/u/archaic.tech)\
**Post date:** [24 November 2022 16:29 UTC](https://uzu.lurk.org/t/what-are-the-part-and-the-whole-in-an-event/4414/2 "2022-11-24T16:29:37Z")

</div>

I can take a crack at this, and I welcome others' additions if I'm missing anything!

`Event`s are the result of querying a `Pattern` for a specific time range, and it's useful to think of any `Event` in relation to a specific query.

As an example, if you take the pattern `"bd*4" :: Pattern String` and query it for the timespan `Arc 0 1/8`, you'll get an event corresponding to the first half of the first "bd" symbol. Ignoring `context`, the resulting `Event` would be:

```haskell
Event { whole=(Arc 0 1/4), part=(Arc 0 1/8), value="bd" }

```

So, the `part` is whatever portion of the event is active within the queried time, while the `whole` is the theoretical span of the entire event. If I'm not mistaken, the `part` is always the intersection of the `whole` arc and the `query` arc.

The algorithm for sending events to SuperDirt depends a lot on the interplay between `part` and `whole`. As an example of events with different `whole`s (per your last question), take the pattern `stack [s "bd", s "bd*2"]`. If you query for span `Arc 1/2 3/4`, you'll get the following two events:

```haskell
[
 Event { whole=(Arc 0 1), part=(Arc 1/2 3/4), value=({s: "bd"}) },
 Event { whole=(Arc 1/2 1), part(Arc 1/2 3/4), value=({s: "bd"}) }
]

```

When sending these events to SuperDirt, Tidal would ignore the first one (because its `whole` begins outside of the active `part`), but would send the second one (because its `whole` begins within its `part`), using the span of the `whole` to calculate the duration of the sample (sent to SuperDirt as `delta`).

`whole` is optional, because some patterns (such as `sine`) are continuous, and so they only produce discrete events when you query them. Basically `whole=Nothing` implies a partial event whose full duration is infinite. In practice, these analog patterns get turned into patterns of discrete events (through functions such as `segment`), and the [way they behave is somewhat undefined](https://github.com/tidalcycles/Tidal/issues/806#issuecomment-831578194).

---

<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:** [24 November 2022 16:36 UTC](https://uzu.lurk.org/t/what-are-the-part-and-the-whole-in-an-event/4414/3 "2022-11-24T16:36:32Z")

</div>

Hi Jeff!

I've been considering renaming 'part' to 'active' to make this a little bit clearer.

> Am I correct that the `part` is what determines the duration of the `Event`?

It depends what you mean by duration. If you want to know how long to play a note for, you'd probably use the whole.

> What is the meaning of the `whole`?

'whole' is the arc or timespan of the event. 'part' is the timespan of the event that is active.

The 'part' will always be contained within the 'whole'.

> Why, when, and how should I use `whole`s?

If they are not the same, i.e. if the part is smaller than the whole, then we can say that the event is a fragment. This can happen if you e.g. have an event that takes up a whole cycle, but you query for only part of that cycle. It can also happen with a lot of transformations, events can be chopped up into fragments.

> Why can `whole` be missing sometimes?

Events that come from continuous signals don't have wholes.

> When do otherwise-identical `Event`s with differrent `whole`s behave differently?

If the onset is missing, i.e if the part starts later than the whole, then that event won't trigger a sound.

---

<div class="post-metadata">

**Author:** ![Jeff\_Brown](https://uzu.lurk.org/user_avatar/uzu.lurk.org/jeff_brown/32/2033_2.png) [@Jeff\_Brown](https://uzu.lurk.org/u/Jeff_Brown)\
**Post date:** [24 November 2022 18:49 UTC](https://uzu.lurk.org/t/what-are-the-part-and-the-whole-in-an-event/4414/4 "2022-11-24T18:49:06Z")

</div>

Thank you both! I'm starting to see it. As a result I have more questions.

Is the following true? The `whole` indicates the duration of the experience the `Event` is a window onto, the `part` is the duration of that window, and the `part` is always the intersection of the query arc and the `whole`.

Is the following true? When SuperDirt receives an `Event`, if the `Event` is a sample, it will only trigger the sample if the `part` beins no later than the `whole`.

What if SuperDirt receives an `Event` that is not a sample, but is instead a tail of a note to be played on a synthesizer? Will SuperDirt similarly ignore the entire `Event` because its `part` starts after its `whole`? (I can see why you might not want to start a sample in the middle -- you'd get a pop, for one thing -- but maybe synth notes are different.)

Is the `whole` optional _only_ in the case of continuous, conceptually-infinite signals like sine?

Last, it seems like `whole` only matters for `Event`s containing instructions to SuperDirt. Suppose, for instance, I've got a pattern of transformations that SuperDirt will never receive. It's got two `Event`s: From 0 to 1/2 the transformation is `fast 2`, and from 1/2 to 1 the transformation is `identity`. Suppose I query it from 0 to 1/4. The "right" result would be an `Event` with a payload of `fast 2`, a `part` from 0 to 1/4, and a `whole` from 0 to 1/2. In this case it's hard for me to imagine the `whole` having any downstream effect. Right?

> I've been considering renaming 'part' to 'active' to make this a little bit clearer.

Now that I've read your explanations the names actually seem pretty good to me. ("whole" and "fragment" also seem like good candidates.) What's missing is a nice detailed comment at the definition of `Event`. Once I've got all these questions ironed out I'll be happy to write one.

---

<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:** [24 November 2022 20:57 UTC](https://uzu.lurk.org/t/what-are-the-part-and-the-whole-in-an-event/4414/5 "2022-11-24T20:57:09Z")

</div>

> [@Jeff\_Brown](#):
>
> Is the following true? The `whole` indicates the duration of the experience the `Event` is a window onto, the `part` is the duration of that window, and the `part` is always the intersection of the query arc and the `whole`.

Not always, consider:

```haskell
ghci> "2" |+ "1 ~"
(0>½)-1|3

```

By adding a longer event to a shorter one, we ended up with a fragment of the longer event. For the event in the first cycle, the part is 0-0.5, the whole is 0-1.

> [@Jeff\_Brown](#):
>
> Is the following true? When SuperDirt receives an `Event`, if the `Event` is a sample, it will only trigger the sample if the `part` beins no later than the `whole`.

Tidal doesn't send a trigger message to superdirt in the first place, if the part begins later, because it doesn't have an 'onset'.

> [@Jeff\_Brown](#):
>
> What if SuperDirt receives an `Event` that is not a sample, but is instead a tail of a note to be played on a synthesizer? Will SuperDirt similarly ignore the entire `Event` because its `part` starts after its `whole`? (I can see why you might not want to start a sample in the middle -- you'd get a pop, for one thing -- but maybe synth notes are different.)

Superdirt doesn't know about parts. You can tell it to start halfway and finish early using the start/end parameters though.

> [@Jeff\_Brown](#):
>
> Is the `whole` optional _only_ in the case of continuous, conceptually-infinite signals like sine?

That's right. They don't get sent to superdirt either.

> [@Jeff\_Brown](#):
>
> Last, it seems like `whole` only matters for `Event`s containing instructions to SuperDirt. Suppose, for instance, I've got a pattern of transformations that SuperDirt will never receive. It's got two `Event`s: From 0 to 1/2 the transformation is `fast 2`, and from 1/2 to 1 the transformation is `identity`. Suppose I query it from 0 to 1/4. The "right" result would be an `Event` with a payload of `fast 2`, a `part` from 0 to 1/4, and a `whole` from 0 to 1/2. In this case it's hard for me to imagine the `whole` having any downstream effect. Right?

Yes I guess it's mainly useful for knowing whether an event should create a trigger message, and for how long the event should play (if `legato` is on)

---

<div class="post-metadata">

**Author:** ![Jeff\_Brown](https://uzu.lurk.org/user_avatar/uzu.lurk.org/jeff_brown/32/2033_2.png) [@Jeff\_Brown](https://uzu.lurk.org/u/Jeff_Brown)\
**Post date:** [25 November 2022 00:10 UTC](https://uzu.lurk.org/t/what-are-the-part-and-the-whole-in-an-event/4414/6 "2022-11-25T00:10:54Z")

</div>

Thanks, Alex!

> [In `"2" |+ "1 ~"`, which results in a 3 with a whole from 0 to 1 and a part from 0 to 1/2, by] adding a longer event to a shorter one, we ended up with a fragment of the longer event. For the event in the first cycle, the part is 0-0.5, the whole is 0-1.

That's hard for me to understand. What does the `whole` _mean_ in that? I understand, in the case of an `Event` that's a sub-interval of a longer sample, that the `part` tells you "you're only listening from `start . part` to `end . part` in this `Event`, but (assuming you're hearing it at all) the sample you're listening to runs from `start . whole` to `end . whole`.

But in `"2" |+ "1 ~"` it seems like the whole is describing something completely irrelevant. It will never affect anything. Am I wrong?

Consider two similar examples: `"2" |+ "1 ~ ~ ~"` vs. `"2 ~" |+ "1 ~ ~ ~"`. If we evaluate those in GHCI we get:

```haskell
> "2" |+ "1 ~ ~ ~"
(0>¼)-1|3
> "2 ~" |+ "1 ~ ~ ~"
(0>¼)-½|3

```

Both have the same payload and the same `part` but different `whole`s. But aren't they functionally identical? Is there any circumstance in which one would cause different behavior than the other?

> Tidal doesn't send a trigger message to superdirt in the first place, if the part begins later, because it doesn't have an 'onset' ... Superdirt doesn't know about parts. You can tell it to start halfway and finish early using the start/end parameters though.

Ah, so the logic of comparing parts and wholes happens entirely in Haskell. That makes sense, thanks. It still leaves unanswered, though, my question about onsets for synth `Event`s. Are they the same -- will an `Event` whose `part` starts later than the `whole` fail to trigger a synth, or will it only fail to trigger a sample?

---

<div class="post-metadata">

**Author:** ![archaic.tech](https://uzu.lurk.org/user_avatar/uzu.lurk.org/archaic.tech/32/2965_2.png) [@archaic.tech](https://uzu.lurk.org/u/archaic.tech)\
**Post date:** [25 November 2022 21:55 UTC](https://uzu.lurk.org/t/what-are-the-part-and-the-whole-in-an-event/4414/7 "2022-11-25T21:55:17Z")

</div>

> [@Jeff\_Brown](#):
>
> Ah, so the logic of comparing parts and wholes happens entirely in Haskell. That makes sense, thanks. It still leaves unanswered, though, my question about onsets for synth `Event`s. Are they the same -- will an `Event` whose `part` starts later than the `whole` fail to trigger a synth, or will it only fail to trigger a sample?

Yes—apologies if I was confusing on that point! In terms of synths vs. samples, Tidal doesn't know the difference and sends any event it encounters as a "play" event to SuperDirt as long as the event has a current onset (in terms of part and whole) and has the `s` parameter set.

The only counterexample I know of is the [effect bus](https://club.tidalcycles.org/t/testing-tidal-1-7/2792/3) feature, which works by sending certain effect parameters as Supercollider messages regardless of the relationship between the part and the whole. As a result, these messages are sent every time Tidal samples the pattern (~20hz).

I think the answer to your general question is that Tidal has a lot to say about how complex patterns can be built and (by design) not much to say about what those patterns mean in terms of sounds or lights or whatever.

---

<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:** [27 November 2022 17:17 UTC](https://uzu.lurk.org/t/what-are-the-part-and-the-whole-in-an-event/4414/8 "2022-11-27T17:17:15Z")

</div>

Another way of looking at this is that a pattern is basically a signal, that's a function from time to events.

We could stop there for continuous signals like audio. However we want to support discrete events, where each event has a timespan - i.e. a beginning and an end.

We then need to query the signal using a timespan rather than a single time value, otherwise we might miss some short events by not querying often enough.

We then can end up with events that aren't fully in the query window, so we need to represent the fragment we end up with, using an additional timespan on the event.

---

<div class="post-metadata">

**Author:** ![Jeff\_Brown](https://uzu.lurk.org/user_avatar/uzu.lurk.org/jeff_brown/32/2033_2.png) [@Jeff\_Brown](https://uzu.lurk.org/u/Jeff_Brown)\
**Post date:** [29 November 2022 02:22 UTC](https://uzu.lurk.org/t/what-are-the-part-and-the-whole-in-an-event/4414/9 "2022-11-29T02:22:17Z")

</div>

I submitted a [pull request](https://github.com/tidalcycles/Tidal/pull/976) to add comments to the `Event` type based on this discussion. Thanks again to you both.
